Changing the style of the dialog when creating to override what is in the .RC template

I have a small dialog box that I created using the resource editor in VS2005. It will be used as a child dialog of another dialog in two different ways ... either as a child that sits on top of the dialog, as a user control, or as a pop-up window that can move outside the parent window if I change one style in the file RC, both of them work as expected - just replace WS_POPUP with WS_CHILD to switch:

IDD_WIDGET DIALOGEX 0, 0, 221, 78
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_POPUP | WS_BORDER
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_STATICEDGE
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    PUSHBUTTON      "Pre&view",IDC_ACTION_PREVIEW,64,59,50,15
    PUSHBUTTON      "M&ore",IDC_ACTION_MORE,115,59,50,15
    PUSHBUTTON      "S&elect",IDC_ACTION_SELECT,168,59,50,15
END

The problem is that I want to be able to choose the behavior when creating a child dialog at runtime as a kind of structure like widgets, for example, overriding the RC file style

I tried:

BOOL CMyDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    m_Widget.Create(IDD_WIDGET,this);
    DWORD oldstyle = m_Widget.GetStyle();
    m_Widget.ModifyStyle(WS_POPUP,WS_CHILD);
    DWORD newstyle = m_Widget.GetStyle();
}

, , , GetStyle 0x8400044C 0x4400044C... widget , , WS_POPUP.

, ?

, , , , , , ?

+3
1

:

, InitDialog , . , .

+1

Source: https://habr.com/ru/post/1748358/


All Articles