1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-02-09 16:36:34 +00:00

Use {Get,Set}WindowLongPtr() instead of {Get,Set}WindowLong() for compatibility

with 64-bit Windows. Untested on 64-bit, but it doesn't appear to have broken
anything on 32-bit.

[originally from svn r5819]
This commit is contained in:
Jacob Nevins 2005-05-21 14:16:43 +00:00
parent 9cde5fa319
commit 26635548e8
6 changed files with 42 additions and 39 deletions

View File

@ -1050,7 +1050,7 @@ int handle_prefslist(struct prefslist *hdl,
hdl->srcitem = LBItemFromPt(dlm->hWnd, dlm->ptCursor, TRUE); hdl->srcitem = LBItemFromPt(dlm->hWnd, dlm->ptCursor, TRUE);
hdl->dragging = 0; hdl->dragging = 0;
/* XXX hack Q183115 */ /* XXX hack Q183115 */
SetWindowLong(hwnd, DWL_MSGRESULT, TRUE); SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
ret |= 1; break; ret |= 1; break;
case DL_CANCELDRAG: case DL_CANCELDRAG:
DrawInsert(hwnd, dlm->hWnd, -1); /* Clear arrow */ DrawInsert(hwnd, dlm->hWnd, -1); /* Clear arrow */
@ -1064,9 +1064,9 @@ int handle_prefslist(struct prefslist *hdl,
if (dest > hdl->dummyitem) dest = hdl->dummyitem; if (dest > hdl->dummyitem) dest = hdl->dummyitem;
DrawInsert (hwnd, dlm->hWnd, dest); DrawInsert (hwnd, dlm->hWnd, dest);
if (dest >= 0) if (dest >= 0)
SetWindowLong(hwnd, DWL_MSGRESULT, DL_MOVECURSOR); SetWindowLongPtr(hwnd, DWLP_MSGRESULT, DL_MOVECURSOR);
else else
SetWindowLong(hwnd, DWL_MSGRESULT, DL_STOPCURSOR); SetWindowLongPtr(hwnd, DWLP_MSGRESULT, DL_STOPCURSOR);
ret |= 1; break; ret |= 1; break;
case DL_DROPPED: case DL_DROPPED:
if (hdl->dragging) { if (hdl->dragging) {

View File

@ -240,7 +240,7 @@ static int SaneDialogBox(HINSTANCE hinst,
wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW; wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW;
wc.lpfnWndProc = DefDlgProc; wc.lpfnWndProc = DefDlgProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = DLGWINDOWEXTRA + 8; wc.cbWndExtra = DLGWINDOWEXTRA + 2*sizeof(LONG_PTR);
wc.hInstance = hinst; wc.hInstance = hinst;
wc.hIcon = NULL; wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
@ -251,11 +251,11 @@ static int SaneDialogBox(HINSTANCE hinst,
hwnd = CreateDialog(hinst, tmpl, hwndparent, lpDialogFunc); hwnd = CreateDialog(hinst, tmpl, hwndparent, lpDialogFunc);
SetWindowLong(hwnd, BOXFLAGS, 0); /* flags */ SetWindowLongPtr(hwnd, BOXFLAGS, 0); /* flags */
SetWindowLong(hwnd, BOXRESULT, 0); /* result from SaneEndDialog */ SetWindowLongPtr(hwnd, BOXRESULT, 0); /* result from SaneEndDialog */
while ((gm=GetMessage(&msg, NULL, 0, 0)) > 0) { while ((gm=GetMessage(&msg, NULL, 0, 0)) > 0) {
flags=GetWindowLong(hwnd, BOXFLAGS); flags=GetWindowLongPtr(hwnd, BOXFLAGS);
if (!(flags & DF_END) && !IsDialogMessage(hwnd, &msg)) if (!(flags & DF_END) && !IsDialogMessage(hwnd, &msg))
DispatchMessage(&msg); DispatchMessage(&msg);
if (flags & DF_END) if (flags & DF_END)
@ -265,15 +265,15 @@ static int SaneDialogBox(HINSTANCE hinst,
if (gm == 0) if (gm == 0)
PostQuitMessage(msg.wParam); /* We got a WM_QUIT, pass it on */ PostQuitMessage(msg.wParam); /* We got a WM_QUIT, pass it on */
ret=GetWindowLong(hwnd, BOXRESULT); ret=GetWindowLongPtr(hwnd, BOXRESULT);
DestroyWindow(hwnd); DestroyWindow(hwnd);
return ret; return ret;
} }
static void SaneEndDialog(HWND hwnd, int ret) static void SaneEndDialog(HWND hwnd, int ret)
{ {
SetWindowLong(hwnd, BOXRESULT, ret); SetWindowLongPtr(hwnd, BOXRESULT, ret);
SetWindowLong(hwnd, BOXFLAGS, DF_END); SetWindowLongPtr(hwnd, BOXFLAGS, DF_END);
} }
/* /*
@ -375,10 +375,11 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg,
dp.hwnd = hwnd; dp.hwnd = hwnd;
create_controls(hwnd, ""); /* Open and Cancel buttons etc */ create_controls(hwnd, ""); /* Open and Cancel buttons etc */
SetWindowText(hwnd, dp.wintitle); SetWindowText(hwnd, dp.wintitle);
SetWindowLong(hwnd, GWL_USERDATA, 0); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
if (help_path) if (help_path)
SetWindowLong(hwnd, GWL_EXSTYLE, SetWindowLongPtr(hwnd, GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP); GetWindowLongPtr(hwnd, GWL_EXSTYLE) |
WS_EX_CONTEXTHELP);
else { else {
HWND item = GetDlgItem(hwnd, IDC_HELPBTN); HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
if (item) if (item)
@ -512,7 +513,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg,
} }
} }
SetWindowLong(hwnd, GWL_USERDATA, 1); SetWindowLongPtr(hwnd, GWLP_USERDATA, 1);
return 0; return 0;
case WM_LBUTTONUP: case WM_LBUTTONUP:
/* /*
@ -573,7 +574,7 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg,
/* /*
* Only process WM_COMMAND once the dialog is fully formed. * Only process WM_COMMAND once the dialog is fully formed.
*/ */
if (GetWindowLong(hwnd, GWL_USERDATA) == 1) { if (GetWindowLongPtr(hwnd, GWLP_USERDATA) == 1) {
ret = winctrl_handle_command(&dp, msg, wParam, lParam); ret = winctrl_handle_command(&dp, msg, wParam, lParam);
if (dp.ended && GetCapture() != hwnd) if (dp.ended && GetCapture() != hwnd)
SaneEndDialog(hwnd, dp.endresult ? 1 : 0); SaneEndDialog(hwnd, dp.endresult ? 1 : 0);

View File

@ -2070,9 +2070,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
/* Enable or disable the scroll bar, etc */ /* Enable or disable the scroll bar, etc */
{ {
LONG nflg, flag = GetWindowLong(hwnd, GWL_STYLE); LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
LONG nexflag, exflag = LONG nexflag, exflag =
GetWindowLong(hwnd, GWL_EXSTYLE); GetWindowLongPtr(hwnd, GWL_EXSTYLE);
nexflag = exflag; nexflag = exflag;
if (cfg.alwaysontop != prev_cfg.alwaysontop) { if (cfg.alwaysontop != prev_cfg.alwaysontop) {
@ -2111,9 +2111,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
if (nflg != flag || nexflag != exflag) { if (nflg != flag || nexflag != exflag) {
if (nflg != flag) if (nflg != flag)
SetWindowLong(hwnd, GWL_STYLE, nflg); SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
if (nexflag != exflag) if (nexflag != exflag)
SetWindowLong(hwnd, GWL_EXSTYLE, nexflag); SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOACTIVATE | SWP_NOCOPYBITS |
@ -4942,7 +4942,7 @@ static int is_full_screen()
{ {
if (!IsZoomed(hwnd)) if (!IsZoomed(hwnd))
return FALSE; return FALSE;
if (GetWindowLong(hwnd, GWL_STYLE) & WS_CAPTION) if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CAPTION)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -4988,13 +4988,13 @@ static void make_full_screen()
return; return;
/* Remove the window furniture. */ /* Remove the window furniture. */
style = GetWindowLong(hwnd, GWL_STYLE); style = GetWindowLongPtr(hwnd, GWL_STYLE);
style &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME); style &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME);
if (cfg.scrollbar_in_fullscreen) if (cfg.scrollbar_in_fullscreen)
style |= WS_VSCROLL; style |= WS_VSCROLL;
else else
style &= ~WS_VSCROLL; style &= ~WS_VSCROLL;
SetWindowLong(hwnd, GWL_STYLE, style); SetWindowLongPtr(hwnd, GWL_STYLE, style);
/* Resize ourselves to exactly cover the nearest monitor. */ /* Resize ourselves to exactly cover the nearest monitor. */
get_fullscreen_rect(&ss); get_fullscreen_rect(&ss);
@ -5016,7 +5016,7 @@ static void clear_full_screen()
DWORD oldstyle, style; DWORD oldstyle, style;
/* Reinstate the window furniture. */ /* Reinstate the window furniture. */
style = oldstyle = GetWindowLong(hwnd, GWL_STYLE); style = oldstyle = GetWindowLongPtr(hwnd, GWL_STYLE);
style |= WS_CAPTION | WS_BORDER; style |= WS_CAPTION | WS_BORDER;
if (cfg.resize_action == RESIZE_DISABLED) if (cfg.resize_action == RESIZE_DISABLED)
style &= ~WS_THICKFRAME; style &= ~WS_THICKFRAME;
@ -5027,7 +5027,7 @@ static void clear_full_screen()
else else
style &= ~WS_VSCROLL; style &= ~WS_VSCROLL;
if (style != oldstyle) { if (style != oldstyle) {
SetWindowLong(hwnd, GWL_STYLE, style); SetWindowLongPtr(hwnd, GWL_STYLE, style);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_FRAMECHANGED); SWP_FRAMECHANGED);

View File

@ -801,8 +801,9 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
switch (msg) { switch (msg) {
case WM_INITDIALOG: case WM_INITDIALOG:
if (help_path) if (help_path)
SetWindowLong(hwnd, GWL_EXSTYLE, SetWindowLongPtr(hwnd, GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP); GetWindowLongPtr(hwnd, GWL_EXSTYLE) |
WS_EX_CONTEXTHELP);
else { else {
/* /*
* If we add a Help button, this is where we destroy it * If we add a Help button, this is where we destroy it
@ -818,7 +819,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
state->collecting_entropy = FALSE; state->collecting_entropy = FALSE;
state->entropy = NULL; state->entropy = NULL;
state->key_exists = FALSE; state->key_exists = FALSE;
SetWindowLong(hwnd, GWL_USERDATA, (LONG) state); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) state);
{ {
HMENU menu, menu1; HMENU menu, menu1;
@ -943,7 +944,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
return 1; return 1;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->collecting_entropy && if (state->collecting_entropy &&
state->entropy && state->entropy_got < state->entropy_required) { state->entropy && state->entropy_got < state->entropy_required) {
state->entropy[state->entropy_got++] = lParam; state->entropy[state->entropy_got++] = lParam;
@ -994,7 +995,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
case IDC_KEYSSH2DSA: case IDC_KEYSSH2DSA:
{ {
state = (struct MainDlgState *) state = (struct MainDlgState *)
GetWindowLong(hwnd, GWL_USERDATA); GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (!IsDlgButtonChecked(hwnd, LOWORD(wParam))) if (!IsDlgButtonChecked(hwnd, LOWORD(wParam)))
CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2DSA, CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2DSA,
LOWORD(wParam)); LOWORD(wParam));
@ -1008,7 +1009,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
case IDC_COMMENTEDIT: case IDC_COMMENTEDIT:
if (HIWORD(wParam) == EN_CHANGE) { if (HIWORD(wParam) == EN_CHANGE) {
state = (struct MainDlgState *) state = (struct MainDlgState *)
GetWindowLong(hwnd, GWL_USERDATA); GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->key_exists) { if (state->key_exists) {
HWND editctl = GetDlgItem(hwnd, IDC_COMMENTEDIT); HWND editctl = GetDlgItem(hwnd, IDC_COMMENTEDIT);
int len = GetWindowTextLength(editctl); int len = GetWindowTextLength(editctl);
@ -1047,7 +1048,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
HIWORD(wParam) != BN_DOUBLECLICKED) HIWORD(wParam) != BN_DOUBLECLICKED)
break; break;
state = state =
(struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (!state->generation_thread_exists) { if (!state->generation_thread_exists) {
BOOL ok; BOOL ok;
state->keysize = GetDlgItemInt(hwnd, IDC_BITS, &ok, FALSE); state->keysize = GetDlgItemInt(hwnd, IDC_BITS, &ok, FALSE);
@ -1103,7 +1104,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
if (HIWORD(wParam) != BN_CLICKED) if (HIWORD(wParam) != BN_CLICKED)
break; break;
state = state =
(struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->key_exists) { if (state->key_exists) {
char filename[FILENAME_MAX]; char filename[FILENAME_MAX];
char passphrase[PASSPHRASE_MAXLEN]; char passphrase[PASSPHRASE_MAXLEN];
@ -1198,7 +1199,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
if (HIWORD(wParam) != BN_CLICKED) if (HIWORD(wParam) != BN_CLICKED)
break; break;
state = state =
(struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (state->key_exists) { if (state->key_exists) {
char filename[FILENAME_MAX]; char filename[FILENAME_MAX];
if (prompt_keyfile(hwnd, "Save public key as:", if (prompt_keyfile(hwnd, "Save public key as:",
@ -1233,7 +1234,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
if (HIWORD(wParam) != BN_CLICKED) if (HIWORD(wParam) != BN_CLICKED)
break; break;
state = state =
(struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (!state->generation_thread_exists) { if (!state->generation_thread_exists) {
char filename[FILENAME_MAX]; char filename[FILENAME_MAX];
if (prompt_keyfile(hwnd, "Load private key:", if (prompt_keyfile(hwnd, "Load private key:",
@ -1245,7 +1246,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
} }
return 0; return 0;
case WM_DONEKEY: case WM_DONEKEY:
state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
state->generation_thread_exists = FALSE; state->generation_thread_exists = FALSE;
state->key_exists = TRUE; state->key_exists = TRUE;
SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
@ -1385,7 +1386,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
} }
break; break;
case WM_CLOSE: case WM_CLOSE:
state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA); state = (struct MainDlgState *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
sfree(state); sfree(state);
if (requested_help) { if (requested_help) {
WinHelp(hwnd, help_path, HELP_QUIT, 0); WinHelp(hwnd, help_path, HELP_QUIT, 0);

View File

@ -1471,8 +1471,9 @@ static int CALLBACK KeyListProc(HWND hwnd, UINT msg,
} }
if (help_path) if (help_path)
SetWindowLong(hwnd, GWL_EXSTYLE, SetWindowLongPtr(hwnd, GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP); GetWindowLongPtr(hwnd, GWL_EXSTYLE) |
WS_EX_CONTEXTHELP);
else { else {
HWND item = GetDlgItem(hwnd, 103); /* the Help button */ HWND item = GetDlgItem(hwnd, 103); /* the Help button */
if (item) if (item)

View File

@ -28,7 +28,7 @@ struct FontSpec {
}; };
#define BOXFLAGS DLGWINDOWEXTRA #define BOXFLAGS DLGWINDOWEXTRA
#define BOXRESULT DLGWINDOWEXTRA + 4 #define BOXRESULT (DLGWINDOWEXTRA + sizeof(LONG_PTR))
#define DF_END 0x0001 #define DF_END 0x0001
/* /*