I understand that winmain() is the starting point for a program, but my book only tells me to put in these lines of code, it doesnt actaully tell me what all of this means. I suppose it doesnt tell me because once i put it in a game engine theres no real need for me to understand it, BUT i'd prefer to :)
Could anyone clearly explain to me whats going on here, including what the parameters are for winmain().
Erm you would better googling this I think I know HINSTANCE
Is a handle to an instance, I know some of the rest but agian google is you friend...... http://www.zetcode.com/tutorials/winapi/
Nice little tutorial that I found when I was starting out, might explain a little more
1. as hInstance is a number identifying the instance of a program within the OS environment, does windows give hInstance this number, and if it does would i get an error if i didnt include this parameter?
2. on the website im looking at, its got " hPrevInstance parameter is always NULL. It is a legacy from 16-bit Windows. ". If this is not important, why do we have to put it?
3. I understand the nCmdShow is a value which shows how the window will be displayed. Minimized, maximized or hidden. But do we have to give it a value? And do we HAVE to give WinMain this parameter?
The signature of WinMain is as it is. It is called by the C start up code with those parameters, you cannot change this.
1. hInstance is assigned by Windows, it identifies your particular instance of the application. Think of it as something like a process id, it's a unique number that identifies your instance of the app.
2. In win16, hPrevInstance gave you the instance handle of the previous invocation of the application. In win32 this is always null.
3. As I said before, this is passed to you, you don't assign it a value, it's assigned for you.
4. lpCmdLine is the full unparsed command line passed to the app.
as "Windows programs can still be started from the command line. The parameters given are stored in lpCmdLine", what exactly is stored in lpCmdLine, how would i go about starting the program for the command line, would i have to find out what information is in lpCmdLine
Why don't you display it with MessageBox()? There's no mystery to it.
If you want to write console apps that don't have a GUI, you won't have to deal with all this. The program entry point will be main() like normal C/C++ apps. The use of WinMain is a Windows design flaw.
Look at any Windows application shortcut. You'll see an option to start the app normal, maximized or minimized. That just selects the nCmdShow value to pass into the app. The app can use it, but doesn't have to respect it. You can make your app always start minimised, but if you want to respond to the shortcut, you'll need to use nCmdShow.
I have another question, ill have to buy another book when i can as the one ive got doesnt help much and assumes you already know some of it, even though the book is supposed to be for beginners, anyway... its got:
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)