int WINAPI WinMain(...) HELP!

This is a discussion on int WINAPI WinMain(...) HELP! within the Windows Programming forums, part of the Platform Specific Boards category; ok i have this code...this should look very similar to many windows applications Code: #include <windows.h> int WINAPI WinMain(HINSTANCE, HINSTANCE ...

  1. #1
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196

    int WINAPI WinMain(...) HELP!

    ok i have this code...this should look very similar to many windows applications

    Code:
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE, HINSTANCE hPrevInstance,
    				   PSTR szCmdLine, int iShowCmd)
    {
    	static TCHAR szAppName[] = TEXT("win prog");
    	HWND hwnd;
    	MSG msg;
    	WNDCLASS wndclass;
    
    	wndclass.style = WS_VREDRAW | WS_HREDRAW;
    	//wndclass.lpfnWndProc = WndProc;
    	wndclass.cbClsExtra = 0;
    	wndclass.cbWndExtra = 0;
    	wndclass.hInstance = hInstance;
    	wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wndclass.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
    	wndclass.lpszMenuName = NULL;
    	wndclass.lpszClassName = szAppName;
    
    	//create window code goes here
    	
    	UpdateWindow(hwnd);
    
    	return 0;
    }
    ok i get the WNDCLASS...but what does the HWND hwnd class has to do anything with the WNDCLASS wndclass...hwnd is one object and wndclass is another object..why do i update the hwnd and not the wndclass...isnt wndclass the window?....please do help


    also how is hwnd linked to wndclass....they look like two different objects..and you didnt even declare a single variable for hwnd..how can hwnd be wndclass?..please clear things up please
    Last edited by nextus; 03-02-2003 at 10:57 PM.
    nextus, the samurai warrior

  2. #2
    Registered User dizolve's Avatar
    Join Date
    Dec 2002
    Posts
    68
    The WNDCLASS is simply an object for giving information on the window class to be registered. The HWND is the actual handle to your window after you register the class and create the window.

    Edit:

    I noticed I didn't explain much. Window classes are used to tell what kind of window to create with certain properties. You can have multiple windows of one class. However, every HWND is different. When you UpdateWindow(HWND); you're updating that specific window.

    Edit #2:

    It's assigned when you do CreateWindow or CreateWindowEx.. it should look like hwnd = CreateWindowEx(...);
    Last edited by dizolve; 03-02-2003 at 11:00 PM.

  3. #3
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    nevermind i am so stupid..i just found my own answer..

    Code:
    hwnd = CreateWindow ("Window Class 1",					// window class name - This tells CreateWindow() to use our class up above.
    						 "My First Window",		  			// window's Title    - This will be the name on the title bar of the window.
    						 WS_OVERLAPPEDWINDOW,				// window style		 - This flag tells windows to create a typical window, (options like resize, minimize, close, etc).
    						 CW_USEDEFAULT,						// initial x position- The top left corner X value of the window in screen coordinates.  This flag let's windows choose for us.
    						 CW_USEDEFAULT,						// initial y position- The top left corner Y value of the window in screen coordinates.  This flag let's windows choose for us.
    						 CW_USEDEFAULT,						// initial x size	 - The bottom right corner X value of the window in screen coordinates.  This flag let's windows choose for us.
    						 CW_USEDEFAULT,					    // initial y size	 - The bottom right corner Y value of the window in screen coordinates.  This flag let's windows choose for us.
    						 NULL,								// This is the parent window handle.  Since we don't have a parent window, we set this to NULL
    						 NULL,								// This is the window menu handle, but since we don't have a menu, we set this to NULL.
    						 hInstance,						    // This is the programs instance handle.  We just pass it our hInstance from our WinMain().  By the way, Windows OS passes the info to WinMain(). It's all taken care of for us.
    						 NULL);
    sorry for the dumb question
    Last edited by nextus; 03-02-2003 at 11:01 PM.
    nextus, the samurai warrior

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  2. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  3. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-01-2003, 11:26 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 04:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21