In MFC, you often derive your custom class from the base MFC class- so, for example assume you wish to create a dialog. In this case- the default class for a dialog in MFC is CDialog.
You'd create a class like:
CMainDialog::public CDialog {
public:
//Message Handler functions
afx_msg void OnBtnNewDialogClick();
DECLARE_MESSAGE_MAP() //VS Macro that adds a message pump to this class
private:
...
};
//This defines all the windows messages we want to respond to.
BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
ON_COMMAND(IDD_BTNNEWDIALOGCLICK, OnBtnNewDialogClick)
END_MESSAGE_MAP()
In MFC, there are two types of dialogs- modal ones (upon which you can not access any other windows until it is closed) vs modeless ones (run besides others- eg does not appear to 'freeze' the rest of the program like modal ones).
how can i get a button in visual studio c++ mfc to lead to a diffrent window/dialog? is there a specific code?
In this case; to create and display a new dialog from the original one- you'd do something like:
afx_msg void CMainDialog::OnBtnNewDialogClick()
{
CDifferentDialog CDiffDlg;
CDiffDlg.DoModal(); //for a modal dialog
}
This will create a model dialog box- provided you've derived CDiffDialog from CDialog like like CMainDialog.
You really need to feel confident with C++ before you can use MFC effeciently. If you can understand all that syntax I've just written; keep reading articles on the internet about MFC; or buy a book on MFC (MFC from ground up is truely a great, fast-track book that I learnt the basics from). Otherwise- try to practice writing/understanding C++ classes before you attempt to tackle MFC.
Subsky