Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Movable toggle button in View?

Posted on 1998-10-21
7
Medium Priority
?
266 Views
Last Modified: 2013-11-20
I have two view pane separate by splitter, In one of the view window which is CHostView : public CScrollView, I want to place Toggle buttons and possibly to drag each individual button vertically to different position. I also like to have a individual popup dialog popup when the button is right mouse clicked. And also the total number of buttons is variable. I appreciate your expertise advice. Thank You!
0
Comment
Question by:nicolet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 600 total points
ID: 1323637
Do you mean that you want the user to be able to drag the button?

You'd need to set the NM_NOTIFY flag for the button (so you get mouse up/down etc) then, on a mouse down event, call ::DragDetect to determine whether the user is clicking of dragging the button (DrawDetect returns TRUE if the button is being dragged).  If it is being dragged, then set a flag (or write your own message pump loop) and respond to mouse moves by changing the window position for your button.

Similarly, you should be able to respond to a OnContextMenu in your button class that would then call TrackPopupMenu to display the context menu.

0
 

Author Comment

by:nicolet
ID: 1323638
Hi Ronslow,
Thank you for your answer, however I am not clear about how to create these toggle buttons in one of my splitter view area which is a CHostView : public CScrollView. By the way the number of buttons is various, it depends on application to decide how many buttons should it provide in the view area). I am using MFC developer studio, Since the view class is not a dialog, How do I create buttons in View? and how to attach the callback message such as NM_NOTIFY or OnContextMenu for each button in the application's View class?
Thank You!

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1323639
I'll see if I can whip up a short example for you ... get back to you soon.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:nicolet
ID: 1323640
I have not received workable answer for this question yet. Can I post this again to get some more help?
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1323641
to create a button, add a member to your view

CButton m_myButton;

Setup a CRect with the position and size of the button

CRect myButtonRect;
myButtonRect.left = ... etc

In your OnInitialUpdate (or maybe OnCreate)

m_myButton.Create (
  "&MyButton",
  WS_CHILD | WS_VISIBLE | WS_TABSTOP,
  myButtonRect,
  this,
  IDC_MYBUTTON);

If you want several, then mane an array of CButton's and set the ID's to be sequential (or have an array of ID's)


0
 

Author Comment

by:nicolet
ID: 1323642
In your first answer you mention that
>Similarly, you should be able to respond to a OnContextMenu in >your button class that would then call TrackPopupMenu to >display the context menu.

If I create a CMyButton() class, to create and postion a button. How do I setup the messages such as "OnContextMenu" or "NM_NOTIFY" for this button in MFC. In App Wizard, I supposed I need to get CMyButton to be added as a new class, but I am confused with what should I enter for "Based class" and "Dialog ID" field in Add new class dialog? Since CMyButton is not a wizard created dialog. I am lost in this MFC way.
Thank you very much for your help!
 

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1323643
Generate the entries for a button in a dialog.  Put the same code into the message map, class header etc for your view.  The Class Wizard doesn't do anything that you as a programmer cannot (or should not) do ... it just helps by writing some simple code for you.

The only catch is if you don't know how many buttons you will have.  If it is truely dynamic, then you will want to handle all the buttons you created with a single member function (say, OnAnyButtonClicked) and use the ID of the button to take the appropriate action.

MFC supports this with

ON_NOTIFY_RANGE( wNotifyCode, id, idLast, memberFxn )

if your case, wNotifyCode is BN_CLICKED, id and idLast are the range of id numbers for the buttons you create and memberFxn is the name of the handler, which looks like..

afx_msg void memberFxn( UINT id, NMHDR * pNotifyStruct, LRESULT * result );

where id is the id of the button the was clicked, pNotifyStruct you can probably ignore, and *result should probably be set to zero

see MFC technical article TN061: ON_NOTIFY and WM_NOTIFY Messages for more info

Regarding tooltips ... look at the MS KB article:

DOC: How to Display Tool Tips After Calling EnableToolTips
Last reviewed: July 31, 1997
Article ID: Q140595

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question