How to arrange work Between WndProc & New Thread
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: How to arrange work Between WndProc & New Thread

  1. #1
    Join Date
    Jun 2012
    Location
    UAE
    Posts
    59

    How to arrange work Between WndProc & New Thread

    Hi My Best Friends,

    I have very simple question :

    Given :
    - To Build a Window and add bottuns on this window , Say Window 1

    - From This Window ,Build Child Window Say Window 2

    Required :
    To use window 1 to add all Buttons on the Graphical User Interface
    To Use Window 2 (Child window ) : to add OpenGL Device

    Problem 1 :

    when I move the Window 1 , or I resize window 1 I lost all the graphics from OpenGL , Because WndProc send a Paint message and redraw on window 2

    Solution 1 :
    I understand that , I can create a new thread , and Let the OpenGL Device working under New thread...

    Problem 2 :
    Still I do not know how can I Prevent sending message from New thread to WndProc ... I need to prevent any message go from wndProc to Window 2 (OpenGL Window)..

    I am looking forwared to receive a well good explanation from my best collegue
    Mr. Igor Vartinove and Mr. VictorN.. and form my other best collegues..

    My Kind Regards

  2. #2
    Join Date
    Jun 2012
    Location
    UAE
    Posts
    59

    Re: How to arrange work Between WndProc & New Thread

    Any Updates ..

  3. #3
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,012

    Re: How to arrange work Between WndProc & New Thread

    Quote Originally Posted by mecheil.edwar View Post
    Problem 1 :

    when I move the Window 1 , or I resize window 1 I lost all the graphics from OpenGL , Because WndProc send a Paint message and redraw on window 2

    ...

    Still I do not know how can I Prevent sending message from New thread to WndProc ... I need to prevent any message go from wndProc to Window 2 (OpenGL Window)..
    Instead of trying to prevent the message loop from sending messages to your window, you should just repaint it when it gets the WM_PAINT message.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  4. #4
    Join Date
    Jun 2012
    Location
    UAE
    Posts
    59

    Re: How to arrange work Between WndProc & New Thread

    Quote Originally Posted by D_Drmmr View Post
    Instead of trying to prevent the message loop from sending messages to your window, you should just repaint it when it gets the WM_PAINT message.
    Thanks D_Drmmr for your reply..
    But the Problem if I let GDI paint the window , I will lose the the Painting object from OpeGL Device...

    So I need to stop painting from GDI on the child Window (Window 2) .. to give a chance to see what is painted by OpenGL device

  5. #5
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,012

    Re: How to arrange work Between WndProc & New Thread

    Quote Originally Posted by mecheil.edwar View Post
    So I need to stop painting from GDI on the child Window (Window 2) .. to give a chance to see what is painted by OpenGL device
    I don't understand. GDI does not paint anything unless you tell it to.
    Please show your code to handle WM_PAINT for the parent and child window.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,782

    Re: How to arrange work Between WndProc & New Thread

    Quote Originally Posted by D_Drmmr View Post
    I don't understand. GDI does not paint anything unless you tell it to.
    emmm this isn't right. because it will.

    it's the other way around.

    GDI will come ask you (or your program rather) via a WM_PAINT if any portion of the program needs repainting.

    this can happen as a result of your own program explicitely telling GDI that a portion of the window is no longer up to date (InvalidateRect)
    or if some other window was on top of your program obscuring part of your program's window and that other program has now been moved/minimized/closed so that some part of that previously obscured part is now visible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center