Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [WINDOWS] Subclassing + WM_DWMNCRENDERINGCHANGED = crash
QtWS25 Last Chance

[WINDOWS] Subclassing + WM_DWMNCRENDERINGCHANGED = crash

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kinju
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cincirin
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kinju
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kinju
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved