0

I am creating a custom drawn Windows 10 style child frame class (derived from CMDIChildWndEx) for MDI applications. I've got everything drawing and working well (I have one residual drawing problem, but I'll ask that separately), however I can't figure out how to get a transparent, but clickable, region outside the drawn window border.

The problem is, Windows 10 style frames are only a single pixel wide, and this is really too narrow to be practical for sizing the frame. As such, what I am trying to do, is to have a 3 pixel wide transparent region outside the border which is part of the non-client area of the window, and thus clickable. The window region is set up properly, however the 3 pixel wide region is never redrawn by the main frame, so it gets parts of other child frames "stuck" and looks a horrible mess. I assume that Windows is assuming that my window is responsible for drawing everything within its declared region, and therefore won't redraw anything in that area.

If I make the window region only extend to the 1 pixel visible border, I don't get messages (i.e. OnNcLButtonDown, OnNcLButtonDblClk and OnNcMouseMovewhen the user moves the mouse outside that region, obviously.

I've tried invalidating the region I want the main frame to redraw (by calling InvalidateRect and RedrawWindow from my CMainFrame class), both just the region I want redrawn, and the whole child frame region, both without success. Forcing the main frame to redraw itself and all its child frames "works", but of course results in a horrible, slow, flickering mess, so that's not a practical solution.

I've not been able to find anything online that helps, and have tried just about everything I can think of, so I'd really appreciate any suggestions!

I'm happy to show code, but hopefully the above describes the problem sufficiently.

The screenshot below shows the effect, with the borders of each child frame having been corrupted by the other as it was dragged over.

Screenshot showing transparent border corruption

  • Unfortunately painting the border the same color as the background doesn't work in an MDI application, as it might be overlapping another child window. – Paul Harrison Jul 23 '18 at 21:32
  • 1
    Show some code and small screen shot to show what your goal is. I think drawing transparent borders in this way can be difficult. It's easier and probably more clear to the user if you just draw the border with solid color. – Barmak Shemirani Jul 23 '18 at 22:16
  • I've added a screenshot as requested. I'm still not sure what code it would make sense to post, the class implementation is over 1200 lines of code... You're right, this is certainly a difficult problem, hence why I'm asking for help. I do disagree on ease of use though, for the simple reason that this is exactly what Microsoft have done in Windows 10, so I think it is very clear for users, if anything clearer as it matches the OS's implementation. – Paul Harrison Aug 15 '18 at 15:41
  • You could make the border the same color as background. Then highlight it on mouse-over, or mouse-click. This would be similar to what you see in Visual Studio. – Barmak Shemirani Aug 15 '18 at 16:38
  • Right, but then when one child frame is over another, It will have a background coloured box around it. That would also only work if the main frame's background is a solid colour, which is, admittedly, often the case, but I have on several occasions included for example a logo on the background for various customers at their request. – Paul Harrison Aug 15 '18 at 17:53

0 Answers0