--- mstools/samples/ddeml/server/dialog.c 2018/08/09 18:20:38 1.1 +++ mstools/samples/ddeml/server/dialog.c 2018/08/09 18:23:24 1.1.1.3 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + #include #include #include "server.h" @@ -8,33 +19,33 @@ * FUNCTION : DoDialog() * * * * PURPOSE : Generic dialog invocation routine. Handles procInstance * - * stuff, focus management and param passing. * + * stuff, focus management and param passing. * * RETURNS : result of dialog procedure. * * * ****************************************************************************/ INT FAR DoDialog( LPSTR lpTemplateName, -FARPROC lpDlgProc, -DWORD param, +DLGPROC lpDlgProc, +LPARAM param, BOOL fRememberFocus) { - WORD wRet; + INT iRet; HWND hwndFocus; WORD cRunawayT; cRunawayT = cRunaway; cRunaway = 0; // turn off runaway during dialogs. - + if (fRememberFocus) hwndFocus = GetFocus(); lpDlgProc = MakeProcInstance(lpDlgProc, hInst); - wRet = DialogBoxParam(hInst, lpTemplateName, hwndServer, lpDlgProc, param); + iRet = DialogBoxParam(hInst, lpTemplateName, hwndServer, lpDlgProc, param); FreeProcInstance(lpDlgProc); if (fRememberFocus) SetFocus(hwndFocus); cRunaway = cRunawayT; // restore runaway state. - return wRet; + return iRet; } @@ -62,15 +73,15 @@ BOOL APIENTRY About(hDlg, message, wPar HWND hDlg; /* window handle of the dialog box */ UINT message; /* type of message */ WPARAM wParam; /* message-specific information */ -LONG lParam; +LPARAM lParam; { switch (message) { case WM_INITDIALOG: /* message: initialize dialog box */ return (TRUE); case WM_COMMAND: /* message: received a command */ - if (GET_WM_COMMAND_ID(wParam, lParam) == IDOK /* "OK" box selected? */ - || GET_WM_COMMAND_ID(wParam, lParam) == IDCANCEL) { /* System menu close command? */ + if (LOWORD(wParam) == IDOK /* "OK" box selected? */ + || LOWORD(wParam) == IDCANCEL) { /* System menu close command? */ EndDialog(hDlg, TRUE); /* Exits the dialog box */ return (TRUE); } @@ -86,7 +97,7 @@ BOOL APIENTRY RenderDelayDlgProc( HWND hwnd, register UINT msg, register WPARAM wParam, -LONG lParam) +LPARAM lParam) { switch (msg){ case WM_INITDIALOG: @@ -97,10 +108,10 @@ LONG lParam) break; case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) { + switch (LOWORD(wParam)) { case IDOK: RenderDelay = GetDlgItemInt(hwnd, IDEF_VALUE, NULL, FALSE); - // fall through + // fall through case IDCANCEL: EndDialog(hwnd, 0); break; @@ -120,10 +131,10 @@ BOOL APIENTRY SetTopicDlgProc( HWND hwnd, register UINT msg, register WPARAM wParam, -LONG lParam) +LPARAM lParam) { CHAR szT[MAX_TOPIC + 10]; - + switch (msg){ case WM_INITDIALOG: SetWindowText(hwnd, "Set Topic Dialog"); @@ -133,7 +144,7 @@ LONG lParam) break; case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) { + switch (LOWORD(wParam)) { case IDOK: DdeFreeStringHandle(idInst, topicList[1].hszTopic); GetDlgItemText(hwnd, IDEF_VALUE, szTopic, MAX_TOPIC); @@ -142,7 +153,7 @@ LONG lParam) strcat(szT, " | "); strcat(szT, szTopic); SetWindowText(hwndServer, szT); - // fall through + // fall through case IDCANCEL: EndDialog(hwnd, 0); break; @@ -160,10 +171,10 @@ BOOL APIENTRY SetServerDlgProc( HWND hwnd, register UINT msg, register WPARAM wParam, -LONG lParam) +LPARAM lParam) { CHAR szT[MAX_TOPIC + 10]; - + switch (msg){ case WM_INITDIALOG: SetWindowText(hwnd, "Set Server Name Dialog"); @@ -173,7 +184,7 @@ LONG lParam) break; case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) { + switch (LOWORD(wParam)) { case IDOK: GetDlgItemText(hwnd, IDEF_VALUE, szServer, MAX_TOPIC); DdeNameService(idInst, hszAppName, 0, DNS_UNREGISTER); @@ -184,7 +195,7 @@ LONG lParam) strcat(szT, " | "); strcat(szT, szTopic); SetWindowText(hwndServer, szT); - // fall through + // fall through case IDCANCEL: EndDialog(hwnd, 0); break; @@ -201,13 +212,13 @@ LONG lParam) BOOL APIENTRY ContextDlgProc( -HWND hwnd, +HWND hwnd, register UINT msg, register WPARAM wParam, -LONG lParam) +LPARAM lParam) { BOOL fSuccess; - + switch (msg){ case WM_INITDIALOG: SetDlgItemInt(hwnd, IDEF_FLAGS, CCFilter.wFlags, FALSE); @@ -215,11 +226,13 @@ LONG lParam) SetDlgItemInt(hwnd, IDEF_CODEPAGE, CCFilter.iCodePage, TRUE); SetDlgItemInt(hwnd, IDEF_LANG, LOWORD(CCFilter.dwLangID), FALSE); SetDlgItemInt(hwnd, IDEF_SECURITY, LOWORD(CCFilter.dwSecurity), FALSE); + CheckRadioButton(hwnd, IDRB_IL_ANON, IDRB_IL_DELEGATE, + IDRB_IL_ANON + (int)CCFilter.qos.ImpersonationLevel); return(1); break; case WM_COMMAND: - switch (GET_WM_COMMAND_ID(wParam, lParam)) { + switch (LOWORD(wParam)) { case IDOK: CCFilter.wFlags = GetDlgItemInt(hwnd, IDEF_FLAGS, &fSuccess, FALSE); if (!fSuccess) return(0); @@ -231,8 +244,18 @@ LONG lParam) if (!fSuccess) return(0); CCFilter.dwSecurity = (DWORD)GetDlgItemInt(hwnd, IDEF_SECURITY, &fSuccess, FALSE); if (!fSuccess) return(0); - - // fall through + + if (IsDlgButtonChecked(hwnd, IDRB_IL_ANON)) { + CCFilter.qos.ImpersonationLevel = SecurityAnonymous; + } else if (IsDlgButtonChecked(hwnd, IDRB_IL_ID)) { + CCFilter.qos.ImpersonationLevel = SecurityIdentification; + } else if (IsDlgButtonChecked(hwnd, IDRB_IL_IMP)) { + CCFilter.qos.ImpersonationLevel = SecurityImpersonation; + } else if (IsDlgButtonChecked(hwnd, IDRB_IL_DELEGATE)) { + CCFilter.qos.ImpersonationLevel = SecurityDelegation; + } + + // fall through case IDCANCEL: EndDialog(hwnd, 0); break; @@ -244,3 +267,5 @@ LONG lParam) } return(FALSE); } + +