static LRESULT CALLBACK wndProcNew(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
int CALLBACK wWinMain(HINSTANCE hInst,HINSTANCE,PWSTR szcmdLine,int cmdShow){
using namespace std;
Pixel pix;
LONG tmp = SetWindowLong(pix.getWnd(), GWLP_WNDPROC, (LONG)wndProcNew);
return 0;
}我想改变窗口程序。mingw抛出一个错误:
错误:从'LRESULT ()(HWND,UINT,WPARAM,LPARAM)‘{aka 'long int ()(HWND__*,无符号int,长无符号int,long int)}到’LRESULT(aka 'long int'} ' long‘{aka’long int‘}-丢失了精度为-fpermissive 21的长tmp = SetWindowLongW(pix.getWnd(),GWLP_WNDPROC,( long )wndProcNew);
我做错什么了?
发布于 2022-04-30 12:26:42
在64位Microsoft上,指针(包括函数指针)的大小为64位,而long或LONG类型的变量的大小为32位。因此,该大小的变量无法表示指针的值。
如果您想设置64位值,我建议您使用SetWindowLongPtr而不是SetWindowLong。
https://stackoverflow.com/questions/72068465
复制相似问题