Board index » Visual Studio » having problem enumerating resources [syntax error: '__stdcall']

having problem enumerating resources [syntax error: '__stdcall']

Visual Studio159
Hi,



I am having problem with line 13. It gives me syntax error saying

'__stdcall'. I am trying to find all the bitmap resource that current

application uses. I can't find a good doc. or relevant posting that

discussed this. Please let me know what I'm doing wrong. Thanks in advance.



Rajib



01. BOOL CALLBACK MyDlg::BitmapEnumProc(HMODULE hModule, LPCSTR lpszType,

02. LPSTR lpszName, LONG_PTR lParam)

03. {

04. AfxMessageBox(lpszName);

05. return TRUE;

06. }

07.

08. void MyDlg::OnAboutApp()

09. {

10. CAboutDlg aboutDlg;

11. LONG_PTR lParam=0;

12. //////// getting error on this function call

13. EnumResourceNames(NULL, RT_BITMAP, (CALLBACK*

ENUMRESNAMEPROCA)BitmapEnumProc, lParam);

14. aboutDlg.DoModal();

15. }


-
 

Re:having problem enumerating resources [syntax error: '__stdcall']

A cast on the ENUMRESNAMESPROC argument shouldn't be necessary AFAIK. If

it's not already, make the 'BitmapEnumProc' a static member function. If

you need to, you can pass the 'this' pointer as the LPARAM.

--

Jeff Partch [VC++ MVP]



"rajib" <askme@nowhere.com>wrote in message

Quote
Hi,



I am having problem with line 13. It gives me syntax error saying

'__stdcall'. I am trying to find all the bitmap resource that current

application uses. I can't find a good doc. or relevant posting that

discussed this. Please let me know what I'm doing wrong. Thanks in

advance.



Rajib



01. BOOL CALLBACK MyDlg::BitmapEnumProc(HMODULE hModule, LPCSTR

lpszType,

02. LPSTR lpszName, LONG_PTR lParam)

03. {

04. AfxMessageBox(lpszName);

05. return TRUE;

06. }

07.

08. void MyDlg::OnAboutApp()

09. {

10. CAboutDlg aboutDlg;

11. LONG_PTR lParam=0;

12. //////// getting error on this function call

13. EnumResourceNames(NULL, RT_BITMAP, (CALLBACK*

ENUMRESNAMEPROCA)BitmapEnumProc, lParam);

14. aboutDlg.DoModal();

15. }









-

Re:having problem enumerating resources [syntax error: '__stdcall']

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?



Thanks again,

Rajib



"Jeff Partch [MVP]" <jeffp@mvps.org>wrote in message

Quote
A cast on the ENUMRESNAMESPROC argument shouldn't be necessary AFAIK. If

it's not already, make the 'BitmapEnumProc' a static member function. If

you need to, you can pass the 'this' pointer as the LPARAM.

--

Jeff Partch [VC++ MVP]



"rajib" <askme@nowhere.com>wrote in message

news:67Pqb.935$U87.19354@news.uswest.net...

>Hi,

>

>I am having problem with line 13. It gives me syntax error saying

>'__stdcall'. I am trying to find all the bitmap resource that current

>application uses. I can't find a good doc. or relevant posting that

>discussed this. Please let me know what I'm doing wrong. Thanks in

advance.

>

>Rajib

>

>01. BOOL CALLBACK MyDlg::BitmapEnumProc(HMODULE hModule, LPCSTR

lpszType,

>02. LPSTR lpszName, LONG_PTR lParam)

>03. {

>04. AfxMessageBox(lpszName);

>05. return TRUE;

>06. }

>07.

>08. void MyDlg::OnAboutApp()

>09. {

>10. CAboutDlg aboutDlg;

>11. LONG_PTR lParam=0;

>12. //////// getting error on this function call

>13. EnumResourceNames(NULL, RT_BITMAP, (CALLBACK*

>ENUMRESNAMEPROCA)BitmapEnumProc, lParam);

>14. aboutDlg.DoModal();

>15. }

>

>









-

Re:having problem enumerating resources [syntax error: '__stdcall']

"rajib" <askme@nowhere.com>wrote in message

Quote
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.

--

Jeff Partch [VC++ MVP]





-

Re:having problem enumerating resources [syntax error: '__stdcall']

Hi Jeff,



That would be awesome. Thank you.



Rajib



"Jeff Partch" <jeffp@mvps.org>wrote in message

Quote
"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.

--

Jeff Partch [VC++ MVP]









-

Re:having problem enumerating resources [syntax error: '__stdcall']

It should have. Something like this:



class MyDlg

{

static BOOL CALLBACK BitmapEnumProc(HMODULE hModule, LPCTSTR

lpszType,

LPTSTR lpszName, LONG_PTR lParam);

};



EnumResourceNames(NULL, RT_BITMAP, BitmapEnumProc,

reinterpret_cast<LONG_PTR>(this));



--

With best wishes,

Igor Tandetnik



"For every complex problem, there is a solution that is simple, neat,

and wrong." H.L. Mencken





"rajib" <askme@nowhere.com>wrote in message

Quote
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?



Thanks again,

Rajib



"Jeff Partch [MVP]" <jeffp@mvps.org>wrote in message

news:%2347F1dUpDHA.488@tk2msftngp13.phx.gbl...

>A cast on the ENUMRESNAMESPROC argument shouldn't be necessary

AFAIK. If

>it's not already, make the 'BitmapEnumProc' a static member

function. If

>you need to, you can pass the 'this' pointer as the LPARAM.

>--

>Jeff Partch [VC++ MVP]

>

>"rajib" <askme@nowhere.com>wrote in message

>news:67Pqb.935$U87.19354@news.uswest.net...

>>Hi,

>>

>>I am having problem with line 13. It gives me syntax error saying

>>'__stdcall'. I am trying to find all the bitmap resource that

current

>>application uses. I can't find a good doc. or relevant posting

that

>>discussed this. Please let me know what I'm doing wrong. Thanks in

>advance.

>>

>>Rajib

>>

>>01. BOOL CALLBACK MyDlg::BitmapEnumProc(HMODULE hModule, LPCSTR

>lpszType,

>>02. LPSTR lpszName, LONG_PTR lParam)

>>03. {

>>04. AfxMessageBox(lpszName);

>>05. return TRUE;

>>06. }

>>07.

>>08. void MyDlg::OnAboutApp()

>>09. {

>>10. CAboutDlg aboutDlg;

>>11. LONG_PTR lParam=0;

>>12. //////// getting error on this function call

>>13. EnumResourceNames(NULL, RT_BITMAP, (CALLBACK*

>>ENUMRESNAMEPROCA)BitmapEnumProc, lParam);

>>14. aboutDlg.DoModal();

>>15. }

>>

>>

>

>









-

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]





-