Note that there are some explanatory texts on larger screens.

plurals
  1. POno window appears in Visual C++ program
    text
    copied!<p>I am developing an Win32 application where user logins when the application starts in a login window and then the main window opens</p> <p>But when I run the program nothing appears. </p> <p>Here's the code</p> <pre><code>HINSTANCE ghInstance; HWND hWnd; HWND hWndPopUp; LRESULT WINAPI PopUpWndProc( HWND hWnd2, UINT msg, WPARAM wParam, LPARAM lParam ); LRESULT WINAPI MainWndProc( HWND hWnd , UINT msg , WPARAM wParam , LPARAM lParam ); int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpszCmdLine , int nCmdShow){ WNDCLASS wc; WNDCLASS wcPopUp; MSG msg; //HWND hWnd; BOOL bRet; if( !hPrevInstance ) { wc.lpszClassName = L"MainAppClass" ; wc.lpfnWndProc = MainWndProc ; wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW ; wc.hInstance = hInstance ; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ) ; wc.hCursor = LoadCursor( NULL, IDC_ARROW ) ; wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 ) ; wc.lpszMenuName = NULL ; wc.cbClsExtra = 0 ; wc.cbWndExtra = 0 ; RegisterClass( &amp;wc ) ; wcPopUp.lpszClassName = L"PopUpAppClass" ; wcPopUp.lpfnWndProc = PopUpWndProc ; wcPopUp.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW ; wcPopUp.hInstance = hInstance ; wcPopUp.hIcon = LoadIcon( NULL, IDI_APPLICATION ) ; wcPopUp.hCursor = LoadCursor( NULL, IDC_ARROW ) ; wcPopUp.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 ) ; wcPopUp.lpszMenuName = NULL ; wcPopUp.cbClsExtra = 0 ; wcPopUp.cbWndExtra = 0 ; RegisterClass( &amp;wcPopUp ); } ghInstance = hInstance; hWndPopUp = CreateWindowEx(WS_EX_CONTEXTHELP, wcPopUp.lpszClassName, L"Stock Ticker Login", WS_OVERLAPPEDWINDOW, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); bool show = ShowWindow( hWndPopUp, SW_MAXIMIZE ) ; UpdateWindow(hWndPopUp); hPE = NULL; /** While there is no WM_QUIT message in the Message Queue Fetch Message from the queue and Dispatch it to WindowProc() **/ while( (bRet = GetMessage( &amp;msg, NULL, 0, 0 )) != 0 ) { if (bRet == -1) { // handle the error and possibly exit int nerror = GetLastError(); MessageBox(hWnd,L"Window Error",L"Window error", MB_ICONERROR); exit(1); } else { TranslateMessage( &amp;msg ); DispatchMessage( &amp;msg ); } } return (int)msg.wParam; } LRESULT WINAPI PopUpWndProc( HWND hWnd2, UINT msg, WPARAM wParam, LPARAM lParam ){ HDC hdc; PAINTSTRUCT ps; RECT rc; GetClientRect(hWnd, &amp;rc); int height = rc.bottom - rc.top; int width = rc.right -rc.left; switch( msg ) { case WM_CREATE: hWndStaticUsername = CreateWindowEx( 0 , L"static" , L"Username" , WS_CHILD | WS_VISIBLE , rc.left + width/8 , rc.top + height/4 , 100 , 30 , hWnd2 , 0 , ghInstance , 0 ); hWndEditUsername = CreateWindowEx( WS_EX_CLIENTEDGE , L"edit" , L"" , WS_CHILD | WS_VISIBLE , rc.left + width/8 + 150 , rc.top + height/4 , 150 , 30 , hWnd2 , 0 , ghInstance , 0 ); hWndBtnLogin = CreateWindowEx( 0 , L"button" , L"Login" , WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , rc.left + width/8 , rc.top + height/4 + 80 , 50 , 30 , hWnd2 , 0 , ghInstance , 0 ); break; case WM_COMMAND: if(HIWORD(wParam)== BN_CLICKED &amp;&amp; lParam==(LPARAM)hWndBtnLogin ) { TCHAR* uname =new TCHAR; Edit_GetText(hWndEditUsername, uname, 20); if(wcscmp(uname,L"")==0) return 0; else { StartTicker(uname); DestroyWindow(hWnd); } } break; case WM_DESTROY: hWnd = CreateWindowEx(WS_EX_CONTEXTHELP, L"MainAppClass", L"Assignment 2", WS_OVERLAPPEDWINDOW, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, ghInstance, NULL ); ShowWindow( hWnd, SW_MAXIMIZE ) ; UpdateWindow(hWnd); break; default: return DefWindowProc(hWnd, msg, wParam, lParam ); } return 0; } </code></pre> <p>Please help me find the solution.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload