Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[WINDOWS] Subclassing + WM_DWMNCRENDERINGCHANGED = crash



  • Hi everybody,

    I have a graphic library which is initialized with a control handle to drow on this control :
    @graphLib->Initialize(myFrame->winId());@

    The library needs to get some window messages related to the handle. To get this, I subclass the WNDPROC like this :
    @WNDPROC oldproc = (WNDPROC)(GetWindowLongPtr(hwnd, GWLP_WNDPROC);
    SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)newproc);@

    In newproc, I just receive this events :
    WM_NCHITTEST
    WM_SETCURSOR
    WM_MOUSEFIRST

    I tried to subclass the parent like this :
    @WNDPROC oldproc = (WNDPROC)(GetWindowLongPtr(GetParent(hwnd), GWLP_WNDPROC);
    SetWindowLongPtr(GetParent(hwnd), GWLP_WNDPROC, (LONG_PTR)newproc);@
    And now I have events I need, like WN_PAINT (15). Is that normal ?

    Next, when the graphLib does not handle an message, I translate it to the oldproc. It works until the message WM_DWMNCRENDERINGCHANGED (0x31F) which makes my application crash. If I redirect the message to DefWinProc, it works, but I think it's not correct.

    What can I do ? Maybe I have to compile Qt with others options ?

    Thank you all,
    Kin



  • From what I see, you set the same new address window procedure for both control handle and it's parent. How do you know from what window is WM_PAINT called ? And in "newproc" commonly you must call CallWindowProc(oldproc, ...) and not DefWindowProc



  • Hi,
    I don't know what I've done, but it works without subclassing the parent :)
    Also, by calling oldproc(...) it crash but with CallWindowProc(oldproc, ...) it works :)
    So thank you very much :)
    Kin


  • Moderators

    Hmmm... how does this relate to Qt at all?



  • I really don't know, I'll try it in the other computer and I'll let you know


Log in to reply