Solved

Determining whether an HTEMPLATE is a DLGTEMPLATE* or a DLGTEMPLATEEX

Posted on 2000-04-04
2
655 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 31

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 180
tripleUp challenge 7 86
changeXy challenge 13 88
wordmultiple challenge 12 142
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 …
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

827 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