Click here to Skip to main content
15,897,704 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Win32/GDI+ - Using a transparent PNG image as window background Pin
Member 38216201-Apr-10 9:33
Member 38216201-Apr-10 9:33 
GeneralRe: Win32/GDI+ - Using a transparent PNG image as window background Pin
LunaticFringe1-Apr-10 11:13
LunaticFringe1-Apr-10 11:13 
GeneralRe: Win32/GDI+ - Using a transparent PNG image as window background Pin
Member 38216201-Apr-10 13:06
Member 38216201-Apr-10 13:06 
GeneralRe: Win32/GDI+ - Using a transparent PNG image as window background Pin
LunaticFringe1-Apr-10 13:23
LunaticFringe1-Apr-10 13:23 
GeneralRe: Win32/GDI+ - Using a transparent PNG image as window background Pin
Code-o-mat1-Apr-10 21:35
Code-o-mat1-Apr-10 21:35 
QuestionA joke on C Pin
Edward10261-Apr-10 7:57
Edward10261-Apr-10 7:57 
AnswerRe: A joke on C Pin
CPallini1-Apr-10 8:10
mveCPallini1-Apr-10 8:10 
QuestionHow to do function with timout & getting message properly ? Pin
oppstp1-Apr-10 7:42
oppstp1-Apr-10 7:42 
Hi,

I want to write a small mfc dialog based program to test the functionality which the third-party library provides.
The flow of test program is simple. I made some buttons on the program.
When I pressed button A, then execute the action A. Pressed button B, then execute the action B...etc.
According to the library document, each action usually contains 3~5 steps.
Each step must call some functions which are provided by the library.
The document said some functions will use PostThreadMessage() to send some specific library-defined message within a specific time.
If the program doesn't receive library-defined message within a specific time, regard it as timeout.
And the frequency of this type function is often, not a little.

But now I don't know how to do this timeout functionality properly.
For now, I used a for loop and difftime() to check the time period repeatedly and didn't create any new thread in my program.
In the for loop, I use GetMessage(&MSG, 0, 0, 0) to receive the message which library function sent.
Although the library function can't work (because the library relies on a specific machine, and the machine doesn't connect to my pc),
I think that it's enough to test the timeout functionality.

But the test result seemed that it didn't work correctly. I use a MessageBox() which is outside the for loop.
And the message box always was showed later than the time I set.
Another problem is if I pressed the button to start the timeout functionality then press the OK or CANCEL button earlier than the timeout
message box, the program will disappear but still resides in the task manager...
(Even if I add OnDestroy() to call DestroyWindow(), the result is same)

So I thought the method which I use now is correct or not. But even it is the incorrect method, I don't know what the proper method is...
So does anyone can give me some suggestions, helpful references, related samples or why my program failed ?

Thank you very much.
QuestionRe: How to do function with timout & getting message properly ? Pin
David Crow1-Apr-10 8:15
David Crow1-Apr-10 8:15 
AnswerRe: How to do function with timout & getting message properly ? Pin
oppstp1-Apr-10 15:06
oppstp1-Apr-10 15:06 
QuestionPicture Control with scroll bars. PinPopular
ashwath19791-Apr-10 5:02
ashwath19791-Apr-10 5:02 
QuestionC++ Thousand Separators Pin
awesometrickycool1-Apr-10 2:37
awesometrickycool1-Apr-10 2:37 
AnswerRe: C++ Thousand Separators Pin
Garth J Lancaster1-Apr-10 2:56
professionalGarth J Lancaster1-Apr-10 2:56 
QuestionRe: C++ Thousand Separators Pin
David Crow1-Apr-10 3:03
David Crow1-Apr-10 3:03 
AnswerRe: C++ Thousand Separators Pin
Garth J Lancaster1-Apr-10 3:06
professionalGarth J Lancaster1-Apr-10 3:06 
AnswerRe: C++ Thousand Separators Pin
Joe Woodbury1-Apr-10 7:15
professionalJoe Woodbury1-Apr-10 7:15 
GeneralRe: C++ Thousand Separators Pin
awesometrickycool1-Apr-10 15:08
awesometrickycool1-Apr-10 15:08 
QuestionRe: C++ Thousand Separators Pin
David Crow1-Apr-10 15:33
David Crow1-Apr-10 15:33 
AnswerRe: C++ Thousand Separators Pin
awesometrickycool1-Apr-10 15:49
awesometrickycool1-Apr-10 15:49 
GeneralRe: C++ Thousand Separators Pin
David Crow1-Apr-10 16:26
David Crow1-Apr-10 16:26 
GeneralRe: C++ Thousand Separators Pin
Joe Woodbury1-Apr-10 16:02
professionalJoe Woodbury1-Apr-10 16:02 
GeneralRe: C++ Thousand Separators Pin
awesometrickycool1-Apr-10 16:17
awesometrickycool1-Apr-10 16:17 
GeneralRe: C++ Thousand Separators Pin
David Crow1-Apr-10 16:29
David Crow1-Apr-10 16:29 
GeneralRe: C++ Thousand Separators Pin
Joe Woodbury1-Apr-10 17:05
professionalJoe Woodbury1-Apr-10 17:05 
GeneralRe: C++ Thousand Separators Pin
awesometrickycool3-Apr-10 12:48
awesometrickycool3-Apr-10 12:48 

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.