Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:32:33+00:00 2026-06-11T00:32:33+00:00

My mfc program draws the following shape in the client area- now i want

  • 0

My mfc program draws the following shape in the client area- now i want to place a button next to this for rearrangement of the shape.

enter image description here

I know i can use a toolbar or a menu button, but is there a way i can place a button right next to the box? something like this:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:32:35+00:00Added an answer on June 11, 2026 at 12:32 am

    All you need to do is create a CButton, and position it appropriately.

    //.h
    #define MYBUTTONID 10000 //or whatever doesn't conflict with your existing resources
    
    public class CMyVew : public CView
    {
        CButton m_Button;
    
        virtual void OnInitialUpdate();
        void RepositionButton();
    }
    
    //.cpp
    void CMyVew::OnInitialUpdate()
    {
       //this creates the actual button GUI window
       m_Button.Create("Rearrange", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0,0,0,0), this, MYBUTTONID);
       RepositionButton();
    }
    
    void CMyVew::RepositionButton()
    {
        //work out button position you need
        m_Button.MoveWindow(x, y, width, height);
    }
    

    Note that the button is only created once and takes care of drawing itself. You do not need to worry about it in OnDraw() or anything like that.

    The only time you need to worry is when the button should move position. This is why I separated out the RepositionButton() function. For instance, if you are using a CScrollView and the user scrolls, the button window has no knowledge of this, so you will need to react to scroll events and call RepositionButton()

    You can react to the button’s messages just like you would any other button by adding an ON_BTN_CLICKED message map.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code below doesn't work correctly since my MFC program is in unicode circumstance.
So I have this MFC dialog program I am working with. The dialogs are
Now i am writing a MFC program with opengl in it. And when i
I am working on a program built in MFC. I have this weird situation
I have this MFC program that when I kill it with task manager I
I'm using the Qt/MFC Migration Framework tool following this example: http://doc.qt.nokia.com/solutions/4/qtwinmigrate/winmigrate-qt-dll-example.html The dll I
I have to program a simple threaded program with MFC/C++ for a uni assignment.
MFC File: winctrl4.cpp (C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\mfc) CString CRichEditCtrl::GetSelText() const { ASSERT(::IsWindow(m_hWnd)); CHARRANGE
Goodmorning, I'm doing a query to fill a MFC Recordset in my program. Since
I have implemented custom draw for an CTreeCtrl in my MFC Smart Device program.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.