Click here to Skip to main content
15,887,875 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: "Navigate2 " function error in ie7.0.. Pin
jhhan27-Aug-10 12:42
jhhan27-Aug-10 12:42 
QuestionProblem on bitmap Pin
sahaja_p2-Jun-06 23:13
sahaja_p2-Jun-06 23:13 
AnswerRe: Problem on bitmap Pin
Laxman Auti3-Jun-06 1:17
Laxman Auti3-Jun-06 1:17 
GeneralRe: Problem on bitmap Pin
RockyJames3-Jun-06 1:28
RockyJames3-Jun-06 1:28 
GeneralRe: Problem on bitmap Pin
_AnsHUMAN_ 3-Jun-06 2:04
_AnsHUMAN_ 3-Jun-06 2:04 
AnswerRe: Problem on bitmap Pin
John R. Shaw3-Jun-06 3:12
John R. Shaw3-Jun-06 3:12 
GeneralRe: Problem on bitmap Pin
preethip4-Jun-06 20:34
preethip4-Jun-06 20:34 
QuestionMessage loop not branching properly Pin
Goldstandard2-Jun-06 21:24
Goldstandard2-Jun-06 21:24 
Hi, I have been trying to learn how to use Direct3D, but I keep running into problems. After scratching my head for a while, and using the OutputDebugString() function, I found out that it was my message loop not branching correctly. It seems that PeekMessage is always returning true so I never get to the block of code that renders to the screen. I can't figure out how to fix the problem though; I was wondering if anyone here has any idea. BTW, I use a wrapper class to hold all my D3D code, thats what the g_Screen.render(); statement comes from.

#include "display.h"

//-------------------------------------------------------------
// Globals
//-------------------------------------------------------------
const char g_szClassName[] = "Sandboxdx9";
Display g_Screen;
bool isrendered = false;

//-------------------------------------------------------------
// Prototypes
//-------------------------------------------------------------
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

//-------------------------------------------------------------
// Application entry point
//-------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance,
				   HINSTANCE prevInstance, 
				   LPSTR lpCmdLine, 
				   int nCmdShow)
{
	WNDCLASSEX wc;
	HWND hwnd;
	MSG msg;

	// Register Window class
	wc.cbSize           = sizeof(wc);
	wc.style            = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc      = WndProc;
	wc.cbClsExtra       = 0;
	wc.cbWndExtra       = 0;
	wc.hInstance        = hInstance;
	wc.hIcon            = LoadIcon(NULL, IDI_APPLICATION);
	wc.hIconSm          = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor          = NULL;
	wc.hbrBackground    = (HBRUSH)GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName     = NULL;
	wc.lpszClassName    = g_szClassName;

	if(!RegisterClassEx(&wc))
	{
		OutputDebugString("Window Registration failed!\n");
		return E_FAIL;
	}

	// Create the Window
	hwnd = CreateWindowEx(0, g_szClassName, "Sandbox", WS_POPUP | WS_SYSMENU | WS_VISIBLE, 
		                  0, 0, 640, 480, NULL, NULL, hInstance, NULL);

	if(hwnd == NULL)
	{
		OutputDebugString("Window Creation failed!\n");
		return E_FAIL;
	}

	// Initialize d3d
	if(g_Screen.init(hwnd) == false)
	{
		OutputDebugString("D3D initialization failed!\n");
		return E_FAIL;
	}

	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);

	ShowCursor(false);

	memset(&msg,0,sizeof(msg));
	while(TRUE)
	{
		if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) // Bug is here, always returns true
		{
			if(msg.message == WM_QUIT)
				break;

			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			isrendered = true;
			g_Screen.render();
		}
	}

	if(isrendered)
		OutputDebugString("It rendered.\n");
	else
		OutputDebugString("It didn't render.\n");


	UnregisterClass(g_szClassName, wc.hInstance);

	return (int)msg.wParam;
}

//-------------------------------------------------------------
// WndProc - Message Handler
//-------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_CREATE:
		{
		}
		break;
	case WM_DESTROY:
		{
			PostQuitMessage(0);
		}
		break;
	case WM_CLOSE:
		{
			PostQuitMessage(0);
		}
		break;
	case WM_PAINT:
		{
		}
		break;
	case WM_KEYDOWN:
		{
			switch(wParam)
			{
			case VK_ESCAPE:
				{
					PostQuitMessage(0);
				}
				break;
			}
		}
		break;
	default:
		{
			return DefWindowProc(hwnd, msg, wParam, lParam);
		}
		break;
	}
	return 0;
}

AnswerRe: Message loop not branching properly Pin
John R. Shaw3-Jun-06 4:01
John R. Shaw3-Jun-06 4:01 
GeneralRe: Message loop not branching properly Pin
Goldstandard3-Jun-06 20:21
Goldstandard3-Jun-06 20:21 
GeneralRe: Message loop not branching properly Pin
John R. Shaw13-Jun-06 22:17
John R. Shaw13-Jun-06 22:17 
QuestionCBitmapButton Pin
akshita_152-Jun-06 21:22
akshita_152-Jun-06 21:22 
AnswerRe: CBitmapButton [modified] Pin
_AnsHUMAN_ 2-Jun-06 23:46
_AnsHUMAN_ 2-Jun-06 23:46 
GeneralRe: CBitmapButton [modified] Pin
akshita_153-Jun-06 0:36
akshita_153-Jun-06 0:36 
GeneralRe: CBitmapButton [modified] Pin
_AnsHUMAN_ 3-Jun-06 1:04
_AnsHUMAN_ 3-Jun-06 1:04 
Questioninteresting question, number of 0s at the end of N! Pin
George_George2-Jun-06 21:16
George_George2-Jun-06 21:16 
AnswerRe: interesting question, number of 0s at the end of N! Pin
John R. Shaw3-Jun-06 4:15
John R. Shaw3-Jun-06 4:15 
GeneralRe: interesting question, number of 0s at the end of N! Pin
George_George4-Jun-06 16:31
George_George4-Jun-06 16:31 
GeneralRe: interesting question, number of 0s at the end of N! Pin
John R. Shaw13-Jun-06 22:29
John R. Shaw13-Jun-06 22:29 
GeneralRe: interesting question, number of 0s at the end of N! Pin
George_George13-Jun-06 22:37
George_George13-Jun-06 22:37 
GeneralRe: interesting question, number of 0s at the end of N! Pin
John R. Shaw13-Jun-06 23:51
John R. Shaw13-Jun-06 23:51 
GeneralRe: interesting question, number of 0s at the end of N! Pin
George_George14-Jun-06 2:35
George_George14-Jun-06 2:35 
GeneralRe: interesting question, number of 0s at the end of N! Pin
John R. Shaw14-Jun-06 2:59
John R. Shaw14-Jun-06 2:59 
GeneralRe: interesting question, number of 0s at the end of N! Pin
George_George14-Jun-06 3:42
George_George14-Jun-06 3:42 
AnswerRe: interesting question, number of 0s at the end of N! [modified] Pin
Stephen Hewitt4-Jun-06 14:06
Stephen Hewitt4-Jun-06 14:06 

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.