Click a button to pop up a window

Source: Internet
Author: User
GetDlgItemThe Button1 button in the Calculator window executes the call to a Mycalc class window.
void Ccalculatordlg::onbnclickedbutton1 ()
{
TODO: Add control notification Handler code here
Mycalc *mycalc_dlg = new Mycalc;
Mycalc_dlg->create (Idd_dialog1,null);
Mycalc_dlg->showwindow (Sw_show);
Non-modal
}

Several functions: 1.GetdlgItem:
DLG--A dialog window, a control.
returns a pointer to the object of the dialog window or control, based on the ID of a dialog window or a control.

For example, IDC_EDIT1 is the ID
of the control cedit* Pboxone;
Pboxone = (cedit*) GetDlgItem (idc_edit1);
With GetDlgItem (IDC_EDIT1); Returns a pointer to this control, cedit*, into Pboxone.

Next, you can use it, for example:
Gotodlgctrl (Pboxone);
2.create () in vs2010 two different forms:
Virtual BOOL Create (
   lpctstr lpsztemplatename,
   cwnd* pparentwnd = NULL 
);
Virtual BOOL Create (
   UINT nidtemplate,
   cwnd* pparentwnd = NULL 
);
Lpsztemplatename

Contains a string that is the name of a dialog template resource that is null-terminated. pParentWnd

A pointer to the parent window object (type CWnd) dialog object belongs to. If NULL, the parent window of the dialog object is set as the main application window. nIDTemplate

Contains the ID number of the dialog template resource.

If the dialog box is created and initialized successfully, both forms return non 0; otherwise 0.
3.ShowWindow () CWnd::ShowWindow

BOOL ShowWindow (int ncmdshow);

Return value: Returns a value other than 0 if the window was originally visible, or 0 if the CWnd was originally hidden.

Parameters:

nCmdShow Specifies how CWnd should be displayed. It must be one of the following values:
Sw_hide Hides the window and passes the active state to the other window.
Sw_minimize Minimizes the window and activates the top-level window in the System list.
Sw_restore Activates and displays the window. If the window is minimized or maximized, Windows recovers its original size and position.
Sw_show Activates the window and displays it at its current size and position.
Sw_showmaximized Activates the window and displays it as a maximized window.
Sw_showminimized Activates the window and displays it as an icon.
Sw_showminnoactive Displays the window as an icon. The currently active window remains active.
Sw_showna Displays the window in the current state. The currently active window remains active.
Sw_shownoactivate Displays the nearest size and position of the window. The currently active window remains active.
Sw_shownormal Activates and displays the window. If the window is minimized or maximized, Windows recovers its original size and position.

Description
This function sets the visual state of the window.
Each application applies only cwinapp::m_ncmdshow to the primary window and calls once ShowWindow. Later calls to ShowWindow should be replaced with the values listed above Cwinapp::m_ncmdshowThe specified value.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.