Results 1 to 20 of 29

Thread: native event of child window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,329
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: native event of child window

    If you reimplement CPeWindow:: event() do you see any events at all from the MFC window?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Mar 2014
    Location
    USA
    Posts
    85
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: native event of child window

    I put in the code
    Qt Code:
    1. bool CPeWindow::event(QEvent *ev)
    2. {
    3. int x = 1; // set break here to see if it enters the function, should catch ANY event
    4. return true;
    5. }
    To copy to clipboard, switch view to plain text mode 
    But it never enters the function no matter what I do
    Last edited by TonyInSoMD; 21st December 2016 at 19:28.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,329
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: native event of child window

    I see this in the ProEssentials MFC DLL documentation:

    PEcreate is similar to the Windows CreateWindow function. However, it always creates a child window and places this child into the provided parent. The PEcreate function returns the Windows handle for the newly created control and this handle must be used to set properties and eventually destroy the control. As with most child windows, the ProEssentials controls will communicate with its parent through WM_COMMAND notification messages.
    So it might be that the HWND you are getting is actually the parent window and not that of the control itself. The parent window could be eating all of the events.

    If I had the time I'd download the demo and see what I could do, but time is not something I have a lot of at the moment. One thing you may find when mixing MFC and Qt is lots of apparent memory leaks upon program exit when you watch your program in the debugger. These aren't real and apparently result from MFC and Qt DLLs and static objects being unloaded / freed in a different order from how they were loaded / created. It's a nuisance that makes it hard to find real memory leaks.

    And the "are you sure it's plugged in" question: You've correctly derived CPEWindow from QWindow, added the Q_OBJECT macro, etc., etc., right?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Mar 2014
    Location
    USA
    Posts
    85
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: native event of child window

    Before I forget to say it, thanks for everyone's time and help. The Q_OBJECT macro is in there, I'm not sure what else would need to be added other than the standard c++ stuff when sub-classing. In this particular case, the "provided parent" is the sub-classed QFrame I mentioned in the first post. The QFrame receives the WM_COMMAND messages which I get using nativeEvent. When the message->message is WM_COMMAND in the QFrame, the HIWORD(message->wParam) tells me what the communication is. They have one for keypress but not keyrelease. I'm trying to find a way to capture the keyrelease event so I can switch between vertical and horizontal scroll depending on whether the Alt key is depressed. When I asked the folks at ProEssentials if there was a way to do it, they said to add this to their sample code:

    Qt Code:
    1. DLL, C++,
    2.  
    3. In our VC demo, PEViews file
    4.  
    5. Header file
    6.  
    7. protected:
    8. //{{AFX_MSG(CPEView)
    9. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    10. afx_msg void OnSize(UINT nType, int cx, int cy);
    11. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    12.  
    13. // new func
    14. virtual BOOL PreTranslateMessage(MSG* pMsg);
    15.  
    16. CPP file
    17.  
    18. // new implementation
    19. BOOL CPEView::PreTranslateMessage(MSG* pMsg) {
    20. if ( pMsg->message == WM_KEYDOWN )
    21. {
    22. if (pMsg->wParam = VK_MENU)
    23. {
    24. PEnset(m_hPE, PEP_nMOUSEWHEELFUNCTION, PEMWF_VERT_SCROLL);
    25. }
    26. return TRUE;
    27. }
    28. else if (pMsg->message == WM_KEYUP )
    29. {
    30. if (pMsg->wParam = VK_MENU)
    31. {
    32. PEnset(m_hPE, PEP_nMOUSEWHEELFUNCTION, PEMWF_HORZ_SCROLL);
    33. }
    34. return TRUE;
    35. }
    36. else
    37. return CView::PreTranslateMessage(pMsg);
    To copy to clipboard, switch view to plain text mode 

    I have no idea how to translate this from MFC to Qt. I don't know jack about MFC. Maybe I should have said all this up front, if so my sincerest apologies. When I said I wasn't working in MFC, it was Qt, ProEssentials offered to customize the code for a measly $1000 USD. $1000 to add a keyrelease wparam to WM_COMMAND which in my opinion I can't believe doesn't already exist considering they have one for keypress. I'll get off my soap box now.

    edit after post
    I'm starting to think that the ProEssentials window is not a "Windows" window in that it doesn't generate events with MSG's. The only MSG's it generates are the self-made self-emitted WM_COMMAND MSG's. There aren't any Windows (or Qt) events to catch because they're not generated, only the ProEssentials events which ProEssentials generates. If so, I've been spinning my and your wheels all this time and you have my apologies. What do you think, does it sound like I might be right?
    Last edited by TonyInSoMD; 22nd December 2016 at 12:19.

Similar Threads

  1. Replies: 0
    Last Post: 9th August 2016, 16:37
  2. Native parent window for QWidget (IPreviewHandler)
    By Kevsoft in forum Qt Programming
    Replies: 3
    Last Post: 19th July 2015, 13:24
  3. Replies: 5
    Last Post: 17th September 2013, 06:45
  4. Replies: 11
    Last Post: 4th June 2008, 07:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.