Source Code for Windows Create dialog box
Define a member variable, When calling DoModal (), the data to be added to the ComboBox is written into this member variable, and the ComboBox is initialized in OnInitDialog void Cmyview::onshow () {//Todo:add Your command handler code here CDIALOG1 dlg; Dlg. Create (IDD_DIALOG1); Dlg. ShowWindow (Sw_show); As a non-modal dialog box, the dlg you define is a local object, then the DLG is executed. ShowWindow (sw_show); At the end of the OnShow () function at the next to} symbol, the life cycle of the local object of Dlg is also destroyed, so you cannot see the dialog box display, You can change the dlg into a CMyView class member variable to define it cstring type = L ""; type. AppendFormat (L "All FILES (*%s) |*%s| |", Suffix,suffix); CFileDialog File_dlg (true,null,null,ofn_hidereadonly| Ofn_overwriteprompt,type,afxgetmainwnd ()); CString current_file = L ""; if (File_dlg. DoModal () = = IDOK) {current_file = File_dlg. GetPathName (); if (! ( Current_file. Right (strlen (SUFFIX)) ==suffix) {Current_file+=suffix;} CFile file (current_file,cfile::moderead);//int bufferlength = file. GetLength ();//char *buffer = (char *) malloc (bufferlength);//file. Read (buffer,bufferlength);//file. Close ();}
Source Code for Windows Create dialog box