Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 21st, 2008, 03:23 PM
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
  #2 (permalink)  
Old January 12th, 2009, 05:16 PM
Authorized User
 
Join Date: Nov 2008
Posts: 15
Thanks: 1
Thanked 1 Time in 1 Post
Default

In case you're still watching this thread:

The "overloaded winmain" error occurs because of Unicode support. You can turn this off in Project->Properties->Character Set (switch it to "not set").

Alternately, you can rename WinMain to wWinMain, and it should compile.

However there's another problem with your code. Your window class structure is ommitting the class name, lpszClassName, which should be set to "DirectXExample" according to your code (wcex.lpszClassName = "DirectXExample" or if you're using Unicode, wcex.lpszClassName = L"DirectXExample".
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I creat a forum like P2P Forum? pcassiano ASP.NET 1.0 and 1.1 Basics 1 October 31st, 2005 05:00 AM
Active X razi BOOK: Beginning Visual C++ 6 0 July 22nd, 2005 01:37 AM
more active free forum! nerssi BOOK: Professional Jakarta Struts 1 May 6th, 2005 04:50 AM
converting Forum.aspx to Forum.ascx (help) drfunkie BOOK: ASP.NET Website Programming Problem-Design-Solution 1 July 11th, 2003 12:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.