From 0617c9d3e7595c7f5c50571b07963134535197d2 Mon Sep 17 00:00:00 2001 From: anders_k Date: Sat, 19 Nov 2011 15:41:45 +0000 Subject: [PATCH] Changed SetWindowLong to SetWindowLongPtr and removed WNDPROC related casts git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6180 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/AdvSplash/advsplash.c | 2 +- Contrib/Banner/Banner.c | 2 +- Contrib/BgImage/BgImage.cpp | 14 +++-------- Contrib/InstallOptions/InstallerOptions.cpp | 28 ++++++++++----------- Contrib/NSISdl/nsisdl.cpp | 16 ++++-------- Contrib/Splash/splash.c | 2 +- Contrib/StartMenu/StartMenu.c | 16 ++++++------ Contrib/nsDialogs/nsDialogs.c | 8 +++--- Source/exehead/Ui.c | 12 ++++----- Source/exehead/exec.c | 2 +- 10 files changed, 45 insertions(+), 57 deletions(-) diff --git a/Contrib/AdvSplash/advsplash.c b/Contrib/AdvSplash/advsplash.c index c441f200..5e1b133d 100644 --- a/Contrib/AdvSplash/advsplash.c +++ b/Contrib/AdvSplash/advsplash.c @@ -37,7 +37,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, switch (uMsg) { case WM_CREATE: SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); - SetWindowLong(hwnd, GWL_STYLE, 0); + SetWindowLongPtr(hwnd, GWL_STYLE, 0); SetWindowPos(hwnd, NULL, r.left + (r.right - r.left - bm.bmWidth) / 2, r.top + (r.bottom - r.top - bm.bmHeight) / 2, diff --git a/Contrib/Banner/Banner.c b/Contrib/Banner/Banner.c index 3fc1824f..71300975 100644 --- a/Contrib/Banner/Banner.c +++ b/Contrib/Banner/Banner.c @@ -36,7 +36,7 @@ BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) SetDlgItemText(hwndDlg, IDC_STR, buf); if (!*buf) - SetWindowLong(hwndDlg, GWL_EXSTYLE, GetWindowLong(hwndDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW); + SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW); } if (uMsg == WM_CLOSE) { diff --git a/Contrib/BgImage/BgImage.cpp b/Contrib/BgImage/BgImage.cpp index b564d301..dc77c93b 100644 --- a/Contrib/BgImage/BgImage.cpp +++ b/Contrib/BgImage/BgImage.cpp @@ -57,7 +57,7 @@ struct myImageList { unsigned int uWndWidth, uWndHeight; -void *oldProc; +WNDPROC oldProc; LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); HBITMAP __stdcall LoadBitmapFile(long right, long bottom, BITMAP *bBitmap); COLORREF GetColor(); @@ -151,7 +151,7 @@ NSISFunc(SetBg) { return; } - oldProc = (void *)SetWindowLong(hwndParent, GWL_WNDPROC, (long)WndProc); + oldProc = (WNDPROC)SetWindowLongPtr(hwndParent, GWLP_WNDPROC, (LONG_PTR)WndProc); } bgBitmap.bReady = FALSE; @@ -347,7 +347,7 @@ NSISFunc(Clear) { NSISFunc(Destroy) { bgBitmap.bReady = FALSE; if (IsWindow(hwndParent) && oldProc) - SetWindowLong(hwndParent, GWL_WNDPROC, (long)oldProc); + SetWindowLongPtr(hwndParent, GWLP_WNDPROC, (LONG_PTR)oldProc); if (IsWindow(hWndImage)) SendMessage(hWndImage, WM_CLOSE, 0, 0); hWndImage = 0; @@ -387,13 +387,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (message == WM_WINDOWPOSCHANGED) { SetWindowPos(hwndImage, hwndParent, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } - return CallWindowProc( - (long (__stdcall *)(HWND,unsigned int,unsigned int,long))oldProc, - hwnd, - message, - wParam, - lParam - ); + return CallWindowProc(oldProc, hwnd, message, wParam, lParam); } switch (message) { case WM_PAINT: diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp index 6aff2ff8..d6a052a1 100644 --- a/Contrib/InstallOptions/InstallerOptions.cpp +++ b/Contrib/InstallOptions/InstallerOptions.cpp @@ -141,13 +141,13 @@ struct FieldType { HWND hwnd; UINT nControlID; - int nParentIdx; // this is used to store original windowproc for LINK + INT_PTR nParentIdx; // this is used to store original windowproc for LINK HANDLE hImage; // this is used by image/icon field to save the handle to the image int nField; // field number in INI file const TCHAR *pszHwndEntry; // "HWND" or "HWND2" - long wndProc; + WNDPROC wndProc; }; // initial buffer size. buffers will grow as required. @@ -702,13 +702,13 @@ LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) } -static void *lpWndProcOld; +static WNDPROC lpWndProcOld; int g_is_cancel,g_is_back; -BOOL CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - BOOL bRes; + INT_PTR bRes; if (message == WM_NOTIFY_OUTER_NEXT && wParam == 1) { // Don't call leave function if fields aren't valid @@ -719,7 +719,7 @@ BOOL CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara // Reset the record of activated control g_NotifyField = 0; } - bRes = CallWindowProc((long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long))lpWndProcOld,hwnd,message,wParam,lParam); + bRes = CallWindowProc(lpWndProcOld,hwnd,message,wParam,lParam); if (message == WM_NOTIFY_OUTER_NEXT && !bRes) { // if leave function didn't abort (bRes != 0 in that case) @@ -733,7 +733,7 @@ BOOL CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara return bRes; } -BOOL CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { @@ -776,7 +776,7 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (lpdis->itemAction & ODA_DRAWENTIRE) { // Get TxtColor unless the user has set another using SetCtlColors - if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA)) + if (!GetWindowLongPtr(lpdis->hwndItem, GWLP_USERDATA)) SetTextColor(lpdis->hDC, (COLORREF) pField->hImage); // Draw the text @@ -921,7 +921,7 @@ int WINAPI NumbersOnlyPasteWndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM l } } - return CallWindowProc((WNDPROC) pField->wndProc, hWin, uMsg, wParam, lParam); + return CallWindowProc(pField->wndProc, hWin, uMsg, wParam, lParam); } int old_cancel_visible; @@ -1225,8 +1225,8 @@ int WINAPI createCfgDlg() mySendMessage(hwCtrl, EM_LIMITTEXT, (WPARAM)pField->nMaxLength, (LPARAM)0); if (dwStyle & ES_NUMBER) { - pField->wndProc = GetWindowLong(hwCtrl, GWL_WNDPROC); - SetWindowLong(hwCtrl, GWL_WNDPROC, (long) NumbersOnlyPasteWndProc); + pField->wndProc = (WNDPROC) GetWindowLongPtr(hwCtrl, GWLP_WNDPROC); + SetWindowLongPtr(hwCtrl, GWLP_WNDPROC, (LONG_PTR) NumbersOnlyPasteWndProc); } break; @@ -1408,7 +1408,7 @@ int WINAPI createCfgDlg() #ifdef IO_ENABLE_LINK case FIELD_LINK: - pField->nParentIdx = SetWindowLong(hwCtrl, GWL_WNDPROC, (long)StaticLINKWindowProc); + pField->nParentIdx = (INT_PTR) SetWindowLongPtr(hwCtrl, GWLP_WNDPROC, (LONG_PTR)StaticLINKWindowProc); break; #endif } @@ -1446,7 +1446,7 @@ int WINAPI createCfgDlg() void WINAPI showCfgDlg() { - lpWndProcOld = (void *) SetWindowLong(hMainWindow,DWL_DLGPROC,(long)ParentWndProc); + lpWndProcOld = (WNDPROC) SetWindowLongPtr(hMainWindow,DWLP_DLGPROC,(LONG_PTR)ParentWndProc); // Tell NSIS to remove old inner dialog and pass handle of the new inner dialog mySendMessage(hMainWindow, WM_NOTIFY_CUSTOM_READY, (WPARAM)hConfigWindow, 0); @@ -1468,7 +1468,7 @@ void WINAPI showCfgDlg() // quit soon, which means the ini might get flushed late and cause crap. :) anwyay. if (!g_is_cancel) SaveSettings(); - SetWindowLong(hMainWindow,DWL_DLGPROC,(long)lpWndProcOld); + SetWindowLongPtr(hMainWindow,DWLP_DLGPROC,(LONG_PTR)lpWndProcOld); DestroyWindow(hConfigWindow); // by ORTIM: 13-August-2002 diff --git a/Contrib/NSISdl/nsisdl.cpp b/Contrib/NSISdl/nsisdl.cpp index fa26c85c..5e762bb0 100644 --- a/Contrib/NSISdl/nsisdl.cpp +++ b/Contrib/NSISdl/nsisdl.cpp @@ -41,7 +41,7 @@ HMODULE hModule; HWND g_hwndProgressBar; HWND g_hwndStatic; static int g_cancelled; -static void *lpWndProcOld; +static WNDPROC lpWndProcOld; static UINT uMsgCreate; @@ -100,7 +100,7 @@ static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP ); DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS; - dwStyle |= GetWindowLong(hwndP, GWL_STYLE) & PBS_SMOOTH; + dwStyle |= GetWindowLongPtr(hwndP, GWL_STYLE) & PBS_SMOOTH; GetWindowRect(hwndP, &ctlRect); @@ -182,13 +182,7 @@ static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LP } else { - return CallWindowProc( - (WNDPROC) lpWndProcOld, - hwnd, - message, - wParam, - lParam - ); + return CallWindowProc(lpWndProcOld, hwnd, message, wParam, lParam); } return 0; } @@ -346,7 +340,7 @@ __declspec(dllexport) void download (HWND parent, { uMsgCreate = RegisterWindowMessage(_T("nsisdl create")); - lpWndProcOld = (void *)SetWindowLong(parent,GWL_WNDPROC,(long)ParentWndProc); + lpWndProcOld = (WNDPROC)SetWindowLongPtr(parent,GWLP_WNDPROC,(LONG_PTR)ParentWndProc); SendMessage(parent, uMsgCreate, TRUE, (LPARAM) parent); @@ -420,7 +414,7 @@ __declspec(dllexport) void download (HWND parent, if (parent) { SendMessage(parent, uMsgCreate, FALSE, (LPARAM) parent); - SetWindowLong(parent, GWL_WNDPROC, (long)lpWndProcOld); + SetWindowLongPtr(parent, GWLP_WNDPROC, (LONG_PTR)lpWndProcOld); } break; } diff --git a/Contrib/Splash/splash.c b/Contrib/Splash/splash.c index 38e23693..0b22fb80 100644 --- a/Contrib/Splash/splash.c +++ b/Contrib/Splash/splash.c @@ -15,7 +15,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar RECT vp; GetObject(g_hbm, sizeof(bm), &bm); SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0); - SetWindowLong(hwnd,GWL_STYLE,0); + SetWindowLongPtr(hwnd,GWL_STYLE,0); SetWindowPos(hwnd,NULL, vp.left+(vp.right-vp.left-bm.bmWidth)/2, vp.top+(vp.bottom-vp.top-bm.bmHeight)/2, diff --git a/Contrib/StartMenu/StartMenu.c b/Contrib/StartMenu/StartMenu.c index 39db5817..5f7bc3db 100644 --- a/Contrib/StartMenu/StartMenu.c +++ b/Contrib/StartMenu/StartMenu.c @@ -21,7 +21,7 @@ int g_done; int noicon; int rtl; -void *lpWndProcOld; +WNDPROC lpWndProcOld; void (__stdcall *validate_filename)(TCHAR *); @@ -120,7 +120,7 @@ void __declspec(dllexport) Init(HWND hwndParent, int string_size, TCHAR *variabl } else { - lpWndProcOld = (void *) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentWndProc); + lpWndProcOld = (WNDPROC) SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (LONG_PTR) ParentWndProc); wsprintf(buf, _T("%u"), hwStartMenuSelect); pushstring(buf); } @@ -145,7 +145,7 @@ void __declspec(dllexport) Show(HWND hwndParent, int string_size, TCHAR *variabl } DestroyWindow(hwStartMenuSelect); - SetWindowLong(hwndParent, DWL_DLGPROC, (long) lpWndProcOld); + SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (LONG_PTR) lpWndProcOld); } void __declspec(dllexport) Select(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) @@ -160,7 +160,7 @@ void __declspec(dllexport) Select(HWND hwndParent, int string_size, TCHAR *varia static BOOL CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - BOOL bRes = CallWindowProc((long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long))lpWndProcOld,hwnd,message,wParam,lParam); + BOOL bRes = CallWindowProc(lpWndProcOld,hwnd,message,wParam,lParam); if (message == WM_NOTIFY_OUTER_NEXT && !bRes) { // if leave function didn't abort (lRes != 0 in that case) @@ -173,10 +173,10 @@ void AddRTLStyle(HWND hWnd, long dwStyle) { long s; - s = GetWindowLong(hWnd, GWL_STYLE); - SetWindowLong(hWnd, GWL_STYLE, s | dwStyle); - s = GetWindowLong(hWnd, GWL_EXSTYLE); - SetWindowLong(hWnd, GWL_EXSTYLE, s | WS_EX_RIGHT | WS_EX_RTLREADING); + s = GetWindowLongPtr(hWnd, GWL_STYLE); + SetWindowLongPtr(hWnd, GWL_STYLE, s | dwStyle); + s = GetWindowLongPtr(hWnd, GWL_EXSTYLE); + SetWindowLongPtr(hWnd, GWL_EXSTYLE, s | WS_EX_RIGHT | WS_EX_RTLREADING); } #define ProgressiveSetWindowPos(hwWindow, x, cx, cy) \ diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c index dd799292..922f2cbc 100644 --- a/Contrib/nsDialogs/nsDialogs.c +++ b/Contrib/nsDialogs/nsDialogs.c @@ -196,7 +196,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) xtraDrawStyle |= DT_HIDEPREFIX; // Use blue unless the user has set another using SetCtlColors - if (!GetWindowLong(lpdis->hwndItem, GWL_USERDATA)) + if (!GetWindowLongPtr(lpdis->hwndItem, GWLP_USERDATA)) SetTextColor(lpdis->hDC, RGB(0,0,255)); // Draw the text @@ -278,7 +278,7 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, TCHAR *varia SWP_NOZORDER | SWP_NOACTIVATE ); - g_dialog.parentOriginalWndproc = (WNDPROC) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentProc); + g_dialog.parentOriginalWndproc = (WNDPROC) SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (LONG_PTR) ParentProc); g_dialog.rtl = FALSE; @@ -389,7 +389,7 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, TCHAR // set the WndProc for the link control if(g_dialog.controls[id].type == NSCTL_LINK) - g_dialog.controls[id].oldWndProc = (WNDPROC) SetWindowLong(hwItem, GWL_WNDPROC, (long) LinkWndProc); + g_dialog.controls[id].oldWndProc = (WNDPROC) SetWindowLongPtr(hwItem, GWLP_WNDPROC, (LONG_PTR) LinkWndProc); // push back result @@ -590,7 +590,7 @@ void __declspec(dllexport) Show(HWND hwndParent, int string_size, TCHAR *variabl // reset wndproc - SetWindowLong(hwndParent, DWL_DLGPROC, (long) g_dialog.parentOriginalWndproc); + SetWindowLongPtr(hwndParent, DWLP_DLGPROC, (LONG_PTR) g_dialog.parentOriginalWndproc); } BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 30fa927c..55295a17 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -123,7 +123,7 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara { if ((uMsg - WM_CTLCOLOREDIT) <= (WM_CTLCOLORSTATIC - WM_CTLCOLOREDIT)) { - ctlcolors *c = (ctlcolors *)GetWindowLong((HWND)lParam, GWL_USERDATA); + ctlcolors *c = (ctlcolors *)GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); if (c) { COLORREF text; @@ -653,7 +653,7 @@ skipPage: } if (uMsg == WM_QUERYENDSESSION) { - SetWindowLong(hwndDlg, DWL_MSGRESULT, FALSE); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, FALSE); return TRUE; } if (uMsg == WM_COMMAND) @@ -1232,7 +1232,7 @@ int NSISCALL TreeGetSelectedSection(HWND tree, BOOL mouse) return (int) item.lParam; } -static LONG oldTreeWndProc; +static WNDPROC oldTreeWndProc; static LPARAM last_selected_tree_item; static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -1264,7 +1264,7 @@ static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l } } #endif//NSIS_SUPPORT_CODECALLBACKS && NSIS_CONFIG_ENHANCEDUI_SUPPORT - return CallWindowProc((WNDPROC)oldTreeWndProc,hwnd,uMsg,wParam,lParam); + return CallWindowProc(oldTreeWndProc,hwnd,uMsg,wParam,lParam); } static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -1290,7 +1290,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar hBMcheck1=LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1)); last_selected_tree_item=-1; - oldTreeWndProc=SetWindowLong(hwndTree1,GWL_WNDPROC,(long)newTreeWndProc); + oldTreeWndProc=(WNDPROC)SetWindowLongPtr(hwndTree1,GWLP_WNDPROC,(LONG_PTR)newTreeWndProc); hImageList = ImageList_Create(16,16, ILC_COLOR32|ILC_MASK, 6, 0); ImageList_AddMasked(hImageList,hBMcheck1,RGB(255,0,255)); @@ -1358,7 +1358,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if (!doLines) { - SetWindowLong(hwndTree1,GWL_STYLE,GetWindowLong(hwndTree1,GWL_STYLE)&~(TVS_LINESATROOT)); + SetWindowLongPtr(hwndTree1,GWL_STYLE,GetWindowLongPtr(hwndTree1,GWL_STYLE)&~(TVS_LINESATROOT)); } if (!noCombo) diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 3f6c55a6..51e3e08c 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -799,7 +799,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) case EW_SETCTLCOLORS: { ctlcolors *c = (ctlcolors *)(g_blocks[NB_CTLCOLORS].offset + parm1); - SetWindowLong((HWND) GetIntFromParm(0), GWL_USERDATA, (long) c); + SetWindowLongPtr((HWND) GetIntFromParm(0), GWLP_USERDATA, (LONG_PTR) c); } break; case EW_SETBRANDINGIMAGE: