• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 708
  • Last Modified:

Determining whether an HTEMPLATE is a DLGTEMPLATE* or a DLGTEMPLATEEX

Hi,

I have a Create method for my dialog, called CreateHidden(), which is used to insert dialogs into a tab control. Before calling CreateIndirect(), I am changing some styls, but the code is different when having extended styles than when not having extended styles. How can I determine whether the HTEMPLATE is extended (DLGTEMPLATEEX)or not (DLGTEMPLATE)?

The code of CreateHidden() is as follows:

BOOL CTemplateTab::CreateHidden(UINT id, CWnd *pParent)
{
      LPCTSTR lpszTemplateName = MAKEINTRESOURCE(id);
      ASSERT(HIWORD(lpszTemplateName) == 0 ||
            AfxIsValidString(lpszTemplateName));

      m_lpszTemplateName = lpszTemplateName;  // used for help
      if (HIWORD(m_lpszTemplateName) == 0 && m_nIDHelp == 0)
            m_nIDHelp = LOWORD((DWORD)m_lpszTemplateName);

      HINSTANCE hInst = AfxGetResourceHandle();
      HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
      HGLOBAL hTemplate = LoadResource( hInst, hResource );
      DLGTEMPLATE* pTemplate = (DLGTEMPLATE*)hTemplate;
      DLGTEMPLATEEX* pTemplateEx = (DLGTEMPLATEEX*)hTemplate;
      BOOL bExStyle = (???);  // **** HOW DO I DO THIS ???
      if (bExStyle)
      { // Extended style
            [...]
      }
      else
      { // Non-extended style
            [...]
      }
      BOOL bResult = CreateIndirect( hTemplate, pParent, hInst );
      FreeResource(hTemplate);
      return bResult;
}
0
Brian_HP
Asked:
Brian_HP
1 Solution
 
ZoppoCommented:
Hi Brian_HP,

this is from MSDN help about DLGTEMPLATEEX's member 'signature':

-----------------------------------------------------------------------------------------------------------
signature

Indicates whether a template is an extended dialog box template. A value of 0xFFFF indicates an extended dialog box template. In this case, the dlgVer member specifies the template version number. If signature is any value other than 0xFFFF, this is a standard template that uses the DLGTEMPLATE and DLGITEMTEMPLATE structures.
------------------------------------------------------------------------------------------------------------

so, simply cast to DLGTEMPLATEEX and if its 'signature' isn't 0xFFFF cast it to DLGTEMPLATE.

hope that helps,

ZOPPO
0
 
Brian_HPAuthor Commented:
Hi Zoppo,

Thanks for your help. Actually, this was also the way I solved it, except that I wasn't sure whether this was "the best" solution or not.  Next time I should maybe read the whole the help text, I am viewing :)

Brian
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now