Jump to content
  • Advertisement
Sign in to follow this  
snoddas14

WinProc Error and some more!

This topic is 4145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i will just print it all up! here comes the code!
/****************************************************************
* example1
* this application shows how to setup a standard windows 
* application
****************************************************************/
#include <windows.h>

// global variables
HINSTANCE hInst;
HWND wndHandle;

// forward declarations
bool initWindow(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, 
				   HINSTANCE hPrevInstance, 
				   LPTSTR lpCmdLine, int nCmdShow)
{
	if (!initWindow(hInstance))
		return false;
	
	// Main message loop:
    MSG msg; 
    ZeroMemory( &msg, sizeof(msg) );
    while( msg.message!=WM_QUIT )
    {
		if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
        {
			TranslateMessage( &msg );
            DispatchMessage( &msg );
        }		
    }
		
	return (int) msg.wParam;
}

bool initWindow(HINSTANCE hInstance)
{
	WNDCLASSEX wcex;

	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.lpszClassName	= "DirectXExample";
	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)
      return false;
   
   ShowWindow(wndHandle, SW_SHOW);
   UpdateWindow(wndHandle);

   return true;
}


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) 
	{
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}
------ Build started: Project: Example1, Configuration: Debug Win32 ------
Compiling...
winmain.cpp
c:\documents and settings\main.cpp\mina dokument\visual studio 2005\projects\example1\example1\winmain.cpp(19) : error C2731: 'WinMain' : function cannot be overloaded
        c:\documents and settings\main.cpp\mina dokument\visual studio 2005\projects\example1\example1\winmain.cpp(16) : see declaration of 'WinMain'
c:\documents and settings\main.cpp\mina dokument\visual studio 2005\projects\example1\example1\winmain.cpp(52) : error C2440: '=' : cannot convert from 'const char [15]' to 'LPCWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\main.cpp\mina dokument\visual studio 2005\projects\example1\example1\winmain.cpp(67) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [15]' to 'LPCWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Build log was saved at "file://c:\Documents and Settings\Main.cpp\Mina dokument\Visual Studio 2005\Projects\Example1\Example1\Debug\BuildLog.htm"
Example1 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[Edited by - jollyjeffers on February 13, 2007 3:08:10 PM]

Share this post


Link to post
Share on other sites
Advertisement

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)

should be


int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!