• WM_NCPAINT - how to draw the/a border and caption ?

    From R.Wieser@21:1/5 to All on Tue Mar 23 19:23:04 2021
    Hello all,

    Using XPsp3.

    I've got a standard dialog and would like to make it appear flat. So, I intercepted the WM_NCPAINT event and in it got GetDCEx to return a valid DC
    (a problem in itself, as it needed a secret flag included (which is not mentioned by MSDN or elsewhere) ).

    But now I'm /again/ pretty much stuck.

    #1: I have tried to use DrawEdge using BS_FLAT, but that one leaves some undrawn space between it and the client area. So for now I'm calling 'Rectangle' using a hollow brush and a pen 8 units thick. Ugly, but for now
    it wil do. (I've got no idea how to get the actual width of the border, SPI_GETNONCLIENTMETRICS says its just one pixel wide)

    #2: The next problem is the captuion with its icon and buttons : DrawCaption refuses to show anything, even though it returns a 'Succes' (0x1) code.

    #3: Furthermore, even when I do not draw the caption, icon and the buttons (leaving a see-thru hole) they still do appear whenever I drag another
    window over that space ... Minimizing and than restoring my dialog than
    again shows a hole where the caption, icon and buttons should be.

    IOW, something seems to be working alongside WM_NCPAINT and do some work I
    did not ask for. Capturing WM_NCACTIVATE (sending it to the same NCPaint
    code) didn't change anything.


    I've been trying for about three days now to get it to work, but nonwithstanding having found a number of (partial) examples I have not been able to figure out what I should be doing here. MSDN isn't much of a help.

    tl;dr:
    has anyone ever overridden the WM_NCPAINT event to draw their own border and full caption and got it to work. I could use some hints.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Wed Mar 24 12:10:13 2021
    #2: The next problem is the captuion with its icon and buttons :
    DrawCaption refuses to show anything, even though it returns a 'Succes'
    (0x1) code.

    Problem found : the default of DrawCaption (when setting the flags to 0x0)
    is to draw ... absolutily nothing! Either the DC_TEXT and DC_ICON must be
    set to draw anything at all. Both must be set to draw a full caption.

    #2B: New problem: Under XPsp3 the DC_BUTTONS flag (to have it draw the
    close, minimize and maximize buttons) doesn't seem to work. :-(

    #2C: forgot to mention : I also can't (programmatically) find what the
    origin (and height) of the caption bar should be.

    There is something positive (of sorts) though : going thru all flags (to see
    if I could get the buttons to draw) I found one causing the caption text to
    be centered. The downside of that is that I'm now trying to figure out why its not documented anywhere ... :-\

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)