| | |
Open Dialog window in MFC
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
When you double click on the button as I showed previously the VC++ 6.0 IDE will create the correct message map entry for you -- you do NOT have to code that yourself. After clicking that button, the message map in the *.cpp file should like something like this:
And in the *.h file
Attached is the complete project I made, minus compiler-generated files.
BEGIN_MESSAGE_MAP(CDlgtestDlg, CDialog)
//{{AFX_MSG_MAP(CDlgtestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()And in the *.h file
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CDlgtestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
}Attached is the complete project I made, minus compiler-generated files.
Last edited by Ancient Dragon; Jul 14th, 2009 at 10:33 am.
•
•
Join Date: Dec 2007
Posts: 360
Reputation:
Solved Threads: 69
Your OnSim should look like:
Please reread the manual concerning the return values of DoModal(). There is no point in comparing the return value against control IDs.
Another strange thing: are you sure the Button is in CMainFrame? Usually you only have IDs of menu items with ON_COMMAND handlers there.
C++ Syntax (Toggle Plain Text)
void YourFirstDialog::OnSim() { CSimConFig dlg; dlg.DoModal(); }
Please reread the manual concerning the return values of DoModal(). There is no point in comparing the return value against control IDs.
Another strange thing: are you sure the Button is in CMainFrame? Usually you only have IDs of menu items with ON_COMMAND handlers there.
Last edited by jencas; Jul 14th, 2009 at 11:30 am.
If you are forced to reinvent the wheel at least try to invent a better one!
Please use code tags - Please mark solved threads as solved
Please use code tags - Please mark solved threads as solved
•
•
Join Date: Feb 2009
Posts: 35
Reputation:
Solved Threads: 0
Hey AncientDragon and Jencas,
thanks a million for all your help. From looking at your example AncientDragon I think I may finally understand what is going on. Again thank you for posting that. Could I ask one small favour from you guys, could you recommand a good book for MFC, I have "Introduction to MFC Programming with Visual C++" by Richard M. Jones and "Professional MFC with Visual C++ 6" by Mike Blaszczak but im finding it hard to dig what I want from these two books. Is there any "bible" book for MFC like "Programming principles and practice using C++" by Bjarne Stroustrup book is for C++? Thanks again for all your help and time.
Colm.
thanks a million for all your help. From looking at your example AncientDragon I think I may finally understand what is going on. Again thank you for posting that. Could I ask one small favour from you guys, could you recommand a good book for MFC, I have "Introduction to MFC Programming with Visual C++" by Richard M. Jones and "Professional MFC with Visual C++ 6" by Mike Blaszczak but im finding it hard to dig what I want from these two books. Is there any "bible" book for MFC like "Programming principles and practice using C++" by Bjarne Stroustrup book is for C++? Thanks again for all your help and time.
Colm.
There have been many major changes to MFC since that compiler was released. I started learning it by doing the Scribble Tutorial
That tutorial will not be useful on VC++ 2005/8 compilers.
That tutorial will not be useful on VC++ 2005/8 compilers.
Last edited by Ancient Dragon; Jul 14th, 2009 at 12:35 pm.
•
•
Join Date: Dec 2007
Posts: 360
Reputation:
Solved Threads: 69
The source code for VS2005/8 can be found at http://msdn.microsoft.com/en-us/libr...ts(VS.80).aspx
Last edited by jencas; Jul 15th, 2009 at 7:20 am.
If you are forced to reinvent the wheel at least try to invent a better one!
Please use code tags - Please mark solved threads as solved
Please use code tags - Please mark solved threads as solved
![]() |
Similar Threads
- Change the default view from "list" to "thumbnails" in open dialog (Windows NT / 2000 / XP)
- Open File Dialog help! (VB.NET)
- Dialog Window doesn't show, Designer won't open (Python)
- File Open dialog created using GetOpenFileName function does not close (C++)
- set anchor property in dialog window (VB.NET)
- file open dialog box control in asp.net (ASP.NET)
- File Dialog window, save dialog window (Python)
- IE cannot open links in new window (Web Browsers)
- Common Open dialog box (C++)
Other Threads in the C++ Forum
- Previous Thread: C++ source file being compiled as C source file
- Next Thread: Falling letters typing game
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






