basic window wont show on vista 64

This is a discussion on basic window wont show on vista 64 within the Windows Programming forums, part of the Platform Specific Boards category; ive just switched from xp 32bit to vista 64bit and installed visual studio express 2008 , the code compiles fine ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    319

    basic window wont show on vista 64

    ive just switched from xp 32bit to vista 64bit and installed visual studio express 2008 , the code compiles fine but fails to show the window , but the process is running in task manager , anyone know the problem

    Code:
    #include "stdafx.h"
    #include <windows.h>
    #include "Dx.h"
    
    
    
    HWND g_hwnd;
    
    INT WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,INT)
    {
    	RegisterWindowClass(hInstance);
    	RegisterWindow(hInstance);
    	ShowWindow(g_hwnd,SW_SHOWDEFAULT);
    	UpdateWindow(g_hwnd);
    	INT result = StartMessageLoop();
    	return result;
    }
    
    LRESULT WINAPI WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
    {
    	switch(msg)
    	{
    	case WM_CREATE:
    		return 0;
    
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    
    	case WM_PAINT:
    		ValidateRect(g_hwnd,NULL);
    		return 0;
    	}
    	return DefWindowProc(hWnd,msg,wParam,lParam);
    }
    
    void RegisterWindowClass(HINSTANCE hInstance)
    {
    	WNDCLASSEX wc;
    	wc.cbSize = sizeof(WNDCLASSEX);
    	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    	wc.lpfnWndProc = WndProc;
    	wc.cbClsExtra = 0;
    	wc.cbWndExtra = 0;
    	wc.hInstance = hInstance;
    	wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
    	wc.hCursor = (HCURSOR)LoadCursor(hInstance,IDC_ARROW);
    	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    	wc.lpszMenuName = NULL;
    	wc.lpszClassName = "WinApp";
    	wc.hIconSm = NULL;
    	RegisterClassEx(&wc);
    }
    
    void RegisterWindow(HINSTANCE hInstance)
    {
    	g_hwnd = CreateWindowEx(NULL,"WinApp","Basic Windows Application",
    		                        WS_OVERLAPPEDWINDOW,
    								100,
    								100,
    								648,
    								514,
    								GetDesktopWindow(),
                                    NULL,
    								hInstance,
    								NULL);
    }
    
    WPARAM StartMessageLoop()
    {
    	MSG msg;
    	while(1)
    	{
    		if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
    		{
    			if(msg.message == WM_QUIT)
    				break;
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    		else
    		{
    
    		}
    	}
    	return msg.wParam;
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    A recent similar post went with

    Code:
    WNDCLASSEX wc = { 0 };
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File IO
    By Jack1982 in forum C++ Programming
    Replies: 9
    Last Post: 10-15-2007, 01:14 AM
  2. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  3. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM
  4. Winamp Vis if anyone can help
    By Unregistered in forum Windows Programming
    Replies: 6
    Last Post: 01-26-2002, 11:43 PM
  5. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM

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