Capture control
-
I write a program to capture window controls. I used global mouse hook to catch mouse message. I want that when I move my mouse to a control, there's a rectangle around that control. I got the handle of the control, drew the rectangle but my problem is when I move to another control, the previous rectangle hasn't disappeared yet. I tried RedrawWindow() like this but there was no effect :
CDC *hScrDC;
hScrDC = CDC::FromHandle ( ::GetDCEx(NULL, NULL, 0));
//Tmp is the CDC * of the control
Tmp->RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
RECT rect;
Tmp->GetWindowRect(&rect);
int nX = rect.left;
int nY = rect.top;
int nX2 = rect.right;
int nY2 = rect.bottom;
hScrDC->Rectangle(nX, nY, nX2, nY2);Some one plz help me :rose:
-
I write a program to capture window controls. I used global mouse hook to catch mouse message. I want that when I move my mouse to a control, there's a rectangle around that control. I got the handle of the control, drew the rectangle but my problem is when I move to another control, the previous rectangle hasn't disappeared yet. I tried RedrawWindow() like this but there was no effect :
CDC *hScrDC;
hScrDC = CDC::FromHandle ( ::GetDCEx(NULL, NULL, 0));
//Tmp is the CDC * of the control
Tmp->RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
RECT rect;
Tmp->GetWindowRect(&rect);
int nX = rect.left;
int nY = rect.top;
int nX2 = rect.right;
int nY2 = rect.bottom;
hScrDC->Rectangle(nX, nY, nX2, nY2);Some one plz help me :rose:
-
I write a program to capture window controls. I used global mouse hook to catch mouse message. I want that when I move my mouse to a control, there's a rectangle around that control. I got the handle of the control, drew the rectangle but my problem is when I move to another control, the previous rectangle hasn't disappeared yet. I tried RedrawWindow() like this but there was no effect :
CDC *hScrDC;
hScrDC = CDC::FromHandle ( ::GetDCEx(NULL, NULL, 0));
//Tmp is the CDC * of the control
Tmp->RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
RECT rect;
Tmp->GetWindowRect(&rect);
int nX = rect.left;
int nY = rect.top;
int nX2 = rect.right;
int nY2 = rect.bottom;
hScrDC->Rectangle(nX, nY, nX2, nY2);Some one plz help me :rose:
capint wrote:
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
Try combining these two flags
RDW_ERASENOW, RDW_UPDATENOW
along with above ones.Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com
-
capint wrote:
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
Try combining these two flags
RDW_ERASENOW, RDW_UPDATENOW
along with above ones.Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com
-
capint wrote:
Thanks so much Nibu babu thomas, I got it
Welcome! :) FYI Reason for above behavior... From MSDN: The system sends this message when there are no other messages in the application's message queue. So we here just forced a paint by adding those flags! Another way to do this will be to first call Invalidate() and then call UpdateWindow() which is similar to what we did!
Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com