The VC implements dialog-based applications hidden at startup

xiaoxiao2021-03-06  67

First, you must change the mode creation of the dialog to non-mode creation in the App class.

The specific method is as follows:

CTestHideDialogDlg * dlg = new CTestHideDialogDlg (); m_pMainWnd = dlg; if (! Dlg = NULL) {BOOL ret = dlg-> Create (IDD_TESTHIDEDIALOG_DIALOG); if (! Ret) {AfxMessageBox ( "Error creating Dialog"); return FALSE; } DLG-> ShowWindow (sw_hide);} else afxMessageBox ("Error Creating Dialog Object");

A Non-Mode dialog has been created at this time and is initially hidden.

Next, you want to add a mess loop processing code, otherwise the program will automatically exit.

BOOL BRET; MSG MSG;

While ((Bret = GetMessage (& MSG, NULL, 0, 0)))! = 0) {if (Bret == -1) {} else if (msg.Message == WM_COMMAND && msg.wparam == idok) {Break } Else if (! Iswindow (m_pmainwnd-> m_hwnd) ||! IsDialogmessage (m_pmainwnd-> m_hwnd, & msg) {TranslateMessage (& MSG); DispatchMessage (& MSG);}}

This is designed to exit when the user presses the OK button on the dialog. Since the first program main window is hidden, you need a keyboard HOOK, design to display the program main window when the user presses a key or a combination button. For details, please refer to the relevant information.

转载请注明原文地址:https://www.9cbs.com/read-89628.html

New Post(0)