Window Problem (Win32)

Posts 1–9 of 9 · Page 1 of 1
Window Problem (Win32)
what is wrong with my code? (other than messiness, lol)
I am trying to create Two windows but the second one isn't showing up, i have been trying to figure it out for a long time so your guys' help is greatly appreciated. Thanks for your help in advance. Here is mainly the conflicting code:



Code:
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK AgpeyaProc (HWND, UINT, WPARAM, LPARAM) ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
   static TCHAR szAppName[] = TEXT ("St. Demiana Homepage") ;  
   static TCHAR agpeyawcn[] = TEXT("Agpeya");  
   HWND         hwnd, agpeyawindow ;
     MSG          msg ;
     WNDCLASS     wndclass ;
	 WNDCLASS     agpeyawin;
	 hInst = hInstance;
	 HINSTANCE agpeyawindowhinstance = hInstance;
     //------Main Window Code------------------------
	 wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     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 = CreateSolidBrush(RGB(255,0,0)) ;
     wndclass.lpszMenuName  = TEXT("Demiana") ;
     wndclass.lpszClassName = szAppName ;
	
     if (!RegisterClass (&wndclass))
     {
          MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
    }
	 //----------------------------------------------

	 //-------Agpeya Window--------------------------------
	 agpeyawin.style = CS_HREDRAW | CS_VREDRAW;
	 agpeyawin.lpfnWndProc = AgpeyaProc;
	 agpeyawin.cbClsExtra = 0;
	 agpeyawin.cbWndExtra = 0;
	 agpeyawin.hInstance = hInstance;
	 agpeyawin.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	 agpeyawin.hCursor = LoadCursor(NULL, IDC_ARROW);
	 agpeyawin.hbrBackground = CreateSolidBrush(RGB(0,0,255));
	 agpeyawin.lpszMenuName = 0;
	 agpeyawin.lpszClassName = agpeyawcn;

     hwnd = CreateWindow (szAppName,                        // window class name
                          TEXT ("St. Demiana Home Screen"), // window caption
                          WS_OVERLAPPEDWINDOW,        // window style
                          CW_USEDEFAULT,              // initial x position
                          CW_USEDEFAULT,              // initial y position
                          CW_USEDEFAULT,              // initial x size
                          CW_USEDEFAULT,              // initial y size
                          NULL,                       // parent window handle
                          NULL,                       // window menu handle
                          hInstance,                  // program instance handle
                          NULL) ;                     // creation parameters

     
     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ;
     
	 agpeyawindow = CreateWindow(agpeyawcn,
								 TEXT("Agpeya"), 
								 WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
								 CW_USEDEFAULT,
								 CW_USEDEFAULT,
								 CW_USEDEFAULT,
								 CW_USEDEFAULT,
								 NULL,
								 NULL,
								 hInstance,
								 NULL);
	 ShowWindow(agpeyawindow, SW_MAXIMIZE);
	 UpdateWindow(agpeyawindow);
     while (GetMessage (&msg, NULL, 0, 0))
     {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     }
     return msg.wParam ;
}
Thats what im currently learning..
Your guess is as good as mine
Lol, ya I hate it when u code something but there is just one mistake that u keep overlooking and u just can't find it until someone points it out then u feel stupid lol.
Change the windows Procedure for the agpeya WNDCLASS struct to WndProc.
That isn't how you create a second window, and wheres the callback function?

under the WM_CREATE message you call CreateWindow.
Oh oooops, so I should keep the wndclass struct for agpeya Changing the callback to wndproc but I should show the window or create it in the wm_create message for my main window proc?

Sorry for my retardedness in my last post, did u guys mean I should do the whole WndClass struct for the agpeya window In the wm_create message in wndproc? Btw thanks for ur guys help when I m able to access a comp I will give u guys a thx
You dont make another class for another window. The first parameter of CreateWindow is the class name of the window you're going to make, so if you want to make a button, there's a predefined class you use, "button". But you want a new window, so you leave it blank or name it something new, which ever you want, doesn't really matter for now.

[Highlight=C++]

HWND wnd;
callback function(params...)
{
switch( params )
{
case WM_CREATE:
wnd = CreateWindow("New_Class","Caption",...);
break;
}
}

WinMain function()
{
...

ShowWindow(wnd);
}
[/Highlight]
Thanks a bunch
lol, it had nothing to do with what u said Austral, i fixed itt though, thanks
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us