First bug (the one which implies a syntax error): You can't define a new variable inside an expression (BTW, you would not be able to access the variable in following statements):
It should be:Code:EnumWindows((WNDENUMPROC) EnumProc,vector<CMyClass*> arMyClass);
Second bug: You don't declare EnumProc with the correct prototype. Behavior is undefined for the C++ standard, even though with the current Win32 CALLBACK calling convention, it's likely to not work too bad.Code:vector<CMyClass*> arMyClass; EnumWindows(EnumProc,reinterpret_cast<LPARAM>(&arMyClass));
Moreover, you define EnumProc with a value vector<CMyClass*> parameter (you forgot the & character).
If you want to avoid calling conventions issues under Win64, you should respect the prototype:
Code:BOOL CALLBACK EnumProc(HWND thwnd,LPARAM); // declarationDo you really need a dynamic allocation for CMyClass objects? Would not a vector<CMyClass> work as well?Code:BOOL CALLBACK EnumProc(HWND thwnd,LPARAM lParam) { // definition vector<CMyClass*> &l=*reinterpret_cast<vector<CMyClass*>*>(lParam); // your code }
Why does CMyClass have a virtual destructor? It has no other virtual function. Do you derive from it?




Reply With Quote