#define WIN31 #include #include "RegEdit.h" HWND hWndNames, hWndIds; WORD fMode; extern char cUsesDDE[]; extern HANDLE *pLocalVals; WORD NEAR PASCAL StoreValue(HWND hWndEdit, HANDLE *pValue) { HANDLE hTemp = NULL; if(!SendMessage(hWndEdit, EM_GETMODIFY, 0, 0L)) return(0); SendMessage(hWndEdit, EM_SETMODIFY, 0, 0L); if(SendMessage(hWndEdit, WM_GETTEXTLENGTH, 0, 0L)) if(!(hTemp=GetEditString(hWndEdit))) return(IDS_OUTOFMEMORY); if(*pValue) LocalFree(*pValue); *pValue = hTemp; return(NULL); } VOID NEAR PASCAL SetValue(HWND hDlg, int i, HWND hWndEdit, HANDLE hValue, BOOL bEnable) { if(bEnable) { if(i >= ID_FIRSTDDEEDIT) EnableWindow(GetWindow(hWndEdit, GW_HWNDPREV), TRUE); EnableWindow(hWndEdit, TRUE); if(hValue) { SendMessage(hWndEdit, WM_SETTEXT, 0, (LONG)(LPSTR)LocalLock(hValue)); LocalUnlock(hValue); } else goto ClearEdit; } else { if(GetFocus() == hWndEdit) SendMessage(hDlg, WM_NEXTDLGCTL, GetDlgItem(hDlg, ID_CLASSID), 1L); EnableWindow(GetWindow(hWndEdit, GW_HWNDPREV), FALSE); EnableWindow(hWndEdit, FALSE); ClearEdit: SendMessage(hWndEdit, WM_SETTEXT, 0, (LONG)(LPSTR)""); } } int FAR PASCAL EditDlg(HWND hDlg, WORD message, WORD wParam, DWORD lParam) { static HANDLE hCustExes = NULL; switch(message) { case WM_ACTIVATE: if(wParam) hWndHelp = hDlg; return(FALSE); case WM_DESTROY: GetLocalCopies(GetDlgItem(hDlg, ID_CLASSNAME), NULL); break; case WM_COMMAND: switch(wParam) { case ID_SAVEACTION: wParam = IsDlgButtonChecked(hDlg, ID_OPENRADIO) ? ID_OPENRADIO : ID_PRINTRADIO; /* We fall through here */ case ID_OPENRADIO: case ID_PRINTRADIO: { WORD wOld, wNew, wTemp, wErrMsg = NULL; BOOL bCheck; HWND hWndEdit; int i; wOld = (ID_LASTEDIT-ID_FIRSTACTIONEDIT+1) * (IsDlgButtonChecked(hDlg, ID_OPENRADIO) ? 0 : 1); wNew = wParam==ID_OPENRADIO ? 0 : 1; bCheck = cUsesDDE[wNew]; wNew *= ID_LASTEDIT-ID_FIRSTACTIONEDIT+1; for(i=ID_FIRSTACTIONEDIT; i<=ID_LASTEDIT; ++i, ++wOld, ++wNew) { if(wTemp=StoreValue(hWndEdit=GetDlgItem(hDlg, i), pLocalVals+wOld)) wErrMsg = wTemp; SetValue(hDlg, i, hWndEdit, pLocalVals[wNew], i