Click here to Skip to main content
15,917,641 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralVirtual CListView page scrolling Pin
ldaoust22-Dec-03 15:57
ldaoust22-Dec-03 15:57 
QuestionPlease help! the way using SetBitmap, no memory leak? Pin
twing22-Dec-03 15:26
twing22-Dec-03 15:26 
AnswerRe: Please help! the way using SetBitmap, no memory leak? Pin
Monty222-Dec-03 18:05
Monty222-Dec-03 18:05 
GeneralRe: absolutely in OnDestroy? No other way? Pin
twing22-Dec-03 19:16
twing22-Dec-03 19:16 
GeneralRe: absolutely in OnDestroy? No other way? Pin
Monty222-Dec-03 19:36
Monty222-Dec-03 19:36 
GeneralRe: because i use it in some threads! Pin
twing22-Dec-03 19:44
twing22-Dec-03 19:44 
GeneralRe: Please help! Smart points could solve my problem??? Pin
twing22-Dec-03 19:34
twing22-Dec-03 19:34 
QuestionBuggy window behavior? Pin
Jerry Hammond22-Dec-03 14:04
Jerry Hammond22-Dec-03 14:04 
Using one of the teach-yourself-you-dummie books I entered the following code to creat a window. It compiles just fine, without error or warning. But once I execute it my CPU usage pegs at 100%, the small Icon does not render, and clicking the close button fails to close the window.

//Standard wondows include<br />
#include <windows.h><br />
<br />
//Message Loop CallBack Function Prototype<br />
LRESULT CALLBACK fnMessageProcessor (HWND, UINT, WPARAM, LPARAM);<br />
<br />
//Function called automatically when the program starts<br />
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,<br />
					int iCmdShow)<br />
<br />
{<br />
	HWND hWnd;<br />
	MSG  msg;<br />
	WNDCLASSEX wndclass;<br />
<br />
	//Set up window class<br />
	wndclass.cbSize    =sizeof(WNDCLASSEX);<br />
	wndclass.style     =CS_HREDRAW | CS_VREDRAW;<br />
	wndclass.lpfnWndProc =fnMessageProcessor;<br />
	wndclass.cbClsExtra =0;<br />
	wndclass.cbWndExtra =0;<br />
	wndclass.hInstance  =hInstance;<br />
	wndclass.hIcon      =LoadIcon(NULL, IDI_APPLICATION);<br />
	wndclass.hCursor    =LoadCursor(NULL, IDC_ARROW);<br />
	wndclass.hbrBackground=(HBRUSH) GetStockObject (GRAY_BRUSH);<br />
	wndclass.lpszMenuName=NULL;<br />
	wndclass.lpszClassName="Window Class";<br />
<br />
	//Class Name<br />
	wndclass.hIconSm     =LoadIcon(NULL,IDI_APPLICATION);<br />
<br />
	//Register the window class<br />
	if(RegisterClassEx(&wndclass)==0)<br />
	{<br />
		//the program failed, exit<br />
		exit(1);<br />
	}<br />
<br />
	//Create the window<br />
	hWnd=CreateWindowEx(<br />
		WS_EX_OVERLAPPEDWINDOW,<br />
		"Window Class",  //Class Name<br />
		"Create Window Example", //Title bar text<br />
		WS_OVERLAPPEDWINDOW,<br />
		0,<br />
		0,<br />
		400,<br />
		600,<br />
		NULL,<br />
		NULL,<br />
		hInstance,<br />
		NULL);<br />
<br />
	//Display Window<br />
	ShowWindow(hWnd, iCmdShow);<br />
<br />
	//Process Messages until program is terminated<br />
	while(GetMessage (&msg,NULL,0,0));<br />
	{<br />
		TranslateMessage(&msg);<br />
		DispatchMessage(&msg);<br />
	}<br />
<br />
	return (msg.wParam);<br />
<br />
}<br />
<br />
//Message loop callBack function (Required for all windows programs)<br />
LRESULT CALLBACK fnMessageProcessor(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
	switch(iMsg)<br />
	{<br />
		//Called when window is first created<br />
	case WM_CREATE:<br />
		return(0);<br />
		//Called when window is refreshed<br />
	case WM_PAINT:<br />
		return(0);<br />
		//Called when the user closes the window<br />
	case WM_DESTROY:<br />
		PostQuitMessage(0);<br />
		return(0);<br />
	default:<br />
		return DefWindowProc(hWnd, iMsg, wParam, lParam);<br />
	}<br />
}<br />


Do any of you have any observations about the code and or any suggestion to overcome this buggy behavior?

Thanks all.

Best,
Jerry

The only way of discovering the limits of the possible is to venture a little past them into the impossible.--Arthur C. Clark
Toasty0.com
AnswerRe: Buggy window behavior? Pin
alex.barylski22-Dec-03 16:25
alex.barylski22-Dec-03 16:25 
AnswerRe: Buggy window behavior? Pin
Chris Richardson22-Dec-03 18:07
Chris Richardson22-Dec-03 18:07 
AnswerRe: Buggy window behavior? Pin
Monty222-Dec-03 18:09
Monty222-Dec-03 18:09 
AnswerRe: Buggy window behavior? Pin
Jerry Hammond23-Dec-03 7:48
Jerry Hammond23-Dec-03 7:48 
AnswerRe: Buggy window behavior? Pin
nema3223-Dec-03 8:08
nema3223-Dec-03 8:08 
QuestionHow to detect logoff and lock event from atl COM Service Pin
Chak22-Dec-03 12:30
Chak22-Dec-03 12:30 
AnswerRe: How to detect logoff and lock event from atl COM Service Pin
Robert Kuster22-Dec-03 13:28
Robert Kuster22-Dec-03 13:28 
GeneralCSocket stops receiving data Pin
Daniel 'Tak' M.22-Dec-03 12:05
Daniel 'Tak' M.22-Dec-03 12:05 
Generalemulating console mode in a window Pin
Ray Gregory22-Dec-03 11:50
Ray Gregory22-Dec-03 11:50 
GeneralRe: emulating console mode in a window Pin
Tim Smith22-Dec-03 12:16
Tim Smith22-Dec-03 12:16 
GeneralRe: emulating console mode in a window Pin
Jörgen Sigvardsson22-Dec-03 13:12
Jörgen Sigvardsson22-Dec-03 13:12 
Generalc++ dll: window not created properly Pin
Extremor22-Dec-03 11:25
Extremor22-Dec-03 11:25 
GeneralRe: c++ dll: window not created properly Pin
Selvam R23-Dec-03 9:43
professionalSelvam R23-Dec-03 9:43 
GeneralBuild Comment Web Pages And C++ Pin
nde_plume22-Dec-03 11:09
nde_plume22-Dec-03 11:09 
GeneralSet Tab Focus Pin
Anthony988722-Dec-03 10:17
Anthony988722-Dec-03 10:17 
GeneralRe: Set Tab Focus Pin
David Crow22-Dec-03 11:09
David Crow22-Dec-03 11:09 
GeneralRe: Set Tab Focus Pin
ldaoust22-Dec-03 16:03
ldaoust22-Dec-03 16:03 

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.