|
Thanks.
I have two questions.
First, how do you create the submenu? Do you create one in resource editor?
Second, how do you know what option the user selects?
Thanks,
Kuphryn
|
|
|
|
|
First,You can create one in resource editor,then you add handler to each option by Class Wizard.
Second,you can create the submenu dynamicly like below:
CMenu popMenu;
popMenu.AppendMenu(MF_STRING,ID,string);
CPoint pt;
::GetCursorPos(&pt);
popMenu.TrackPopupMenu(.......);
If you do it by first point above,Class Wizard will know
what option the user selects,and call the related handler.
Or you can just do like below:
int id=popMenu.TrackPopupMenu(......);
//id is the ID of the menu option selected
if(id==...)
{
//do you want to do
}
if(id==....)
{
//do you want to do;)
}
|
|
|
|
|
Okay. Thanks.
I have not implemented a submenu (context menu). I do admit the process sounds quite simple.
One thing I am not sure on is if you create a new menu, say, "Edit Tools" in resource editor, it will show up in the main menu too.
Kuphryn
|
|
|
|
|
I'm rephrasing a previous unanswered Q. How can I directly connect a dialog box to variables declared in a CDocument inherited class? Here's a simplified example:
A CMyDocument class is declared in Document.h and has a CString variable (say, m_text). I also have a CMyDialog class declared in a View.h that accepts a string as input from an edit box. When I enter a string, it updates m_text, which is then stored to disk and used throughout the application's classes.
Is there a way to direct the DDX to the CMyDocument class? Or is there even a simpler way? Someone must have done this many times, since it seems to be such a commonplace situation. Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
RalfPeter wrote:
Is there a way to direct the DDX to the CMyDocument class?
Yes, you could use DDX_Text without ClassWizard and read/store string directly into document's data member. You could also skip DDX_Text and use [Get|Set]DlgItemText to access edit control directly in CYourDlg.
However, I'd advise against this approach. Treat your dialog as simple device for user interaction. Dialog shouldn't care about document at all. Just invoke a dialog in some CYourDoc method and update m_text when DoModal returns IDOK.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hello Everybody:
I was wondering if anyone can tell me how to disable existing control inside a Dialgo box. Ok this is what I want to do. I have a check box control and under that check box I have 2 combo boxes and 2 buttons. What I want to do is if I check the check box, the controls under the check box become enabled. And when I uncheck the check box, the controls under the check box become disabled. Any suggestions are more than welcome.
Best regards,
Luis E. Cuadrado
)
|
|
|
|
|
Handle BN_CLICK for checkbox. In the event handler, use EnableWindow to switch other controls on/off.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hi:
Sorry for my ignorance, but does EnableWindow works with controls as well?
thanks,
Luis E. Cuadrado
)
|
|
|
|
|
Luis E. Cuadrado wrote:
does EnableWindow works with controls as well?
Controls *are* windows. EnableWindow will work.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Create Control Variables Using the ClassWizard and Call
Your_Control_Variable.EnableWindow(FALSE) ;
To Disable the Control
and
Your_Control_Variable.EnableWindow(TRUE) ;
to enable the Window
and using Classwizard make a event Handler Corresponding to BN_CLICKED message of u check box
and ur checkbox_control_variable.GetCheck() fuction to determine the check state..id it is true box checked else unchecked..handle the situation as u like...
Renjith-CPian.
|
|
|
|
|
Oh, I see. I'm giving it a try. I'll let you know the results. Thank you for your replies.
later,
|
|
|
|
|
Well, I just did what you guys recommended me and it works. Thank you very much Tomasz Sowinski and Renjith - CPian for all you help. Have a wonderful day.
Best regards,
Luis E. Cuadrado
)
|
|
|
|
|
i see many web pages with edit controls which allow people to input their bank ID (credit card ID or whatever) and order goods on line.
i try to type a random id (with right numbers) and get a responding like "id is not correct".
i am wandering how these pages know it is not correct?
i think if i input my real id (never try), the pages will know it is right.
my question is: do the pages contact to banks (or whatever) immediately to check the inputting? otherwise how do they know at once?
(i know c++, applet, php, socket etc tech)
thx
includeh10
|
|
|
|
|
See this algorithm[^].
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
ur page is quite interesting, thx
includeh10
|
|
|
|
|
Hello,
I keep running in to this bug because I don't really know when the appropriate time is to access various child/control windows in the creation of a dialog. I wish to set some of the controls' initial values (e.g., CMonthCalCtrl::SetDayState) once when the dialog is created and before the user sees the child windows.
I have tried to insert such function calls in "OnCreate" or "PreCreateWindow", but these seem to fail. I would like to find the windows message I can use to call such initialization functions that satisfies ASSERT(::IsWindow(m_hWnd)).
Thanks!
JennyP
|
|
|
|
|
If it's a modal dialog, you can manipulate the controls in OnInitDialog() . If it's a modeless dialog, do it after the dialog has been shown for the first time.
I put my GUI initialization code for modeless dialogs in a method called initGUI() that I call once in OnShowWindow() when the window is being shown.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
how can u access the child control properties even before the parent window is created..?? that is the reason that fails...
Renjith-CPian.
|
|
|
|
|
Hi Guys,
I am writing a Monitoring/Alert application using Winsock.
I have a dialog based application.
The Server part accepts incoming client connections and sends alert messages to clients when certain things happen.
I have a main dialog which shows monitoring results.
I have a CSocketManager class which manages all the Winsock stuff.
In my main dialog class I have declared a member variable of type CSocketManager m_SocketManager.
I have created a second dialog which will be interface to manage all Winsock comm stuff, start server listening,port, messages from clients etc.
The reason I am not creating CSocketManager object in the class for this dialog is that I want Socket object to exist and remain listening even after this second dialog is closed.
This second dialog is just an interface that the user can access from menu on main dialog when the need arises to for example see what clients are connected or to send a message to all clients.
Ho to I refer to the CSocketManager object m_SocketManager declared in the main dialog class in the class for this second dialog.
...or is there another way I should be structuring everything or another way to do things.
To try and summarize what I am trying to achieve is I want to create a Socket object which I can reference and manipulate from a second dialog but I do not want this Socket object to be destroyed when this second dialog is closed.
I am fairly new to C++.
I appreciate that this is a fairly general and possibly wide ranging question but any ideas would be appreciated.
Let me know if I can more specific about any point or if anything is unclear in my question.
Cheers
Zed's dead, baby. Zed's dead.
|
|
|
|
|
Just pass the address of m_SocketManager to a member in the 2nd dialog, before you call its DoModal() . The 2nd dialog can then manipulate the object from within itself.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ravi,
Thanks very much for your feedback.
I am a bit new to all of this so could you please give a simple example of how to pass address of m_SocketManager to member variable in 2nd dialog class.
What is the most professional way to pass this address??
Cheers
Zed's dead, baby. Zed's dead.
|
|
|
|
|
The easiest way to do this is to declare a public member pointer to a CSocketManager object in dialog 2, like so:
CDialogTwo : public CDialog
{
...
public:
CSocketManager* m_pSocketManager;
} Then, in the first dialog, set that member before displaying the 2nd dialog, like so:
CDialog2 dlg2 (this);
dlg2.m_pSocketManager-> &socketManager;
long nStatus = nDlg2.DoModal();
...
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
just make the CSocketManager as ur main dialog's public member variable..and Create the new Dialog as child and
you can access the CSocket_manager obbject from ur child dialog like
GetParent()->CSocket_managerObject;
Renjith-CPian.
|
|
|
|
|
You'd first need to cast the CWnd* returned by GetParent() .
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Renjith,
Thank you very much for your feedback.
In a dialog-based application how can you indicate that you want a second dialog to be child of the first dialog?
Cheers;)
Zed's dead, baby. Zed's dead.
|
|
|
|