Like Tree2Likes
  • 1 Post By dmh2000
  • 1 Post By ledow

Learning WINAPI(#include windows.h) for C tutorial suggestions?

This is a discussion on Learning WINAPI(#include windows.h) for C tutorial suggestions? within the C Programming forums, part of the General Programming Boards category; Hello! I have read 2 books on C programming to the point to where I can write C programs proficiently ...

  1. #1
    Registered User
    Join Date
    Jan 2013

    Learning WINAPI(#include windows.h) for C tutorial suggestions?

    Hello! I have read 2 books on C programming to the point to where I can write C programs proficiently with the language itself. The problem is, the books I covered mostly only taught programs with little(to no) use to me. It would cover stuff like, how to calculate sales tax, or how to log customer information. This is all well and fine, but otherwise I feel like I have all this C knowledge and nothing to actually program with it. I recently learned about the WINAPI side of C and found it interesting, as I thought I might could be able to learn some type of C that could help me program GUI applications for games and such. I don't know where I could find a good book on this side of programming, or the limitations of this though. I am asking for suggestions on uses of C, and more information about the WINAPI in this thread for those of you who are more experienced at C than I am. Thanks for your time!

  2. #2
    Registered User
    Join Date
    Mar 2011
    google 'win32 api'
    i found this : theForger's Win32 API Tutorial
    stahta01 likes this.

  3. #3
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    GUI programming is nothing more than calling functions someone else has written to do things - things like, for example, load in a named file and return a structure that represents an image, then another function that takes an image structure and a few integers and draws an image on the screen at a certain point, another that returns how wide/tall the screen is, etc.

    The basics of C have got you to the point where you can run off on your own - so long as you do understand how the language works.

    Now what you need is a "library" (just like the "standard library" that you've been using with printf and everything else in it) that you can "include" the headers of and it will give you a ton of functions to do more interesting stuff. You can start on WINAPI but, to be honest, it can be a bit of a nightmare to achieve even simple things (the tutorial above will start you off).

    Even without that - it's seconds to start off exploring the Win32 API. I'm going to assume you are programming on Windows, so the best thing to do is write a short main that calls a function called MessageBox with a string - should be literally a one-liner outside of the usual code for a program. Then compile it with the library and headers present (in this case you would need to include "windows.h", and use a compiler/linker that knows where to find the Windows libraries) and it should pop up a GUI message box with your string inside it. Google "MessageBox" and you'll find everything you need to know to use that one function, change the icon, window title, etc. If you manage that, the same page that describes MessageBox should show you bunches of other WinAPI functions that you can delve into - everything that's possible to do in a Windows program.

    Similarly, you could also just start using something like the SDL library. Again, just make a program that includes the SDL header file (sometimes trickily you need to use include <SDL/SDL.h>) and links to the SDL library and you're away - just start calling SDL functions in their appropriate way and you can do everything from read the mouse or joystick to play a sound to draw graphics to implement timers, etc.

    You're at the point where (with an API reference sheet for the library of your choice, which lists what every function does, what it takes as parameters and what it returns), you should be able to write just about anything you like - with a bit of legwork and guesswork and tinkering.

    Go explore! I suspect your first hurdle will be getting a working library/include/path setup in your compiler (i.e. nothing to do with actually programming C at all).
    Matticus likes this.


  4. #4
    Registered User
    Join Date
    Dec 2012
    personally i started using win api commands for resizing a console, getting console size, getting curser location and moving curser location, ect...

    over all though, i gave up on the OVER complicated and mass of code you need to use just to make a dialog box.

    i now use QT for all my gui, and of course pelles c ide for my console. IF you are really set on API, forger is pretty decent to learn from, if you just want to make gui programs, check out QT and see which you like more!

  5. #5
    Cat is offline
    Registered User
    Join Date
    May 2003
    Well, I don't regret learning WinAPI, but nowadays I do pretty much everything in C# WinForms - not because I can't do it in WinAPI, but because I can cut development time down by an order of magnitude. WinAPI is powerful, but very low level - it takes longer to write and it's harder to maintain. It's good to know since it underpins everything Windows related, but writing meaningful programs in WinAPI is somewhat like writing meaningful programs in assembly language - certainly possible, and also certainly challenging and time consuming.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Include syntax-highlighting for Tutorial Pages
    By Panarchy in forum General Discussions
    Replies: 0
    Last Post: 10-20-2010, 11:18 PM
  2. #include <windows.h> and #include <wininet.h>
    By steve1_rm in forum C++ Programming
    Replies: 4
    Last Post: 03-30-2009, 11:14 AM
  3. Learning C for OSX, tutorial suggestions please
    By Nexum in forum C Programming
    Replies: 2
    Last Post: 02-17-2003, 03:57 AM
  4. File I/O Tutorial- suggestions
    By loobian in forum A Brief History of
    Replies: 0
    Last Post: 03-18-2002, 02:38 PM
  5. Learning Material Suggestions
    By shotgunmoose in forum C++ Programming
    Replies: 2
    Last Post: 01-30-2002, 02:59 PM

Tags for this Thread
