problem understanding wondows and directx programing

Started by
0 comments, last by TDragon 18 years, 10 months ago
Hi ma name is Razvan and i am from romania. I started learning programing in Borland pascal a long time ago.then i was learning from a teacher.After that i started learning from books and magazines . Now i know c++ and DJGPP. these are so well implemented in my head that i find impossible to understand windows programing whatever what i read about it. Someone please help me understand the most simple program.
Advertisement
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){    return 0;}

This is the most simple Windows program. You'll notice that the only difference from a console program is the number of arguments to main (and the name, which is changed to WinMain). Because Windows is multitasking, it provides INSTANCEs to let you know if there is more than one copy of your program running -- so hInstance is the copy that was just opened, and hPrevInstance is the one before it (if there is one). lpCmdLine is the command line to your program. Nowadays, this is mostly a remnant from good old DOS, but beginners and simple programs can use it to detect if a file was dragged'n'dropped on the exe (or you can run your program from the command prompt, if you like). It's not separated into the various arguments like the classic main, so you have to parse it yourself. Finally, nShowCmd is a way of telling you that, if you create a window, it needs to be shown a certain way.

Creating windows, and managing them, is rather more complex. First, you must fill in and register a window class. Then you call CreateWindow or CreateWindowEx to create the window, then ShowWindow to show it (in most cases). Finally, you go into a loop to start pumping messages: as a part of creating the window class, you define a message processing function that will be called whenever the user does something to your window -- for example, when they click it, the message function will get a WM_CLICK message.

To see all of this put together in a fairly simple windowed application, view A Generic Sample Application from the MSDN Library.
{[JohnE, Chief Architect and Senior Programmer, Twilight Dragon Media{[+++{GCC/MinGW}+++{Code::Blocks IDE}+++{wxWidgets Cross-Platform Native UI Framework}+++

This topic is closed to new replies.

Advertisement