0

Let's say you want to add a little extra graphical info to a Windows control. For example, you want to add drag/drop functionality to a listview (using the procedure discussed here), but with horizontal lines signaling the drop/insertion points as the user drags an item. (The control belongs to your own application.)

Is there a safe way to subclass the control and draw onto it directly? In my limited experimentation in trying to do this, I encountered some problems. First, it wasn't clear whether I should call BeginPaint and EndPaint during the WM_PAINT message, since the control itself would be calling those functions once the message was passed along to the default procedure. I also inevitably encountered flickering, since some areas were being painted twice.

I thought a safer way would be just to create a transparent overlay window and draw on that, since that would avoid conflicts with the default paint procedure, but I thought I'd ask before going down that road. Thanks for any advice.

  • 2
    Results you will get would probably be highly control dependant, your code and windows styles that are used. An advantage of an overlay windows is that you can draw outside of you could which is probably what you want as clipping to your control boundary might be weird when user move the mouse near the boundaryof the control. Anytime someone program to the API level (and even with relatively low level framework like MFC), one must be aware of a lot of details as soon as doing something a bit unusual.. – Phil1970 Jan 23 '21 at 02:39
  • What do you need to do in `WM_PAINT`? Do you try adding `WS_EX_COMPOSITED` style which paints all descendants of a window in bottom-to-top painting order using double-buffering. – Strive Sun Jan 25 '21 at 03:35
  • I just need to draw a horizontal insertion marker. I'll try out WS_EX_COMPOSITED. Thanks. –  Jan 28 '21 at 16:32
  • Hi, have your problem been solved? – Strive Sun Feb 01 '21 at 08:42
  • Yes, I think so. Thank you very much. –  Feb 03 '21 at 07:53

0 Answers0