INT_PTR CALLBACK OptsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: CenterDialogInParent(hDlg); InitOptionsFont(hDlg); ComboInitDialog(hDlg,GHCi_Combo_Editor); ComboInitDialog(hDlg,GHCi_Combo_Startup); ComboInitDialog(hDlg,GHCi_Combo_Prompt); break; case WM_COMMAND: { INT Code = HIWORD(wParam); INT Ctrl = LOWORD(wParam); if ((Ctrl == IDC_ChkFontBold && Code == BN_CLICKED) || (Ctrl == IDC_ChkFontItalic && Code == BN_CLICKED) || (Ctrl == IDC_TxtFontSize && Code == EN_CHANGE) || (Ctrl == IDC_LstFontFace && (Code == CBN_EDITCHANGE || Code == CBN_SELCHANGE)) ) UpdateFontPreview(hDlg); switch (LOWORD(wParam)) { case IDOK: { CHARFORMAT cf, prevCf; RegistryReadFont(&prevCf); CalculateFont(hDlg, &cf); if( (StringCmp(cf.szFaceName,prevCf.szFaceName)) || (cf.yHeight != prevCf.yHeight) || (cf.dwEffects != prevCf.dwEffects)) { RegistryWriteFont(&cf); RtfWindowUpdateFont(); } UpdateOptions(hDlg) ; EndDialog(hDlg, TRUE); return (INT_PTR)TRUE; } case IDCANCEL: EndDialog(hDlg, TRUE); return (INT_PTR)TRUE; } } break; } return (INT_PTR)FALSE; }
VOID RtfWindowInit(VOID) { CHARFORMAT cf; //make it all protected SendMessage(hWndRtf, EM_SETEVENTMASK, 0, ENM_PROTECTED | ENM_LINK | ENM_KEYEVENTS | ENM_SELCHANGE); cf.cbSize = sizeof(cf); cf.dwEffects = CFE_PROTECTED; cf.dwMask = CFM_PROTECTED; SendMessage(hWndRtf, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf); SendMessage(hWndRtf, EM_SETTEXTMODE, TM_RICHTEXT|TM_MULTICODEPAGE, (LPARAM) &cf); // Allow them 1 million characters // the system will sort out overflows later SendMessage(hWndRtf, EM_LIMITTEXT, 1000000, 0); // Let words break anywhere SendMessage(hWndRtf,EM_SETWORDBREAKPROC,0,(LPARAM)EditWordBreakProc); // Default formatting information BufFormat = DefFormat; NowFormat = DefFormat; // And syncronisation stuff InitializeCriticalSection(&CriticalSect); //update the font RtfWindowUpdateFont(); // Set margins SendMessage(hWndRtf, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, (LPARAM)MAKELONG(4,3)); }
void MainCommand(HWND hWnd, int ID) { switch (ID) { case IDCANCEL: EndDialog(hWnd, 0); break; case ID_OPEN: MainOpenFile(hWnd); break; case ID_SCRIPTMAN: ShowScriptMan(); break; case ID_EXIT: FireCommand(":quit\n"); break; /* Load one of the last 10 open files */ case ID_MRU+0: case ID_MRU+1: case ID_MRU+2: case ID_MRU+3: case ID_MRU+4: case ID_MRU+5: case ID_MRU+6: case ID_MRU+7: case ID_MRU+8: case ID_MRU+9: { char Command[1000]; wsprintf(Command, ":load %s", ExpandFileName(MruGetItem(ID-ID_MRU))); FireCommand(Command); } break; // EDIT MENU case ID_CUT: RtfWindowClipboard(WM_CUT); break; case ID_COPY: RtfWindowClipboard(WM_COPY); break; case ID_PASTE: RtfWindowClipboard(WM_PASTE); break; case ID_CLEARSCREEN: RtfWindowClear(); break; case ID_DELETE: RtfWindowDelete(); break; case ID_SELECTALL: RtfWindowSelectAll(); break; case ID_GOPREVIOUS: RtfWindowHistory(-1); break; case ID_GONEXT: RtfWindowHistory(+1); break; // ACTIONS MENU // Reload script files case ID_COMPILE: case ID_MAKE: FireCommand(":reload"); break; case ID_CLEARALL: FireCommand(":load"); break; case ID_GOEDIT: FireCommand(":edit"); break; /* Stop program execution */ case ID_STOP: MessageBeep(0xFFFFFFFF); AbortExecution(); break; /* Evaluate main expression */ case ID_RUN: { char Buffer[1000]; RtfWindowGetCommand(Buffer); if (Buffer[0] == '\0') FireCommand(":main"); else FireCommand(Buffer); } break; /* Set interpreter options using dialog box */ case ID_SETOPTIONS: if (ShowOptionsDialog(hWnd)) RtfWindowUpdateFont(); break; // BROWSE MENU case ID_BROWSEHIERARCHY: DrawClassesHierarchy(); break; case ID_BROWSECLASSES: DoBrowseClasses(); break; case ID_BROWSENAMES: DoBrowseNames(); break; case ID_BROWSETYCONS: DoBrowseTycons(); break; // HELP MENU case ID_HELPCONTENTS: ExecuteFileDocs("hugs98.chm"); break; case ID_HELPCOMMANDS: FireCommand(":?\n"); break; case ID_LIBRARIES: ExecuteFile("http://www.haskell.org/ghc/docs/latest/html/libraries/index.html"); break; case ID_WWWHASKELL: ExecuteFile("http://haskell.org/"); break; case ID_WWWHUGS: ExecuteFile("http://haskell.org/hugs/"); break; case ID_ABOUT: ShowAboutDialog(hWnd); break; } }