View Single Post
  #1 (permalink)  
Old December 21st, 2008, 03:23 PM
iceman90289 iceman90289 is offline
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default Reposting in a more active forum

i get two errors when i compile this. the first tells me i cant overload winmain the second says i cant convert parameter two from x-type to y-type in the part where i have "windowhandle = CreateWindow(...); in the initialize window function. i am not sure what i am doing wrong. i have typed the code twice. and i am using VS2k5 pro ed. thanks in advance

// Include windows header
#include<windows.h>
HINSTANCE hInst;
HWND wndHandle;
// Prototypes
bool initWindow( HINSTANCE hInstance );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
// Entry point
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
// Init window
if( !initWindow(hInstance))
returnfalse;
// Message loop
MSG msg;
ZeroMemory( &msg,
sizeof( msg) );
while( msg.message!=WM_QUIT )
{
// Check the msg queue
while(GetMessage(&msg, wndHandle, 0, 0) )
{
TranslateMessage( &msg );
DispatchMessage( &msg);
}
}
return (int)msg.wParam;
}
bool initWindow( HINSTANCE hInstance )
{
WNDCLASSEX wcex;
// Fill in the wndclassex struct
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.hIconSm = 0;
RegisterClassEx(&wcex);
// Create the window
wndHandle = CreateWindow(
"DirectXExample",
"DirectXExample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
NULL,
NULL,
hInstance,
NULL);
if(!wndHandle)
returnfalse;
// Display window
ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
returntrue;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// Check any available msgs
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
Reply With Quote