Solved

Determining whether an HTEMPLATE is a DLGTEMPLATE* or a DLGTEMPLATEEX

Posted on 2000-04-04
2
642 Views
Last Modified: 2013-11-20
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
Comment
Question by:Brian_HP
2 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 50 total points
ID: 2683248
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
 

Author Comment

by:Brian_HP
ID: 2683292
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now