1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +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->dragging = 0;
/* XXX hack Q183115 */
SetWindowLong(hwnd, DWL_MSGRESULT, TRUE);
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
ret |= 1; break;
case DL_CANCELDRAG:
DrawInsert(hwnd, dlm->hWnd, -1); /* Clear arrow */
@ -1064,9 +1064,9 @@ int handle_prefslist(struct prefslist *hdl,
if (dest > hdl->dummyitem) dest = hdl->dummyitem;
DrawInsert (hwnd, dlm->hWnd, dest);
if (dest >= 0)
SetWindowLong(hwnd, DWL_MSGRESULT, DL_MOVECURSOR);
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, DL_MOVECURSOR);
else
SetWindowLong(hwnd, DWL_MSGRESULT, DL_STOPCURSOR);
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, DL_STOPCURSOR);
ret |= 1; break;
case DL_DROPPED:
if (hdl->dragging) {

View File

@ -240,7 +240,7 @@ static int SaneDialogBox(HINSTANCE hinst,
wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW;
wc.lpfnWndProc = DefDlgProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = DLGWINDOWEXTRA + 8;
wc.cbWndExtra = DLGWINDOWEXTRA + 2*sizeof(LONG_PTR);
wc.hInstance = hinst;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
@ -251,11 +251,11 @@ static int SaneDialogBox(HINSTANCE hinst,
hwnd = CreateDialog(hinst, tmpl, hwndparent, lpDialogFunc);
SetWindowLong(hwnd, BOXFLAGS, 0); /* flags */
SetWindowLong(hwnd, BOXRESULT, 0); /* result from SaneEndDialog */
SetWindowLongPtr(hwnd, BOXFLAGS, 0); /* flags */
SetWindowLongPtr(hwnd, BOXRESULT, 0); /* result from SaneEndDialog */
while ((gm=GetMessage(&msg, NULL, 0, 0)) > 0) {
flags=GetWindowLong(hwnd, BOXFLAGS);
flags=GetWindowLongPtr(hwnd, BOXFLAGS);
if (!(flags & DF_END) && !IsDialogMessage(hwnd, &msg))
DispatchMessage(&msg);
if (flags & DF_END)
@ -265,15 +265,15 @@ static int SaneDialogBox(HINSTANCE hinst,
if (gm == 0)
PostQuitMessage(msg.wParam); /* We got a WM_QUIT, pass it on */
ret=GetWindowLong(hwnd, BOXRESULT);
ret=GetWindowLongPtr(hwnd, BOXRESULT);
DestroyWindow(hwnd);
return ret;
}
static void SaneEndDialog(HWND hwnd, int ret)
{
SetWindowLong(hwnd, BOXRESULT, ret);
SetWindowLong(hwnd, BOXFLAGS, DF_END);
SetWindowLongPtr(hwnd, BOXRESULT, ret);
SetWindowLongPtr(hwnd, BOXFLAGS, DF_END);
}
/*
@ -375,10 +375,11 @@ static int CALLBACK GenericMainDlgProc(HWND hwnd, UINT msg,
dp.hwnd = hwnd;
create_controls(hwnd, ""); /* Open and Cancel buttons etc */
SetWindowText(hwnd, dp.wintitle);
SetWindowLong(hwnd, GWL_USERDATA, 0);
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
if (help_path)
SetWindowLong(hwnd, GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
SetWindowLongPtr(hwnd, GWL_EXSTYLE,
GetWindowLongPtr(hwnd, GWL_EXSTYLE) |
WS_EX_CONTEXTHELP);
else {
HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
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;
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.
*/
if (GetWindowLong(hwnd, GWL_USERDATA) == 1) {
if (GetWindowLongPtr(hwnd, GWLP_USERDATA) == 1) {
ret = winctrl_handle_command(&dp, msg, wParam, lParam);
if (dp.ended && GetCapture() != hwnd)
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 */
{
LONG nflg, flag = GetWindowLong(hwnd, GWL_STYLE);
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
LONG nexflag, exflag =
GetWindowLong(hwnd, GWL_EXSTYLE);
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
nexflag = exflag;
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)
SetWindowLong(hwnd, GWL_STYLE, nflg);
SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
if (nexflag != exflag)
SetWindowLong(hwnd, GWL_EXSTYLE, nexflag);
SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOCOPYBITS |
@ -4942,7 +4942,7 @@ static int is_full_screen()
{
if (!IsZoomed(hwnd))
return FALSE;
if (GetWindowLong(hwnd, GWL_STYLE) & WS_CAPTION)
if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CAPTION)
return FALSE;
return TRUE;
}
@ -4988,13 +4988,13 @@ static void make_full_screen()
return;
/* Remove the window furniture. */
style = GetWindowLong(hwnd, GWL_STYLE);
style = GetWindowLongPtr(hwnd, GWL_STYLE);
style &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME);
if (cfg.scrollbar_in_fullscreen)
style |= WS_VSCROLL;
else
style &= ~WS_VSCROLL;
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowLongPtr(hwnd, GWL_STYLE, style);
/* Resize ourselves to exactly cover the nearest monitor. */
get_fullscreen_rect(&ss);
@ -5016,7 +5016,7 @@ static void clear_full_screen()
DWORD oldstyle, style;
/* Reinstate the window furniture. */
style = oldstyle = GetWindowLong(hwnd, GWL_STYLE);
style = oldstyle = GetWindowLongPtr(hwnd, GWL_STYLE);
style |= WS_CAPTION | WS_BORDER;
if (cfg.resize_action == RESIZE_DISABLED)
style &= ~WS_THICKFRAME;
@ -5027,7 +5027,7 @@ static void clear_full_screen()
else
style &= ~WS_VSCROLL;
if (style != oldstyle) {
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowLongPtr(hwnd, GWL_STYLE, style);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_FRAMECHANGED);

View File

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

View File

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

View File

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