|
|
|
You may wish to use exit()[^].
The best things in life are not things.
|
|
|
|
|
why not just wait for the thread to quit ?
if (needToQuit)
{
PostQuitMessage
WaitForSingleObject(threadHandle)
quit the main app
}
|
|
|
|
|
If you need to quit the application, use Richard's advice, if you need to quit a thread, use TerminateThread (a couple of people suggested) but be aware that doing that creates memory leaks as the threads working memory is not properly deallocated... so you shouldn't do the operation very often and only when its absolutely necessary, in most cases, you can creatively code a solution that allows a thread to properly shutdown... for example if the thread is processing some data, then you can have a control variable that'll stop the processing (within the thread) until WM_QUIT message is processed.
|
|
|
|
|
posted on my blog with due reference of your name!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
No prob
|
|
|
|
|
The program running in xp is no problem ,bu in Win7 ,it doesn't use the CreateRemoteThread to inject a dll to other process.
if I use the administrator to run,is also failed !
It's there any where to do this in Win7/Vista ?
I found this note: http://www.codeproject.com/Messages/3625827/It-dont-work-on-64bit-win7-system.aspx[^]
but I can't open the url, because the country's gateway shield it.
Thanks for your reply !
Best Regards !
|
|
|
|
|
I always used SetWindowsHookEx to inject dlls into other processes.
Dr D Evans "The whole idea that carbon dioxide is the main cause of the recent global warming is based on a guess that was proved false by empirical evidence during the 1990s" financialpost
|
|
|
|
|
Thanks !
|
|
|
|
|
Hi, this is the code:
case WM_MOUSEMOVE:
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
InvalidateRect(hWnd,NULL,TRUE);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
memDC = CreateCompatibleDC(hdc);
SelectObject(memDC,hbmp);
GetObject(bmp, sizeof(bm), &bm);
GetClientRect(hWnd,&rcc);
StretchBlt(hdc,
0,0, rcc.right,rcc.bottom,
memDC,
0,0,bm.bmWidth, bm.bmHeight,
SRCCOPY);
MoveToEx(hdc, pt.x , 0 , NULL);
LineTo(hdc, pt.x, rcc.bottom);
MoveToEx(hdc, 0, pt.y, NULL);
LineTo(hdc, rcc.right, pt.y);
how can i draw lines on mouse move without repainting the background bitmap? There's a way to "fix" the bitmap on background and repaint only lines?
|
|
|
|
|
InvalidateRect(hWnd,NULL,TRUE);
The third parameter tells the system whether to erase the background on the next call to BeginPaint() ; change it to FALSE to prevent the erase. You can also trap the WM_ERASEBKGND message and provide your own code to redraw the background however you like.
The best things in life are not things.
|
|
|
|
|
thanks works, but why when i resize or maximize the window it doesn't work very well?
|
|
|
|
|
Member 2965471 wrote: ...it doesn't work very well?
Is that supposed to be helpful?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
sorry...well when i increase the size of the window, the two lines partially disappear under the bitmap, while when i maximize the window the two lines do not appear and even the background image is distorted, may you help me please?
|
|
|
|
|
I think you should be drawing the bitmap on the temporary DC, then drawing the lines on top of that, and then BitBlt'ing the temporary DC onto the screen DC.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
i've tried, when i maximize the window bitmap disappear and when i restoring the window the bitmap reappears, it seems that the coordinates are different when the window is maximize, it may be true?
|
|
|
|
|
Member 2965471 wrote: it seems that the coordinates are different when the window is maximize, it may be true?
That depends on if you are using screen or client coordinates. With the former, the coordinates will always change. With the latter, top and left will always be 0.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Where are you calling InvalidateRect from? Don't do it in your WM_PAINT handler!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
no no of course, i call it from WM_MOUSEMOVE.
|
|
|
|
|
You're joking, right?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i don't understand, why? i post my code in the first msg...
|
|
|
|
|
Well it's not as bad as the recursion you'd get from calling it in response to WM_PAINT, but it certainly doesn't need to be called on every WM_MOUSEMOVE message.
Maybe call it from WM_SIZE handling code instead...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I need to call it on mouse move because i need to draw two lines converging at the mouse cursor position.
|
|
|
|
|
Ok then I would double-buffer as mentioned by DavidCrow and use Invalidate();UpdateWindow() combination.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|