Results 1 to 6 of 6

Thread: Is OnPaint just a MFC function?

  1. #1

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Is OnPaint just a MFC function?

    I have my window subclassed and was hoping that instead of completely overriding every message that I handle, it would carry out whatever is in the subclassed window as well, like C# does in the OnPaint event.

    In C# I have a choice whether to completely override it or not and when it is carried out using
    base.OnPaint(e);

    I hope you know what I mean. How would I do this?

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    <base class name>::OnPaint(bla);

    And yeah, OnPaint is not there in WinAPI, although no one prevents you from declaring one
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In the WinAPI, when you're subclassing, you receive the old WNDPROC pointer. You need to store it and in the subclassing WndProc, instead of calling DefWindowProc, call
    return CallWindowProc(pOldWndProc, hwnd, msg, wparam, lparam);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Yes I have done that in my sub classed window. The problem is that it does not call the messages that I handled, only the ones I didn't. In C# I can call the base class to do it's work and then paint over it. But that can slow. I guess that is not a good concept for C++.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It depends.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    You're right, I guess it depends upon how I implement everything. What I could do is make my own OnPaint function and pass the window message to it including a rectangle of the area I want erased or refreshed, draw that to a memory HDC, pass the memory HDC back and draw to that.

    Good thinking CornedBee.

Posting Permissions

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



Click Here to Expand Forum to Full Width