Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
4/14/2010

In general, a dialog box should include the OKbutton on the title bar. However, if you are creating a wizard-style dialog box or another type of dialog box that includes a Cancelbutton, you can choose to show no title bar icon for that dialog box. This requires several changes to general-purpose code, such as that generated by the App Wizard.

To prevent Smart Minimize and OK buttons from appearing on title bar of dialog boxes

  1. Manually edit the resource (.rc) file for the dialog box. Add WS_NONAVDONEBUTTONto the STYLEline to prevent the display of the Smart Minimizebutton, as shown:

    Copy Code
    //
    // Dialog.
    //
    IDD_WIZARD DIALOG DISCARDABLE 0, 0, 140, 57
    STYLE WS_POPUP | WS_CAPTION | WS_NONAVDONEBUTTON
    EXSTYLE 0x80000000L
    CAPTION "Your Wizard"
    
  2. Remove SHDIF_DONEBUTTONfrom the dwFlagsmember of the SHINITDLGINFOuser interface structure (generally found in the WM_INITDIALOGmessage handler for the dialog box) to remove the OKbutton from the title bar, as follows:

    Copy Code
    SHINITDLGINFO shidi;
    switch (message)
    {
    	case WM_INITDIALOG:
    		shidi.dwMask = SHIDIM_FLAGS;
    	
    		shidi.hDlg = hDlg;
    		if (!SHInitDialog(&shidi)) {
    			MessageBox(NULL, _T("Can't create dialog box."),
    					 _T("Error"), MB_OK);
    			exit(0);  // Replace with specific error handling.
    	}
    		.
    		.
    		.
    
  3. Add a call to the SHDoneButtonfunction with the SHDB_HIDEstate after calling the SHInitDialogfunction to hide the OKbutton, as follows:

    Copy Code
    	if (!SHDoneButton(hDlg, SHDB_HIDE)) {
    		MessageBox(NULL, _T("Can't hide the OK button."),
    				 _T("Error"), MB_OK);
    		exit(0);  // Replace with specific error handling.
    }
    
  4. If you run the code as is, no Smart Minimizebutton or OKbutton appears on the title bar, but tapping the Enterkey in the emulator or on the input panel keyboard closes the dialog box. If this is not the desired behavior, make the appropriate changes to the WM_COMMANDmessage handler. Generally, you want to set focus to the default control in the current panel of your wizard.

See Also