Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDialogBar

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0

I'm using the CDialogBar which is easy to create and display. I have a problem when I run class wizard and want to create a class to receive messages. I don't know what class to choose. I would like to choose CDialogBar but the class wizard doesn't have it. I tried CDialog but it ignores all events. Has anyone used this CDialogBar class before.

Thanks in advance,

Some dude
 
It's very easy. I'm not sure it's the best solution but if you do the following and you'll reach the target:
- create a new dialog resource in ResourceView, it's supposed to be IDD_DIALOGBAR
- insert a new MFC class that derives from CWnd (choose "generic CWnd" as the base class) and it's supposed to be CMyDialogBar
- change the base class of CMyDialogBar from CWnd to CDialogBar
- add a button (IDC_BUTTON1) and a textbox (IDC_EDIT1) into your IDD_DIALOGBAR dialog resource
- define the message map for CMyDialogBar class by adding this macro:
BEGIN_MESSAGE_MAP(CFindBar, CWnd)
//{{AFX_MSG_MAP(CFindBar)
//}}AFX_MSG_MAP
ON_COMMAND(IDC_BUTTON1, OnButton1)
END_MESSAGE_MAP()

- add a new member function to CMyDialogBar with this prototype "afx_msg void OnButton1();" (it's not necessary to use afx_msg keyword in function implementation)
- put this code into your function implementation:
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_STEXT_EDIT);
if (pEdit)
{
CString strText;
pEdit->GetWindowText(strText);
AfxMessageBox(strText);
}
- just run the application, click the button and see how it works.
Cheers,
Long.
 
I think u did not understand the Q !!! if u did then the solution is wrong. the wiz would still not be able to help...
 
> I think u did not understand the Q !!! if u did then the solution is
> wrong. the wiz would still not be able to help...

I disagree. The way I read your question Long's post is a 'bullseye' for an answer.

If it does not address your question then you might try to clarify your problem and goal for us.

-pete
 
I think it's a flexible way to hanlde every message that can't not be reveiced by using Class Wizard. It's not the best, I know, but it can help you overcome... :)
Long.
 
I know this post is long forgotten but for everyone who is interested, I dug up the following from MFC:

The Dialog Bar is an extension of the CMainFrame, therefore all messages are handed down to CMainFrame. What I did was create the button in the DialogBar, right-click on it in the Dialog Editor, choose "Class-Wizard". It will complain about the button being a new ressource and will ask to which class it should be linked. Choose "Existing Class" and then choose your CMainFrame. You can then assign events to the button as you normal.
Of course this works also with other controls.

I tried this with a German version of MSVC++, so I probably didn't get all the texts right in the description above...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top