Solved

Determining whether an HTEMPLATE is a DLGTEMPLATE* or a DLGTEMPLATEEX

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
Expand LInux Boot partition remotly 3 90
Host to IP 7 78
Unix Command -- Challenging  question 7 88
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

12 Experts available now in Live!

Get 1:1 Help Now