Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging a dialog's style at creation to override what's in the .RC template
    primarykey
    data
    text
    <p>I have a little dialog I created using Resource Editor in VS2005. It's going to be used as a child dialog of another dialog, in 2 different ways... either as a child which sits on top of the dialog like a custom control, or as a popup which can move beyond the boundaries of the parent window. If I modify a single style in the RC file, both of these work as expected - simply substitute WS_POPUP for WS_CHILD to toggle:</p> <pre><code>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&amp;view",IDC_ACTION_PREVIEW,64,59,50,15 PUSHBUTTON "M&amp;ore",IDC_ACTION_MORE,115,59,50,15 PUSHBUTTON "S&amp;elect",IDC_ACTION_SELECT,168,59,50,15 END </code></pre> <p>The problem is, I want to be able to choose the behavior when creating the child dialog at run-time as a sort of widget type framework, e.g overriding the RC file style</p> <p>I tried:</p> <pre><code>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(); } </code></pre> <p>But it makes no difference that I can see, other than that the result of GetStyle changes from <code>0x8400044C</code> to <code>0x4400044C</code>... the widget child-dialog starts invisible but when I show it, it retains the WS_POPUP behavior.</p> <p>What's wrong, and how can it be fixed?</p> <p>As Ben suggests, I wonder if this is not a style that can be changed <em>after</em> the window is created, but the problem then is how to intercept the dialog-template structure and modify the style before it's used to create the window?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload