Results 1 to 7 of 7

Thread: Does not execute it for which reason?

Threaded View

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Post Does not execute it for which reason?

    I have written the following code to create a simple window. But the problem is that whenever I click execute button. It does not execute(run) it. It does nothing.

    Please Note:

    I am using Visual C++ 6 Enterprise, and every other program is executed except this one. I also copied and pasted the code from www.winpro.org to create a simple window and it works fine. Please find any error if you can.

    Code:
    #include <windows.h>
    static char myclass[] = "t";
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
    {
    	switch(msg)
    	{
    	case WM_CLOSE:
    		DestroyWindow(hwnd);
    		break;
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		break;
    	default:
    		return WndProc(hwnd, msg, wparam, lparam);
    	}
    	return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    	WNDCLASSEX wc;
    	MSG message;
    	HWND hwnd;
    
    	wc.cbClsExtra = 0;
    	wc.cbWndExtra = 0;
    	wc.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH);
    	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hInstance = hInstance;
    	wc.lpfnWndProc = WndProc;
    	wc.lpszMenuName = myclass;
    	wc.lpszMenuName = NULL;
    	wc.style = NULL;
       
    
    	if(!RegisterClassEx(&wc))
    	{
    		return 0;
    	}
    
    	hwnd = CreateWindowEx(
    			WS_EX_CLIENTEDGE,
    			myclass,
    			"This is win",
    			WS_OVERLAPPEDWINDOW,
    			0,
    			0,
    			100,
    			100,
    			NULL,
    			NULL,
    			hInstance,
    			NULL);
    	if(hwnd == NULL)
    	{
    		return 0;
    	}
    
    	ShowWindow(hwnd, nShowCmd);
    	UpdateWindow(hwnd);
    
    	while(GetMessage(&message, NULL, 0,0))
    	{
    		TranslateMessage(&message);
    		DispatchMessage(&message);
    	}
    
    	return message.wParam;
    }
    Thanks!
    Last edited by abdul; May 4th, 2001 at 07:53 PM.
    Baaaaaaaaah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width