|
|
|
maybe it is some helpful to you here[^]
|
|
|
|
|
If I create a thread with code like this:
while ( true ) {
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
switch ( msg.message ) {
case WM_QUIT : {
return;
}
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Does this automatically create a hidden window (I'd prefer not to have this)? Are there any downsides to doing this? Somewhere I recall reading that this could potentially be problematic.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
No it doesn't automatically create a window. The first call to PeekMessage()/GetMessage() would automatically create a message queue for the worker thread though.
In your code, you would be polling PeekMessage() in a tight loop if there is no message available on the queue. Why not use GetMessage() instead? It blocks until a message is posted on the queue.
|
|
|
|
|
In general, I would do that, however the actual code is a bit more complex than I posted. It possible for it to run for a brief time, for example run the message loop for 5 minutes. So for that I don't think I can use GetMessage. I put a Sleep(1) in the current code, though I'm not sure that's the right thing to do.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
I don't think calling Sleep(1) in your loop would solve the issue.
If you need the message loop to run say for 5 minutes, can't you create a timer using SetTimer() that would post WM_TIMER to your message queue and handle that message as the condition to get out of the loop?
|
|
|
|
|
hfry wrote: can't you create a timer using SetTimer() that would post WM_TIMER to your message queue and handle that message as the condition to get out of the loop?
Doh!!! You're exactly right! I'll adjust accordingly! Thanks so much for mentioning that - I feel like an idiot for missing something so obvious.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Please note that you will have to use callbacks with the timer, as you don't have a window.
|
|
|
|
|
Polling with PeekMessage is antisocial behaviour for an application. In a multitasking OS busy waits should be avoided like the plague.
Steve
|
|
|
|
|
If it helps, you can use MsgWaitForMultipleObjects() to put a timeout on waiting for messages.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
Please!!! I'm tryng to get the amount of memory allocated by a process. I have the HANDLE of process, and actually a discovered a function wich returns information about pages "GetProcessMemoryInfo" defined in "psapi.h", but I don't know how to get the amount of memory (in Kb) allocated for this process. How can I get this information????
Thanks!
|
|
|
|
|
you can use GetProcessMemoryInfo to get amount of memory (in Kb) allocated for process as following :
<br />
PROCESS_MEMORY_COUNTERS pmc;<br />
if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) )<br />
{<br />
CString s3;<br />
s3.Format( "amount of memory (in Kb) allocated for process: %ld\n", pmc.WorkingSetSize/1024 );<br />
}<br />
Use the WorkingSetSize member of the PROCESS_MEMORY_COUNTERS structure to get
amount of memory (in Kb) allocated for process.
Osama E. Adly
|
|
|
|
|
How do you convert a ULARGE_INTEGER in to a string and back?
No MFC Pleas.
Thanks in advance
G_S
|
|
|
|
|
1) sprintf(str, "%I64d", num);
2) _atoi64(str);
Maxwell Chen
|
|
|
|
|
Hallo
I try to implement: double clicking a file opens mainframe an childframe. Openeing the mainframe seems to work but what do i have to do that also the childframe opens ??
THX
|
|
|
|
|
This one has always bugged me... I tried looking in VC++'s help to find the answer, but no luck.
When I am typing a function header, and "intellisense" is completing a function signature for me, is there anyway to tell it to actually type it out for me? It's displaying everything for me, but I still have to type it all out! Is there some kind of keystroke that will do that?
(I'm asking now, because I'm putting intellisense-like behaviour into an app I'm writing, and I want to mimick VC++'s as much as possible).
|
|
|
|
|
[Key Down] (to select one) and [Enter].
Maxwell Chen
|
|
|
|
|
Umm, No. Keydown lets me scroll through the different overloads, but enter just puts a newline in the editor.
I'm talking about the function signatures, not the function names (where keydown + enter does work).
Anyone?
|
|
|
|
|
But I am using Visual C++ 2003 this way, and it works just fine for me ...
Maxwell Chen
|
|
|
|
|
I'm also using VC++ 2003, and it doesn't work.
I don't think I'm being clear enough in my question.
For object members, etc... I get a white dropdown with scrollbars, from which I can select a word to complete. That works fine...
However, for function parameters when I'm declaring or defining a function (when I type '(' after the function name), I get a yellow tooltip that tells me the parameters and their types. Enter doesn't do anything here.
|
|
|
|
|
OK. There are (at least) three kinds:
1) Intellisense:
This one is --- When you are typing, and you hit the [Complete word], then it pops up a dropdown list control.
In VC++ 6, you may press [Enter] to select the 1st match.
In VC++ 2003, it does not select any item by default. Thus [Enter] gives you newline. When you [Keydown], it selects an item. Then press [Enter] completes that word.
2) Parameter information:
When you type '(' right after a function token, it pops up for the prototype(s) of the function. When there are more than one, you have to click the tiny arrow buttons. There is no hot key for that.
3) Quick type information:
When mouse hovers on some token, it prompts you the type.
Maxwell Chen
|
|
|
|
|
Unfortunately Intellisense doesn't support this, at least in VS2003. I don't know about VS2005; maybe they fixed it (one can hope).
Software Zen: delete this;
|
|
|
|
|
Does anybody have sample code in C++ to change the gamma ramp. I want to set the colours, contrast and brightness of an LCD panel.
Similar with: http://www.majorgeeks.com/Gamma_Panel_d2796.html
Regards.
|
|
|
|