Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionFirst 4 bytes of EDITSTREAM destination buffer overlay Pin
ForNow4-May-09 12:54
ForNow4-May-09 12:54 
AnswerRe: First 4 bytes of EDITSTREAM destination buffer overlay Pin
Garth J Lancaster4-May-09 13:55
professionalGarth J Lancaster4-May-09 13:55 
GeneralRe: First 4 bytes of EDITSTREAM destination buffer overlay Pin
ForNow4-May-09 14:22
ForNow4-May-09 14:22 
QuestionRe: First 4 bytes of EDITSTREAM destination buffer overlay Pin
«_Superman_»4-May-09 14:53
professional«_Superman_»4-May-09 14:53 
AnswerRe: First 4 bytes of EDITSTREAM destination buffer overlay Pin
ForNow4-May-09 14:56
ForNow4-May-09 14:56 
GeneralRe: First 4 bytes of EDITSTREAM destination buffer overlay Pin
Garth J Lancaster4-May-09 15:20
professionalGarth J Lancaster4-May-09 15:20 
GeneralRe: First 4 bytes of EDITSTREAM destination buffer overlay Pin
ForNow4-May-09 16:01
ForNow4-May-09 16:01 
QuestionProblem using WinMain function with C++ Pin
Gindi Bar Yahav4-May-09 11:08
Gindi Bar Yahav4-May-09 11:08 
Hey, i hope you can help me with my question:
I started learning working with DirectX, in the start i saw a codeexample for how open an empty window (without chosing winn app at the start of Visual Studio)
but for some reson, the code makes me problems, hope you can say to me why

code
#include <windows.h>

HINSTANCE hInst; // global handle to hold the application instance
HWND wndHandle; // global variable to hold the window handle

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

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
	// Initialize the window
	if ( !initWindow( hInstance ) )
	{
		return false;
	}
	
	// main message loop:
	MSG msg;
	
	ZeroMemory( &msg, sizeof( msg ) );
	
	while( msg.message!=WM_QUIT )
	{
		// Check the message 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 structure. This describes how the window
	// will look to the system

	wcex.cbSize = sizeof(WNDCLASSEX); // the size of the structure
	wcex.style = CS_HREDRAW | CS_VREDRAW; // the class style
	wcex.lpfnWndProc = (WNDPROC)WndProc; // the window procedure callback
	wcex.cbClsExtra = 0; // extra bytes to allocate for this class
	wcex.cbWndExtra = 0; // extra bytes to allocate for this instance
	wcex.hInstance = hInstance; // handle to the application instance
	wcex.hIcon = 0; // icon to associate with the application
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);// the default cursor
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); // the background color
	wcex.lpszMenuName  = NULL; // the resource name for the menu
	wcex.lpszClassName = "DirectXExample"; // the class name being created
	wcex.hIconSm = 0; // the handle to the small icon
	RegisterClassEx( &wcex );
	// Create the window
	wndHandle = CreateWindow(
		"DirectXExample",
		"DirectXExample",
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, // the starting x coordinate
		CW_USEDEFAULT, // the starting y coordinate
		640, // the pixel width of the window
		480, // the pixel height of the window
		NULL, // the parent window; NULL for desktop
		NULL, // the menu for the application; NULL for
		hInstance, // the handle to the application instance
		NULL); // no values passed to the window
	// Make sure that the window handle that is created is valid
	if (!wndHandle)
	{
		return false;
	}
	
	// Display the window on the screen
	ShowWindow(wndHandle, SW_SHOW);
	
	UpdateWindow(wndHandle);
	
	return true;
}


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	// Check any available messages from the queue
	switch (message)
	{
		case WM_DESTROY:
			PostQuitMessage(0);
		break;
	}
	
	// Always return the message to the default window
	// procedure for further processing
	return DefWindowProc(hWnd, message, wParam, lParam);
}


Errors:
Error 1 error C2731: 'WinMain' : function cannot be overloaded c:\users\יהב\documents\visual studio 2008\projects\learningdirectx\learningdirectx\winmain.cpp 11 LearningDirectX
Error 2 error C2065: '“DirectXExample”' : undeclared identifier c:\users\יהב\documents\visual studio 2008\projects\learningdirectx\learningdirectx\winmain.cpp 56 LearningDirectX
Error 3 error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [15]' to 'LPCWSTR' c:\users\יהב\documents\visual studio 2008\projects\learningdirectx\learningdirectx\winmain.cpp 71 LearningDirectX


Sorry to ask but please try to help me (I couldnt solve it for hours before i came here)

Thanks and good day, Yahav.

Gindi Bar Yahav - Web & Software defeloper.

AnswerRe: Problem using WinMain function with C++ Pin
I am BATMAN4-May-09 11:26
I am BATMAN4-May-09 11:26 
AnswerRe: Problem using WinMain function with C++ Pin
Adam Maras4-May-09 11:39
Adam Maras4-May-09 11:39 
GeneralRe: Problem using WinMain function with C++ Pin
Gindi Bar Yahav4-May-09 11:47
Gindi Bar Yahav4-May-09 11:47 
Question[Message Deleted] Pin
Greg Mort4-May-09 9:20
Greg Mort4-May-09 9:20 
Answer[Message Deleted] Pin
led mike4-May-09 9:23
led mike4-May-09 9:23 
General[Message Deleted] Pin
Greg Mort4-May-09 9:40
Greg Mort4-May-09 9:40 
General[Message Deleted] Pin
led mike4-May-09 10:51
led mike4-May-09 10:51 
GeneralRe: Cross Posted - Reposted Pin
Greg Mort4-May-09 10:56
Greg Mort4-May-09 10:56 
QuestionWhy do you ignore received suggestions? Pin
CPallini4-May-09 9:32
mveCPallini4-May-09 9:32 
AnswerRe: Why do you ignore received suggestions? Pin
Greg Mort4-May-09 9:42
Greg Mort4-May-09 9:42 
GeneralRe: Why do you ignore received suggestions? Pin
CPallini4-May-09 9:52
mveCPallini4-May-09 9:52 
GeneralRe: Why do you ignore received suggestions? Pin
Greg Mort4-May-09 9:57
Greg Mort4-May-09 9:57 
QuestionRe: Why do you ignore received suggestions? Pin
David Crow4-May-09 10:02
David Crow4-May-09 10:02 
AnswerRe: Why do you ignore received suggestions? Pin
Greg Mort4-May-09 10:08
Greg Mort4-May-09 10:08 
QuestionRe: Why do you ignore received suggestions? Pin
CPallini4-May-09 10:24
mveCPallini4-May-09 10:24 
AnswerRe: Why do you ignore received suggestions? Pin
Greg Mort4-May-09 10:49
Greg Mort4-May-09 10:49 
GeneralRe: Why do you ignore received suggestions? Pin
CPallini4-May-09 21:01
mveCPallini4-May-09 21:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.