An Example of Overlapping Controls (CRgnedButton)

Whenever a developer wants to create overlapping controls for example a Button with inner buttons, or a slider inside it, he faces a problem that whenever a user clicks on the button inner items disappear. I found a simple solution for this problem, which also prevents any distortions in the drawing if the inner controls.

Using this special button control is very simple, just use the ClassWizard to subclass your button to a CRgnedButton class typed control, and start overlapping it with what ever you want. (Of course don't forget to include the header file and cpp file, CRgnedButton.h & CRgnedButton.cpp accordingly)

To manually add a CRgnedButton to your existing Dialog do the following:

Add to your Dialog control the following (after adding a visual Button, using the Visual Editor):

  • To the Dialog's header file:
    #include "RgnButton.h"
    
  • (under the Dialog class)
    CRgnButton	m_Btn1;
    
  • To the Dialog's cpp file:
    (under the Dialog DoDataExchange)
    DDX_Control(pDX, IDC_BUTTON1, m_Btn1);
    

Downloads

Download demo project & source code - 36 KB



Comments

  • Overlaping Of Buttons(Active x control with buttons)

    Posted by Legacy on 04/05/2003 12:00am

    Originally posted by: vishala

    Hi,
    This is nice working,But My problem is how we done same thing for an active x control and buttons.Example I takke a media palyer control on that control i place buttons in the place of position controls,when a button click it is it's functionality with out disappear control.It is Important for me.
    regards
    vishala

    Reply
  • Doubt regarding CBitmapButtons

    Posted by Legacy on 10/16/2002 12:00am

    Originally posted by: anu

    hi,

    i have some CBitmapButtons in the view window.when i click one bitmapbutton it is fixed in a particular position. i want the same bitmapbutton to appear in a different position too. how to add functionality twice and how to make it understand that the first click is for one position and the second click is for other position?

    Reply
  • Doesn't work in Windows 95

    Posted by Legacy on 10/18/2000 12:00am

    Originally posted by: Harry

    I built the code using VC++ 6.0 sp4 and it ran great on
    Windows 98, NT & 2000. But it doesn't work in Windows 95.
    Just alot of screen flicker. Any ideas anyone?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds