We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Dialog Bars/Tool Bars

jrmcg
jrmcg asked
on
Medium Priority
343 Views
Last Modified: 2010-04-02
I created a Dialog Bar Control with the dialog editor.
It contains 3 edit boxes that are to contain integer
values.  The values are obtained from the document.
I have no problem creating the Dlg Bar in the MainFrame
and displaying it the way I want to.

The problem is in displaying the values.  I gave the edit
boxes member variables, then obtained a pointer to
the frame and in turn accessed the variables of the
dialog bar ( I thought) this didn't work.  I get a compile
error that says that my variable is not a member of
CDialogBar.  I am also going to need to be able to set
the variables in the same Dialog Bar.  Obviously what
I am doing is incorrect.  So my question is :
How can I access variables attached to the controls on
a Dialog Bar that is created on the MainFrame?
Comment
Watch Question

Commented:
WARNING: I don't do MFC

It sounds to me like you class is derived from CDialogBar, but you have a pointer to just a CDialogBar.  You need to down cast that pointer to a pointer to your dialog bar class type.

Commented:
Does that make sense?  Do you know how to cast the pointer?

Commented:
Hope that this might help:

Perphaps you could consider modeless CDialogBox instead of CDialogBar. Derive a new class that inherits from the CDialogBox or CDialogBar. Then, have the member variables of the edit boxes declared. Then, you could actually declared another CStrings variables and that you could get the value of the edit using GetWindowText and that you pass the CString in. You could have the value of the edit control through the new class that inherits the DialogBox or the DialogBar. ie

CNewClass m_dlg; // the new class that inherits from CDialogBox or CDialogBar
CEdit m_edit;         // the member variable of the edit control
CString m_string    // Containing the text inside the edit control

m_dlg.m_edit.GetWindowText(m_string);  // Getting the text.

You also could get the text inside the new Class declared. However, I have yet to do that as above. But I have done that by gettting the text inside the new Class derived.

Tell me if it works.

Author

Commented:
Sorry, but this control has to specifically be used as a toolbar type dialog.  This control is to be constantly displayed and updated by more than one document.  It is also going to be changed.

Todd can you give me an example of casting the pointer?  The dialog box that the dialog bar is using as a resource can't put values into the controls when the dialog initializes, either.  I can't set an initial value for the CEdit control.

There is a sample program on MSDN but all it does is demonstrate creation of different types of Control Bars.  It never actually uses them in an interactive way.

Thanks

Commented:
Can you post your code where you try to access the members of the dialogbar object?  Also post the code where you declare the dialogbar class.  I can probably make that work.  I don't know enough MFC to do it from scratch.

Commented:
How about adding variables to the dialog bar constructor which are the variables you want to update/change/examine?

Author

Commented:
Sorry it is taking so long.  Bare with me.  Today has been hectic.  I'll post the code tomorrow.  I appreciate you guys helping.

JR
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
The way I created the member variables was using the class wizard with the dialog class.  I created the Dialog with the wizard and added the variables to the dialog.

In Frame.h:
CDialogBar m_wndDlgBar;

In Frame.cpp:

// IDD_DIALOG_CTRL_BAR is ID of Dialog created with wizard

m_wndDlgBar.Create(this,IDD_DIALOG_CTRL_BAR,CBRS_TOP | WS_VISIBLE,
                          IDD_DIALOG_CTRL_BAR))

In DlgBar.h: Declaration of Dlg Class

//public variables
int m_Value

In DlgBar.cpp: Implementation of Dlg Class

// In Data Exchange
DDX_Text(pDX, IDC_EDIT_VALUE, m_Value);

I can not even put values into these boxes using the OnInitDialog() function with the dialog class.

To access these variables inside the Document class, I would obtain a pointer to the frame, then access the variables of the m_wndDlgBar.

pFrame->m_wndDlgBar.m_Value = 999;

 
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.