在VS2010 C#中 ,子类化SysListView32,SysTreeView32等通用控件报错(Button,Edit等标准控件正常)。WndProc oldProc;void WinMain()
{
IntPtr hWnd = CreateWindowEx(0,"SysListView32",...); oldProc = SetWindowLong(hWnd, GWL_WNDPROC, MyWndProc);//传递给运行时且要转换为委托的函数指针 0xffff039d 无效。传递要转换为委托的无效函数指针会导致崩溃、损坏或数据丢失。
}IntPtr MyWndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
{
return CallWindowProc(oldProc, hWnd, msg, wParam, lParam);
}在CodeBlocks中, 没有问题。long oldProc;pProc = SetWindowLong(hwndListView, GWL_WNDPROC, (long)ListViewWndProc);LRESULT CALLBACK MyWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return CallWindowProc((WNDPROC)pProc, hwnd, message, wParam, lParam);
}我想知道在C#调用SetWindowLong(hWnd, GWL_WNDPROC, MyWndProc)报错的问题怎么解决啊?注意我指的是SysListView32和SysTreeView32等通用控件。
{
IntPtr hWnd = CreateWindowEx(0,"SysListView32",...); oldProc = SetWindowLong(hWnd, GWL_WNDPROC, MyWndProc);//传递给运行时且要转换为委托的函数指针 0xffff039d 无效。传递要转换为委托的无效函数指针会导致崩溃、损坏或数据丢失。
}IntPtr MyWndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
{
return CallWindowProc(oldProc, hWnd, msg, wParam, lParam);
}在CodeBlocks中, 没有问题。long oldProc;pProc = SetWindowLong(hwndListView, GWL_WNDPROC, (long)ListViewWndProc);LRESULT CALLBACK MyWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return CallWindowProc((WNDPROC)pProc, hwnd, message, wParam, lParam);
}我想知道在C#调用SetWindowLong(hWnd, GWL_WNDPROC, MyWndProc)报错的问题怎么解决啊?注意我指的是SysListView32和SysTreeView32等通用控件。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货