CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    34

    How to create this button

    I have standard Doc/View application with the view class derived from CScrollview. I have loaded a 256 color bitmap on the entire client area. I'd like to add a small CButton object on the client area ( on top of the bitmap). How can I achieve this without creating additional dialog box. Thank you very much for your help.



  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How to create this button

    Just call the API CreateWindow(), CreateWindowEx(), or MFC's CWnd::Create() with the class name as "BUTTON". Look in the Help for the various button styles.

    Regards,

    Paul McKenzie




  3. #3
    Join Date
    Apr 1999
    Posts
    21

    Re: How to create this button

    Hi, to create a Button, first create a CButton member variable in CYourView class.

    CButton m_button;

    and in CYourView::OnInitialUpdate add this

    void CYourView::OnInitialUpdate()
    {
    CScrollView::OnInitialUpdate();

    CRect rect(0,0,70,30); //size and position of your button
    m_button.Create("Test", BS_PUSHBUTTON, rect, this, 0);
    m_button.ShowWindow(SW_SHOW);
    }


    I used BS_PUSHBUTTON style, but you can use whatever you need, just take a look to "Button Styles" in the documentation.
    The font used to write "Test", is the current font selected in the device-context, so you can change it to whatever font you want.

    Fabian


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