Re:having problem enumerating resources [syntax error: '__stdcall']
"rajib" <
askme@nowhere.com>wrote in message
Quote
"Jeff Partch" <jeffp@mvps.org>wrote in message
news:uOaKJwUpDHA.2416@TK2MSFTNGP10.phx.gbl...
>"rajib" <askme@nowhere.com>wrote in message
>news:QpPqb.944$U87.20404@news.uswest.net...
>>Hi Jeff,
>>
>>I tried static, and removing the cast it didn't work. Next I set the
last
>>parameter to this... that too failed. I'm lost.
>>
>>Do you have any working example?
>
>I'm sure I do in the archives, but not with me at the moment. If no one
>beats me to it -- and you can hold out that long, I'll post something
later
>tonight.
Hi Jeff,
That would be awesome. Thank you.
Rajib
Hi!
After Igor's post I don't know if this is still necessary, but I promised to
post it. Here's the relevant parts from the class/function declaration in
the *.h file...
class MyDlg : public CDialog
{
...
// Implementation
protected:
VOID ReportName(LPCTSTR lpszName);
static BOOL CALLBACK BitmapEnumProc(
HMODULE hModule, LPCTSTR lpType,
LPTSTR lpName, LONG_PTR lParam);
protected:
afx_msg void OnAppAbout();
};
...and here's the static ENUMRESNAMEPROC function's implementation...
BOOL
CALLBACK
MyDlg::BitmapEnumProc(
HMODULE hModule,
LPCTSTR lpType,
LPTSTR lpszName,
LONG_PTR lParam
)
{
MyDlg* pThis = reinterpret_cast<MyDlg*>(lParam);
if (pThis)
pThis->ReportName(lpszName);
return TRUE;
}
...and here's the non-static member function's implementation...
VOID
MyDlg::ReportName(
LPCTSTR lpszName
)
{
CString strName;
if (IS_INTRESOURCE(lpszName))
{
strName.Format(_T("Name: %u\n"),
reinterpret_cast<USHORT>(lpszName));
}
else
{
strName.Format(_T("Name: %s\n"),
lpszName);
}
AfxMessageBox(strName);
}
...and here's the reimplementation of your invocation procedure...
void MyDlg::OnAppAbout()
{
CAboutDlg aboutDlg;
LONG_PTR lParam = reinterpret_cast<
LONG_PTR>(this);
EnumResourceNames(
NULL,
RT_BITMAP,
BitmapEnumProc,
lParam );
aboutDlg.DoModal();
}
Sorry it took a while.
--
Jeff Partch [VC++ MVP]
-