Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FindResourceEx and CreateDialogParam

Status
Not open for further replies.

RGeorg

Programmer
Feb 1, 2007
6
US
I am loading multiple language resources and the strings load properly. I am having a problem getting the dialog identifiers. Here is the code:
Code:

LPCTSTR get_dialog(int nResID)
{
LPCTSTR ptcBlock;
HGLOBAL hg;
HRSRC hResourceInfoBlock;
LPCTSTR szTemplate = MAKEINTRESOURCE(nResID);
if( // use methods until we find one that works
(NULL != (hResourceInfoBlock = FindResourceEx( hInstGlobal, RT_DIALOG, szTemplate, GetUserDefaultLangID()))) ||
(NULL != (hResourceInfoBlock = FindResourceEx( hInstGlobal, RT_DIALOG, szTemplate, GetSystemDefaultLangID()))) ||
(NULL != (hResourceInfoBlock = FindResourceEx( hInstGlobal, RT_DIALOG, szTemplate, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ))))
)
{
;
}
//
if( hResourceInfoBlock )
{
if(
(NULL != (hg = LoadResource( hInstGlobal, hResourceInfoBlock ))) &&
(NULL != (ptcBlock = (char*)LockResource(hg))) )
{
return ptcBlock;
}
}
return 0;
}
The result should be fed into CreateDialogParam as a dialog ID

Code:

lpDialog = get_dialog(MAKEINTRESOURCE(IDD_MAIN));
hDlg = CreateDialogParam(hInstance, lpDialog,
hWndParent, (DLGPROC)DlgProc, (LPARAM)this);
Please take a look and see what am I doing wrong.

Thanks
 
Could it be the problem you are using the macro MAKEINTRESOURCE twice?

first : lpDialog = get_dialog (MAKEINTRESOURCE(IDD_MAIN));
second : LPCTSTR szTemplate = MAKEINTRESOURCE(nResID);



Marcel
 
Thanks,

MAKEINTRESOURCE indeed was causing trouble.
I ended up overriding CreateDialogParam to use the template handle with CreateDialogIndirectParam which yielded the proper result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top