Click here to Skip to main content
16,011,757 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAsp and thumbnail Pin
26-Dec-00 2:37
suss26-Dec-00 2:37 
GeneralBjarne Stroustrup's Puzzle Pin
Amit Kulkarni25-Dec-00 21:54
Amit Kulkarni25-Dec-00 21:54 
GeneralRe: Bjarne Stroustrup's Puzzle Pin
Tim Deveaux26-Dec-00 5:00
Tim Deveaux26-Dec-00 5:00 
GeneralRe: Bjarne Stroustrup's Puzzle Pin
Erik Funkenbusch26-Dec-00 8:09
Erik Funkenbusch26-Dec-00 8:09 
GeneralRe: Bjarne Stroustrup's Puzzle Pin
Michael Dunn26-Dec-00 21:23
sitebuilderMichael Dunn26-Dec-00 21:23 
GeneralRe: Bjarne Stroustrup's Puzzle Pin
Masoud Samimi27-Dec-00 1:09
Masoud Samimi27-Dec-00 1:09 
GeneralRe: Bjarne Stroustrup's Puzzle Pin
Erik Funkenbusch27-Dec-00 8:47
Erik Funkenbusch27-Dec-00 8:47 
Generalbig problem! Pin
Satervalley25-Dec-00 20:10
Satervalley25-Dec-00 20:10 
Hi,everyone!
I have a big problem:my program can not exit completed.
below is the structure of my program:

WinMain(...)
{
Init(...);
RegisterClass(...);
CreateAndShowMainWindow(...);

// Main message loop
while(::GetMessage(...))
{
::TranslateMessage(...);
::DispatchMessage(...);
}
return msg.wParam;
}


CALLBACK MainWindowProc(...)
{
switch(message)
{
case WM_PAINT:
...;
break;
case WM_COMMAND:
...
break;
case ...:
...;
break;
case WM_LBUTTONUP:
::DialogBoxParam(...);
break;
case WM_DESTROY:
::PostQuitMessage(0);
break;
default:
::DefWndProc(...)
break;
}
return 0;
}


It's looks ok,Is not it?
but:
if I click the left mouse button,and the dialog box appeared,
and I press ESC(or ENTER),the dialog box disappeared and the
main window disappeared also,the program has completed,I do not
know why.
so I changed my code,the main message loop like blow:

// Main Message loop
BOOL bRet=FALSE;
for(;;)
{
for(;;)
{
if(!::GetMessage(&msg,NULL,0,0))
bRet=TRUE;
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
if(bRet)
return msg.wParam;
}

It works fine,the dialog box disappeared and the main window not
disappeared,but when I press Alt+F4 close the main window,I can
find the process in task manager,and I must press the "End Process"
button to end the process,It is said,my program can not exit completely.
I'm very puzzled!
Thanks for any suggestion.Big Grin | :-D
GeneralRe: big problem! Pin
l a u r e n25-Dec-00 22:08
l a u r e n25-Dec-00 22:08 
GeneralRe: big problem! Pin
Satervalley26-Dec-00 14:26
Satervalley26-Dec-00 14:26 
Questionenhance the Scribble activex control to support multiple documents? Pin
Rajesh Honnawarkar25-Dec-00 18:30
Rajesh Honnawarkar25-Dec-00 18:30 
GeneralEN_CHANGE leads endless loop Pin
Suha Aktan25-Dec-00 6:37
Suha Aktan25-Dec-00 6:37 
GeneralRe: EN_CHANGE leads endless loop Pin
l a u r e n25-Dec-00 21:56
l a u r e n25-Dec-00 21:56 
GeneralRe: EN_CHANGE leads endless loop Pin
Suha Aktan28-Dec-00 4:09
Suha Aktan28-Dec-00 4:09 
Questiondisplay numbers in a list boxt? Pin
24-Dec-00 23:41
suss24-Dec-00 23:41 
AnswerRe: display numbers in a list boxt? Pin
Michael Dunn25-Dec-00 15:00
sitebuilderMichael Dunn25-Dec-00 15:00 
QuestionHow much memory a specific program is using? Pin
24-Dec-00 20:37
suss24-Dec-00 20:37 
AnswerRe: How much memory a specific program is using? Pin
l a u r e n27-Dec-00 4:38
l a u r e n27-Dec-00 4:38 
GeneralManage Controlls On Rebar Pin
24-Dec-00 18:06
suss24-Dec-00 18:06 
Generaltoo many dialogs to manage... Pin
MengYan24-Dec-00 16:51
MengYan24-Dec-00 16:51 
GeneralRe: too many dialogs to manage... Pin
Masoud Samimi25-Dec-00 2:26
Masoud Samimi25-Dec-00 2:26 
GeneralRe: too many dialogs to manage... Pin
MengYan26-Dec-00 21:14
MengYan26-Dec-00 21:14 
GeneralRe: too many dialogs to manage... Pin
l a u r e n25-Dec-00 22:03
l a u r e n25-Dec-00 22:03 
GeneralMonitoring memory usage system-wide Pin
24-Dec-00 13:38
suss24-Dec-00 13:38 
GeneralCView Drop Targets Pin
Greg Hedlund24-Dec-00 4:37
Greg Hedlund24-Dec-00 4:37 

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.