upper drawing layer
-
If i draw some image, lines, rectangles etc. in OnPain() of dialog box then it takes some time. Suppose i draw image,rectangle on mouse click and release event. I can call repaint from mouse click/release function and it's working fine. But suppose if i want to draw some lines on mouse move function then i need to call repaint from mouse move function and it gives flickering problem. To solve this i plan to draw image, rectangle etc in a memory device context on mouse click/release functions. and for mouse move first i'll draw data from memory device context and then i'll draw line on top of it. But it's not working. Can someone give any example to solve that problem.
Manoj Kumar Chauhan
-
If i draw some image, lines, rectangles etc. in OnPain() of dialog box then it takes some time. Suppose i draw image,rectangle on mouse click and release event. I can call repaint from mouse click/release function and it's working fine. But suppose if i want to draw some lines on mouse move function then i need to call repaint from mouse move function and it gives flickering problem. To solve this i plan to draw image, rectangle etc in a memory device context on mouse click/release functions. and for mouse move first i'll draw data from memory device context and then i'll draw line on top of it. But it's not working. Can someone give any example to solve that problem.
Manoj Kumar Chauhan
-
Which device context you are using on window mouse message handler and are you using ::ReleaseCapture funtion after releasing mouse.If possible pls give me code to understand your problem.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
The code is simple. Just Create a dialog base application. Add a static control on dialog box. Make a class for this static control(derived from CStatic). Now draw in this class. In Onpaint() of this class draw some image,rectangle, lines etc. Add all mouse functions in this class. Call Invalidate() from mouse click/release functions. Upto now there is no problem. Now call Invalidate() from mouse move function. You'll see flickering. To solve it take an offscreen buffer. Create image/rectangle in offscreen buffer and draw it on view when Invalidate() is call from mouse click/release function. Otherwise form mouse move function, dont create offscreen buffer, just use previously created offscreen buffer and draw it on view. Then draw lines. I'm not using any capture function like ReleaseCapture(). When i dtied this then i can see only lines. I cant see any image/rectangle. What i want I want a 2 layers. bottom layer should contains image and rectangle and top layer contains only lines.
Manoj Kumar Chauhan
-
The code is simple. Just Create a dialog base application. Add a static control on dialog box. Make a class for this static control(derived from CStatic). Now draw in this class. In Onpaint() of this class draw some image,rectangle, lines etc. Add all mouse functions in this class. Call Invalidate() from mouse click/release functions. Upto now there is no problem. Now call Invalidate() from mouse move function. You'll see flickering. To solve it take an offscreen buffer. Create image/rectangle in offscreen buffer and draw it on view when Invalidate() is call from mouse click/release function. Otherwise form mouse move function, dont create offscreen buffer, just use previously created offscreen buffer and draw it on view. Then draw lines. I'm not using any capture function like ReleaseCapture(). When i dtied this then i can see only lines. I cant see any image/rectangle. What i want I want a 2 layers. bottom layer should contains image and rectangle and top layer contains only lines.
Manoj Kumar Chauhan
-
If i draw some image, lines, rectangles etc. in OnPain() of dialog box then it takes some time. Suppose i draw image,rectangle on mouse click and release event. I can call repaint from mouse click/release function and it's working fine. But suppose if i want to draw some lines on mouse move function then i need to call repaint from mouse move function and it gives flickering problem. To solve this i plan to draw image, rectangle etc in a memory device context on mouse click/release functions. and for mouse move first i'll draw data from memory device context and then i'll draw line on top of it. But it's not working. Can someone give any example to solve that problem.
Manoj Kumar Chauhan
1/ Are you sure you're just invalidating the CMyStatic control? If you're also invalidating the dialog box, then you'll get flickering. 2/ If your code is working, but not with the memory context, then have a look at Keith Rule's CMemDC article. I've used his CMemDC in many places, and it's great. Just do a search for his name. He didn't write many articles, but it's a golden one. Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
-
are you using CClientDC device context or CPaintDC on OnMouseMove function ? And when i see your code it is clear for me where is the problem?
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
I'm not using any device context in mousemove. From mouse move i'm calling Invalidate. And in Ontain, i'm using CDC to create memory device context. If your code is working fine then please send here if you can.Or please mail to my id gkv_manoj@yahoo.com
Manoj Kumar Chauhan
-
1/ Are you sure you're just invalidating the CMyStatic control? If you're also invalidating the dialog box, then you'll get flickering. 2/ If your code is working, but not with the memory context, then have a look at Keith Rule's CMemDC article. I've used his CMemDC in many places, and it's great. Just do a search for his name. He didn't write many articles, but it's a golden one. Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
-
If i draw some image, lines, rectangles etc. in OnPain() of dialog box then it takes some time. Suppose i draw image,rectangle on mouse click and release event. I can call repaint from mouse click/release function and it's working fine. But suppose if i want to draw some lines on mouse move function then i need to call repaint from mouse move function and it gives flickering problem. To solve this i plan to draw image, rectangle etc in a memory device context on mouse click/release functions. and for mouse move first i'll draw data from memory device context and then i'll draw line on top of it. But it's not working. Can someone give any example to solve that problem.
Manoj Kumar Chauhan
Yes you get a flickering problem coz when you call OnPaint() or Invalidate() you are redrawing the whole window. try this Create your function e.g MyDrawing(int x,int y) { CClientDC dc(this); dc.SetTextColor(RGB(0,0,255)); dc.TextOut(x,y,"my text"); } in you Mouse Move Handler { .... MyDrawing(point.x,point.y); } then play around with rectangles
-
Yes you get a flickering problem coz when you call OnPaint() or Invalidate() you are redrawing the whole window. try this Create your function e.g MyDrawing(int x,int y) { CClientDC dc(this); dc.SetTextColor(RGB(0,0,255)); dc.TextOut(x,y,"my text"); } in you Mouse Move Handler { .... MyDrawing(point.x,point.y); } then play around with rectangles