Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

persistent graphics 1

Status
Not open for further replies.

danielprovin

Programmer
May 7, 2002
7
BR
I am having problems trying to modify the persistent graphics of a window (the window already exist) using it hWnd
I can already paint on the window, but another window goes on top of this window, it erases the paint
 
What do you mean by the window already exists? I take it that you did not create the window that you are painting to? The problem resides in the fact that the window only knows how to re-paint it's controls, background color etc...it has no idea what you want to re-paint...be it a bitmap or just simple GDI output. To correctly restore the desired client area output you must handle the WM_PAINT message...of course this is assuming raw api programming...more info would help. Mike L.G.
mlg400@linuxmail.org
 
Yes, the window is a PictureBox object from VB, but I will create an activeX_dll that will modify that PictureBox.
I tried to handle the WM_PAINT message, re-painting the graphics, but it didn't work

that's what I use:

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
switch(uMessage)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hWnd,&ps);
if (bCopiaJanela) PintaCopiaJanela(ps.hdc);
SetBkMode(ps.hdc, TRANSPARENT);
SetTextColor(ps.hdc, RGB(255,0,0));
TextOut(ps.hdc, 100,100, "Press SPACE", 11);
EndPaint(hWnd,&ps);
break;
}
}
return DefWindowProc(hWnd,uMessage,wParam,lParam);
}
 
Try returning 0 after WM_PAINT executes...

LRESULT CALLBACK WndProc( HWND hWnd, UINT uMessage,WPARAM wParam,LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch( uMessage )
{
case WM_PAINT:

hdc=BeginPaint(hWnd,&ps);
if ( bCopiaJanela )PintaCopiaJanela( hdc );
SetBkMode( hdc,TRANSPARENT );
SetTextColor( hdc,RGB( 255,0,0 ) );
TextOut( hdc,100,100,"Press SPACE", 11);
EndPaint( hWnd,&ps );

return 0;
}
return DefWindowProc(hWnd,uMessage,wParam,lParam);
} Mike L.G.
mlg400@linuxmail.org
 
Sounds like you are having a similar problem to what I'm trying to solve. (See my post "Dialog Box: Bitmap gets erased when a screen is dragged over.")
I have my own application, but the problem exists for my dialog box, too.

LiquidBinary, thanks for the tip on the WM_PAINT message, I'll check that out.

DMF
 
This code have worked on THE application, but when I tried to implement a dll that gets the hwnd from a window of another application, it won't hook to process the WM_PAINT message
is there any way to make it goes thru the dll?
 
I found that on MFC applications, u can't use WndProc to handle the WM_PAINT messages, u need to use the AfxRegisterWndClass function, but the help didn't help me that much

so, anyone know something about handling window messages on a MFC dll?

thanks
Daniel
 
I had finally found a happy end to my problem
What I had to do was to subclass the existing window to a new function to handle the messages (like WM_PAINT) using
SetWindowLong with the hwnd, GWL_WNDPROC argument, and the name of the new function to handle messages, than it handle only the messages to that specific hwnd.

hope it helps other people
Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top