Loading ...
Sorry, an error occurred while loading the content.

Modify style in modeless dialog during creation of dialog

Expand Messages
  • matmidlw
    I need help with Modeless Dialog. My dialog has to be in both LeftToRight & RightToLeft Layout depending on user location. The problem is that if I change
    Message 1 of 4 , Jul 8, 2008
    • 0 Attachment
      I need help with Modeless Dialog. My dialog has to be in both
      LeftToRight & RightToLeft Layout depending on user location. The
      problem is that if I change style with
      ModifyStyleEx(0,WS_EX_LAYOUTRTL,0);
      in "OnInitDialog" message, the child controls were already created
      and don't apply WS_EX_LAYOUTRTL style staying in their place. In a
      Modal Dialog I could handle WM_CREATE message but in modeless message
      does not seem to be generated. Any help is really appreciated.
    • johndiiix
      How are you creating the dialog? What class are you using? John
      Message 2 of 4 , Jul 8, 2008
      • 0 Attachment
        How are you creating the dialog? What class are you using?

        John

        --- In wtl@yahoogroups.com, "matmidlw" <matmidlw@...> wrote:
        >
        > I need help with Modeless Dialog. My dialog has to be in both
        > LeftToRight & RightToLeft Layout depending on user location. The
        > problem is that if I change style with
        > ModifyStyleEx(0,WS_EX_LAYOUTRTL,0);
        > in "OnInitDialog" message, the child controls were already created
        > and don't apply WS_EX_LAYOUTRTL style staying in their place. In a
        > Modal Dialog I could handle WM_CREATE message but in modeless message
        > does not seem to be generated. Any help is really appreciated.
        >
      • domehead100
        ... message ... I don t know anything about RTL layout, but since your dialog is modeless you must be calling Create, so you can supply your own Create
        Message 3 of 4 , Jul 8, 2008
        • 0 Attachment
          --- In wtl@yahoogroups.com, "matmidlw" <matmidlw@...> wrote:
          >
          > I need help with Modeless Dialog. My dialog has to be in both
          > LeftToRight & RightToLeft Layout depending on user location. The
          > problem is that if I change style with
          > ModifyStyleEx(0,WS_EX_LAYOUTRTL,0);
          > in "OnInitDialog" message, the child controls were already created
          > and don't apply WS_EX_LAYOUTRTL style staying in their place. In a
          > Modal Dialog I could handle WM_CREATE message but in modeless
          message
          > does not seem to be generated. Any help is really appreciated.
          >

          I don't know anything about RTL layout, but since your dialog is
          modeless you must be calling Create, so you can supply your own
          Create function in your CDialogImpl-derived class. The example below
          is a Create function that attempts to load the dialog template
          resource into memory, alter it to set the WS_EX_LAYOUTRTL extended
          style, then call CreateDialogIndirectParam to create the dialog. I'm
          not sure if it works, but it might :o). I looked at
          CDialogImpl::Create to get an idea of what to do, then "created" what
          is below:

          HWND Create(HWND hwndParent, LPARAM dwInitParam = NULL)
          {
          ATLASSERT(m_hWnd == NULL);
          HRSRC hDlg = ::FindResource
          (_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDD), (LPTSTR)
          RT_DIALOG);
          ATLASSERT(hDlg != NULL);
          if(hDlg == NULL)
          return NULL;

          HGLOBAL hResource = ::LoadResource
          (_AtlBaseModule.GetResourceInstance(), hDlg);
          ATLASSERT(hResource != NULL);
          if(hResource == NULL)
          return NULL;
          DLGTEMPLATEEX* pDlg = NULL;
          pDlg = (DLGTEMPLATEEX*) ::LockResource(hResource);
          ATLASSERT(pDlg != NULL);
          if(pDlg == NULL)
          return NULL;
          pDlg->exStyle |= WS_EX_LAYOUTRTL;
          _AtlWinModule.AddCreateWndData(&m_thunk.cd, this);
          HWND hWnd = ::CreateDialogIndirectParam
          (_AtlBaseModule.GetModuleInstance(), (LPDLGTEMPLATE)pDlg, hwndParent,
          StartDialogProc, dwInitParam);
          ATLASSERT(m_hWnd = hWnd);
          return hWnd;
          }

          Hope this helps.

          ~Mike
        • matmidlw
          ... below ..... Thanks Mike. Sorry for belated reply. I am using the ATL Dialog class and I will give it a try it looks good. In a couple of days I ll post my
          Message 4 of 4 , Jul 11, 2008
          • 0 Attachment
            > I don't know anything about RTL layout, but since your dialog is
            > modeless you must be calling Create, so you can supply your own
            > Create function in your CDialogImpl-derived class. The example
            below .....

            Thanks Mike. Sorry for belated reply. I am using the ATL Dialog class
            and I will give it a try it looks good. In a couple of days I'll post
            my results
          Your message has been successfully submitted and would be delivered to recipients shortly.