直接上代码void SongList::Create(HWND &hwnd, DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle,
int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
{
hwnd = CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle
, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
OldProc = (WNDPROC)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)ListBoxProc);
}。LRESULT SongList::ListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_LBUTTONDOWN:
MessageBox(NULL, "0", "1", NULL);
break;
default:
return CallWindowProc(OldProc,hwnd,uMsg,wParam,lParam);
break;
}
return 1;
}错误:类型转换问题。
error C2440: 'type cast' : cannot convert from 'long (__thiscall SongList::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast怎么整,谢谢。
int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam)
{
hwnd = CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle
, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
OldProc = (WNDPROC)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)ListBoxProc);
}。LRESULT SongList::ListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_LBUTTONDOWN:
MessageBox(NULL, "0", "1", NULL);
break;
default:
return CallWindowProc(OldProc,hwnd,uMsg,wParam,lParam);
break;
}
return 1;
}错误:类型转换问题。
error C2440: 'type cast' : cannot convert from 'long (__thiscall SongList::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast怎么整,谢谢。
把SongList::ListBoxProc的返回类型从LRESULT改为UINT试试
SetWindowLong()子类化要求的消息处理函数是__stdcall方式的.