EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

#Previous question #Index of VC++/WIN32/MFC Questions #Next question

Modal common dialogs

Most of the Common dialog boxes like File open/save, font, color, page setup, print dialog etc opens on top on main window and takes the user input and then closes. User cannot interact with main window and the control jumps to the event procedure of popup dialog. It returns to main event when user selects okay or cancel and dialog returns. This type of dialogs are modal dialog box.

Modeless find replace

Find replace dialog is different than these dialogs. It takes user's input at the same time user can interact with the main window where the search is happening. This type of dialog is modeless dialog box. The processing happens in different GUI thread and user can switch between main dialog and this popup dialog.

Source Code

#include <afxwin.h>
#include <afxdlgs.h>
class CMyWnd : public CFrameWnd
{
  CFindReplaceDialog m_FindReplace;
  CEdit m_Edit;
  public:
    CMyWnd()
10      {
11        RECT rect;
12        Create(NULL, _T("FindReplace demo"));
13        GetClientRect(&rect);
14        m_Edit.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, rect, this, 100);
15        m_FindReplace.Create(FALSE, "find", "replace", FR_DOWN, this);
16        m_Edit.SetWindowText("This is a find replace demo.");
17      }
18      afx_msg void CMyWnd::OnClose()
19      DECLARE_MESSAGE_MAP()
20  };
21 
22  BEGIN_MESSAGE_MAP(CMyWnd, CFrameWnd)
23  ON_WM_CLOSE()
24  END_MESSAGE_MAP()
25 
26  afx_msg void CMyWnd::OnClose()
27  {
28    if(MessageBox ("Want to exit from this application?", "Exit", MB_YESNO) == IDYES)
29    {
30       PostQuitMessage(0);
31    }
32  }
33   
34  class CMyApp : public  CWinApp 
35  {
36 
37    public:
38       virtual BOOL InitInstance()
39      {
40        m_pMainWnd = new CMyWnd();
41        m_pMainWnd->ShowWindow(SW_SHOW);
42        m_pMainWnd->UpdateWindow();
43        return TRUE;
44      }
45   };
46  CMyApp app;

Output

Find replace modeless dialog

You have viewed 1 page out of 109. Your VC++ learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

#Programming Windows, Fifth Edition (Developer Reference)
#Programming Applications for Microsoft Windows (Microsoft Programming Series)
#Programming Windows with MFC, Second Edition
#Visual C++ Programming
#Programming Microsoft Visual C++, Fifth Edition

* #1 webmaster Tue 29 Apr/2014 11:21:48(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.

Regards,
Webmaster

Your message goes here:

Name:Guest
Email:anonymous@unknown.com
My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
 
Note:
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.