CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2000
    Location
    Romania, Cluj-Napoca
    Posts
    57

    OWNER DRAW BUTTON

    I'm trying to create an owner draw button using the subclassing. Below are the steps that I followed to achieve this task:

    1. Using the resource editor (my application is a dialog box),I added a button and I selected the owner draw style.

    2. I added a new class derived from CButton, called CMyButton.

    3. In the dialog box class (derived from CDialog), I added a member variabile m_Button of type CMyButton using the class wizard. A DDX_Control function was added.

    4. In the CMyButton class I override the DrawItem function where I should draw the button.

    BUT SURPRISE ! This function is never called, even if, in my opinion I did all the steps to subclass the button. The code from it is never called. In the debug version I get stucked into
    this sequence of code:


    // Derived class is responsible for implementing all of these handlers
    // for owner/self draw controls
    void CButton:rawItem(LPDRAWITEMSTRUCT)
    {
    ASSERT(FALSE);
    }


    , belonging to the WINCTRL1.CPP.
    Why's that ? I really don't have a clue.
    I WILL CERTAINLY GIVE POINTS FOR A USEFUL ANSWER.
    I even tried to change the code: I dropped the owner draw style of the button using the resource editor, and in the CMyButton::PreSubclassWindow handler I made the button owner draw using the ModifyStyle function. The result was the same, CMyButton:rawItem is never called.

    I'm using VISUAL C++ 5.0 under WIN 2000 PROFESSIONAL.
    10x in advance





  2. #2
    Join Date
    Jun 1999
    Posts
    1,786

    Re: OWNER DRAW BUTTON

    It seems to me you didn't overwrite DrawItem.
    From your post I see that you think you did. But I insist you didn't (at least the amount of info you've posted let me think this way)
    So, please show did you overwrite DrawItem in your class CMyButton.
    I need all info - header and implementation

    Good luck
    Please rate if you think this response was useful for you
    Have more questions? Feel free to ask.

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

Featured