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 long int ( )(HWND__*, unsigned int, long long unsigned int, long long int)'} 轉換為 'LONG' {aka 'long int'} 失去精度 [-fpermissive] 21 | LONG tmp = SetWindowLongW(pix.getWnd(), GWLP_WNDPROC, (LONG)wndProcNew);
我究竟做錯了什么?
uj5u.com熱心網友回復:
在 64 位 Microsoft Windows 上,指標(包括函式指標)的大小為 64 位,而型別變數longorLONG的大小為 32 位。因此,該大小的變數無法表示指標的值。
如果要設定 64 位值,我建議您使用SetWindowLongPtr而不是SetWindowLong.
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/468952.html
上一篇:寫入FILE以通過USART傳輸
