Introduction
This article describes how to remove the OK button in the upper right corner of the wtl dialog box.
Problem
The dialog box inherited from the cstddialogimpl class has an OK button in the upper right corner by default. For example
Why is there this OK button?CodeIs inherited from cstddialogimpl <cconfigdialog>, and cconfigdialog is a custom class.
ClassCconfigdialog:PublicCstddialogimpl <cconfigdialog>,PublicCwindataexchange <cconfigdialog>
{
Public:
Begin_msg_map (cconfigdialog)
Chain_msg_map (cstddialogimpl <cconfigdialog>)
End_msg_map ()
Cstddialogimpl inherits from cstddialogimplbase. The default Shidi flags is wtl_std_shidif.
Template<ClassT, uint t_shidiflags = wtl_std_shidif,BoolT_bmodal =True>
ClassAtl_no_vtable cstddialogimpl:PublicCstddialogimplbase <t, t_shidiflags, t_bmodal>
{};
Wtl_std_shidif contains shidif_donebutton.
# DefineWtl_std_shidif shidif_donebutton | shidif_sipdown | shidif_sizedlgfullscreen
Shidif_donebutton is the OK button displayed in the upper right corner.
Implementation
To remove this button, follow these steps.
1. Modify the inheritance of cconfigdialog and inherit from cstddialogimpl <cconfigdialog, shidif_sizedlgfullscreen | shidif_sipdown>
ClassCconfigdialog:PublicCstddialogimpl <cconfigdialog, shidif_sizedlgfullscreen | shidif_sipdown>,
PublicCwindataexchange <cconfigdialog>
{
Public:
TypedefCstddialogimpl <cconfigdialog, shidif_sizedlgfullscreen | shidif_sipdown> cconfigdialogwithoutdone;
Begin_msg_map (cconfigdialog)
Chain_msg_map (cconfigdialogwithoutdone)
End_msg_map ()
You also need to modify chain_msg_map.
2. added the shdonebutton and modifystyle calls in the oninitdialog () function.
Lresult cconfigdialog: oninitdialog (uint umsg, wparam, lparam, bool & bhandled)
{
Shdonebutton (m_hwnd, shdb_hide );
Modifystyle (0, ws_nonavdonebutton, swp_nosize );
ReturnBhandled = false;
}
The result is as follows:
Refer to cstddialogimpl and the OK button