// ----------------------------------------------------------------------- // Create a memory block for sub listbox entries long AllocSubListBox(CStr StringToStore) { long ReturnValue = 0; ReturnValue = (long) calloc(StringToStore.Len() + 1, 1); RtlCopyMemory((void *) ReturnValue, StringToStore.Get_String(), StringToStore.Len()); return(ReturnValue); }
// ----------------------------------------------------------------------- // Change the icon associated with the project void SetProjectIcon(void) { CStr LdFile; CStr OpFilters; CStr IconDir; OpFilters = "Icon files (*.ico)|*.ico"; LdFile = ComDlgGetOpenFileName(FRMPrjPropshWnd, OpFilters, LastPrjIconDir, 0, CurrentDir); if(LdFile.Len() == 0) return; IconDir = FileGetDirectory(LdFile); if(strcmp(IconDir.Right(1).Get_String(), "\\") == 0) IconDir = IconDir.Left(IconDir.Len() - 1); LastPrjIconDir = IconDir; NewIconFile = LdFile; PictureBoxChangeIcon(FRMPrjPropsIcon, (HICON) LoadImage(0, LdFile.Get_String(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE)); }
// ----------------------------------------------------------------------- // Response for font size modifications void Prop_DialogFontSize(void) { if(CurrentFont != 0) DeleteObject(CurrentFont); if(SelectedInListText.Len() != 0) { // CurrentFont = GDIObtainFont(DiagLabelsFormStorage.Get(CurrentEditControlIndex - 1)->Content, SelectedInListText.Get_Long(), FRMDiaghwnd, 0, 0); // ControlSetFont(FRMDiaghwnd, CurrentFont); } }
void CALLBACK AboutTimerNotify(HWND hWnd, UINT uMsg, UINT_PTR idEvent, unsigned long dwTime) { HDC AbouthDC = 0; switch(uMsg) { case WM_TIMER: AboutPosInText++; if((long) AboutPosInText > (long) AboutText.Len()) { AboutPosInText = 1; AboutPosOnScreen = 0; AbLine1 = AbLine2; AbLine2 = AbLine3; AbLine3 = AbLine4; AbLine4 = AbLine5; AbLine5 = AbLine6; AbLine6 = AbLine7; AbLine7 = AbLine8; AbLine8 = ""; } if(strcmp(AboutText.Mid(AboutPosInText, 1).Get_String(), "\r") == 0) { AboutPosOnScreen = 0; AbLine1 = AbLine2; AbLine2 = AbLine3; AbLine3 = AbLine4; AbLine4 = AbLine5; AbLine5 = AbLine6; AbLine6 = AbLine7; AbLine7 = AbLine8; AbLine8 = ""; LetterWidth = 0; } else { AbLine8 = AbLine8 + (CStr) AboutText.Mid(AboutPosInText, 1).Get_String(); LetterWidth = GDIGetTextWidth(AbouthWnd, AboutCourFont8, AboutText.Mid(AboutPosInText, 1)); } AboutPosOnScreen = AboutPosOnScreen + LetterWidth; AbouthDC = GetDC(AbouthWnd); DisplayTypeWriterLine(AbouthDC, AbLine1, 0, ABOUT_LABELSCOLOR1); DisplayTypeWriterLine(AbouthDC, AbLine2, AboutScrollAmount, ABOUT_LABELSCOLOR2); DisplayTypeWriterLine(AbouthDC, AbLine3, AboutScrollAmount * 2, ABOUT_LABELSCOLOR3); DisplayTypeWriterLine(AbouthDC, AbLine4, AboutScrollAmount * 3, ABOUT_LABELSCOLOR4); DisplayTypeWriterLine(AbouthDC, AbLine5, AboutScrollAmount * 4, ABOUT_LABELSCOLOR5); DisplayTypeWriterLine(AbouthDC, AbLine6, AboutScrollAmount * 5, ABOUT_LABELSCOLOR6); DisplayTypeWriterLine(AbouthDC, AbLine7, AboutScrollAmount * 6, ABOUT_LABELSCOLOR7); DisplayTypeWriterLine(AbouthDC, AbLine8, AboutScrollAmount * 7, ABOUT_LABELSCOLOR8); GDIWriteClippedText(AbouthDC, AboutPosOnScreen, AboutScrollAmount * 7, GDIGetTextWidth(AbouthWnd, AboutCourFont8, "_"), AboutScrollAmount, "_", ABOUT_LABELSCOLOR8, AboutCourFont8, 0, ABOUT_BACKCOLOR); ReleaseDC(AbouthWnd, AbouthDC); } }
// ----------------------------------------------------------------------- // Display API functions/constants listbox void DisplayAPIWindow(long dx, long dy, HWND hWnd, CStr APIFncN) { CStr ReturnValue; long EntryIndex = 0; long MaxName = 0; long MaxName2 = 0; if((UseDbFnc == 0) && (UseDbConst == 0)) return; // Retrieve all names ChildStruct = LoadStructure(CurrentForm); APIListWidth = 0; APIListHeight = 1; CreateSplashDialog(dx, dy, APIListWidth, APIListHeight, "", ChildStruct->hChildCodeMax, NULL, NULL, &FRMAPIListInitProc, &FRMAPIListWinHook, 0, 0, SW_HIDE); ListBoxReset(APIhListBox); if(FncBase != 0) if(UseDbFnc == 1) MaxName = FillAPIListBox(APIhListBox, FncBase); if(ConstBase != 0) if(UseDbConst == 1) MaxName2 = FillAPIListBox(APIhListBox, ConstBase); if(MaxName2 > MaxName) MaxName = MaxName2; if(MaxName != 0) { // Set sizes APIListWidth = (GDIGetFontWidth(FRMAPIListhWnd, APIListhFont) * MaxName) + 2 + 1 + GetSystemMetrics(SM_CXVSCROLL); APIListHeight = (GDIGetTextHeight(FRMAPIListhWnd, APIListhFont, "hg") * DbLinesNumbers) + 2 + 1; if(dx < 0) dx = 0; if(dy < 0) dy = 0; if((dx + APIListWidth) > GetSystemMetrics(SM_CXFULLSCREEN)) dx = GetSystemMetrics(SM_CXFULLSCREEN) - APIListWidth; if((dy + APIListHeight) > GetSystemMetrics(SM_CYFULLSCREEN)) dy = GetSystemMetrics(SM_CYFULLSCREEN) - APIListHeight; // Resize and display API list now ControlResize(FRMAPIListhWnd, dx, dy, APIListWidth, APIListHeight); ControlResize(APIhListBox, 1, 1, APIListWidth - 2, APIListHeight - 2); APIXDim = APIListWidth; APIYDim = APIListHeight; // Modify index of the listbox if necessary if(APIFncN.Len() != 0) { EntryIndex = SendMessage(APIhListBox, LB_FINDSTRING, -1, (long) APIFncN.Get_String()); ListBoxSetIndex(APIhListBox, EntryIndex); ListBoxSetTopIndex(APIhListBox, EntryIndex); } else { ListBoxSetIndex(APIhListBox, -1); ListBoxSetTopIndex(APIhListBox, -1); } ControlVisible(FRMAPIListhWnd, 1); SetFocus(APIhListBox); } else { // Remove it ControlClose(FRMAPIListhWnd); } }
// ----------------------------------------------------------------------- // Retrieve the last slot available for an addin in the ini file long GetAddInSlot(void) { int i = 0; long ReturnValue = 0; CStr AddInName; for(i = 0; i <= 999; i++) { AddInName = IniReadKey("AddIns", "File" + (CStr) StringNumberComplement(i, 3).Get_String(), MainIniFile); if(AddInName.Len() == 0) break; ReturnValue++; } return(ReturnValue); }
// ----------------------------------------------------------------------- // Search an addin in the list long CheckAddInIniList(CStr FileName) { int i = 0; long ReturnValue = -1; CStr AddInName; for(i = 0; i <= 999; i++) { AddInName = IniReadKey("AddIns", "File" + (CStr) StringNumberComplement(i, 3).Get_String(), MainIniFile); if(AddInName.Len() == 0) break; if(_strcmpi(AddInName.Get_String(), FileName.Get_String()) == 0) { ReturnValue = i; break; } } return(ReturnValue); }
// ----------------------------------------------------------------------- // Fill the listview with filenames long DllDefFillFilesList(void) { int i = 0; CStr DefValue; CStr DefEntryValue; long ReturnValue = 0; DefEntryValue = IniReadKey("ENTRYPOINT", "Proc", DllDefFile); for(i = 0; i <= StringGetSplitUBound(DllDefArray) - 1; i++) { if(strlen(StringGetSplitElement(RealProcList, DllDefArray, i).Get_String()) != 0) { ListViewAddItem(FRMDllDefListview, StringGetSplitElement(RealProcList, DllDefArray, i), i, 0); if(_strcmpi(StringGetSplitElement(RealProcList, DllDefArray, i).Get_String(), DefEntryValue.Get_String()) == 0) ReturnValue = i + 1; ComboBoxAddItem(FRMDllDefComboBox, StringGetSplitElement(RealProcList, DllDefArray, i), -1); DefValue = IniReadKey("EXPORTS", StringGetSplitElement(RealProcList, DllDefArray, i), DllDefFile); if(DefValue.Len() != 0) ListViewSetItemCheckbox(FRMDllDefListview, i, 1); } } return(ReturnValue); }
// ----------------------------------------------------------------------- // Select a font void PropSelectFont(void) { CStr FName; CStr BufString; long FSize = 0; HDC NextDC = 0; int i = 0; // Note: Font name must always be followed by font size if(strlen((char *) GetPropertyDatas(hCurrentObject, CurrentEditControlIndex + 1, PROPERTY_STORAGE)) != 0) { FSize = atol((char *) GetPropertyDatas(hCurrentObject, CurrentEditControlIndex + 1, PROPERTY_STORAGE)); } ControlEnable(FRMDiagToolhwnd, 0); ControlEnable(FRMDiagTBhwnd, 0); ControlEnable(FRMDiagPropshwnd, 0); if(ComDlgChooseFont(FRMDiaghwnd, (char *) GetPropertyDatas(hCurrentObject, CurrentEditControlIndex, PROPERTY_STORAGE), FSize, 0) != 0) { for(i = 0; i <= LF_FACESIZE - 1; i++) { if(MyLogFont.lfFaceName[i] == 0) break; FName = FName + FName.Chr(MyLogFont.lfFaceName[i]); } if(FName.Len() != 0) { BufString = MyFont.iPointSize / 10; SetPropertyDatas(hCurrentObject, CurrentEditControlIndex + 1, PROPERTY_STORAGE, (long) BufString.Get_String()); SetPropertyDatas(hCurrentObject, CurrentEditControlIndex, PROPERTY_STORAGE, (long) FName.Get_String()); ControlSetText(CurrentEditControlSubEdit, FName); // Set size NextDC = GetDC(hPropListbox); GDIWriteClippedText(NextDC, PropCurrentLeft + 1, PropCurrentTop + 1, PropCurrentWidth - 1, PropCurrentHeight, (char *) GetPropertyDatas(hCurrentObject, CurrentEditControlIndex + 1, PROPERTY_STORAGE), GetSysColor(COLOR_WINDOWTEXT), WASerifFont, 0, GetSysColor(COLOR_WINDOW)); ReleaseDC(hPropListbox, NextDC); if(GetPropertyDatas(hCurrentObject, CurrentEditControlIndex, PROPERTY_ROUTINE) != 0) JumpToAddr((FARPROC) GetPropertyDatas(hCurrentObject, CurrentEditControlIndex, PROPERTY_ROUTINE)); } } ControlEnable(FRMDiagToolhwnd, 1); ControlEnable(FRMDiagTBhwnd, 1); ControlEnable(FRMDiagPropshwnd, 1); }
// ----------------------------------------------------------------------- // Fill the languages extensions void FillExtLanguage(void) { long *ExtArray = 0; CStr LangToCheck; CStr RegEntry; CStr BufString; int i = 0; int j = 0; int k = 0; // Get default extensions (.med/.mws) ListViewAddItem(FRMRegsListview, "med", k, 0); RegEntry = RegistryGetKeyValue(HKEY_CLASSES_ROOT, ".med", ""); if(RegEntry.Len() != 0) { if(_strcmpi(RegEntry.Get_String(), "Chromatic project file") == 0) { ListViewSetItemCheckbox(FRMRegsListview, k, 1); } } ListViewSetSubItem(FRMRegsListview, "(Chromatic projects)", k, 1); k++; ListViewAddItem(FRMRegsListview, "mws", k, 0); RegEntry = RegistryGetKeyValue(HKEY_CLASSES_ROOT, ".mws", ""); if(RegEntry.Len() != 0) { if(_strcmpi(RegEntry.Get_String(), "Chromatic workspace file") == 0) { ListViewSetItemCheckbox(FRMRegsListview, k, 1); } } ListViewSetSubItem(FRMRegsListview, "(Chromatic workspaces)", k, 1); k++; for(i = 0; i <= 999; i++) { FRMRegsRetVal = IniReadKey("RefLanguages", "Ext" + (CStr) StringNumberComplement(i, 3).Get_String(), LanguagesIniFile).Trim(); LangToCheck = IniReadKey("RefLanguages", "Lang" + (CStr) StringNumberComplement(i, 3).Get_String(), LanguagesIniFile); if(FRMRegsRetVal.Len() == 0) break; LangToCheck = ChangeRelativePaths(LangToCheck); LangFileToRead = LangToCheck; FRMRegsLangName = IniReadKey("LangSpec", "LangName", LangFileToRead); if(FRMRegsLangName.Len() == 0) { LangToCheck = "<Error>"; } else { LangToCheck = FRMRegsLangName; } ExtArray = StringSplit(FRMRegsRetVal, " "); if(StringGetSplitUBound(ExtArray) != -1) { for(j = 0; j <= StringGetSplitUBound(ExtArray); j++) { ListViewAddItem(FRMRegsListview, StringGetSplitElement(FRMRegsRetVal, ExtArray, j), k, 0); RegEntry = RegistryGetKeyValue(HKEY_CLASSES_ROOT, "." + (CStr) StringGetSplitElement(FRMRegsRetVal, ExtArray, j).Get_String(), ""); if(RegEntry.Len() != 0) { BufString = "Chromatic " + (CStr) StringGetSplitElement(FRMRegsRetVal, ExtArray, j).Get_String() + (CStr) " file"; if(_strcmpi(RegEntry.Get_String(), BufString.Get_String()) == 0) { ListViewSetItemCheckbox(FRMRegsListview, k, 1); } } ListViewSetSubItem(FRMRegsListview, LangToCheck, k, 1); k++; } } StringReleaseSplit(ExtArray); } }
// ----------------------------------------------------------------------- // Initialize Form int CALLBACK FRMAddInsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT CreatePs; long CurrentLvItem = 0; long AddInIcon = 0; CStr RunningInIniFile; POINT PopMenuCoords; CStr OpFilters; CStr LdFile; FARPROC AddInAuthUpDate = 0; FARPROC AddInDescUpDate = 0; long OldRunningState = 0; CStr BufString; switch(uMsg) { case WM_SYSCOLORCHANGE: ListViewSetBackColor(FRMAddInsListView, GetSysColor(COLOR_WINDOW)); break; case WM_INITDIALOG: FRMAddInshWnd = hwndDlg; ControlSetText(hwndDlg, "AddIns manager"); FRMAddInsCmdOk = CreateButton(327, 292, 77, 23, hwndDlg, "Ok", 1, 0, 0, 0, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP, Buttons_StaticEdge); FRMAddInsCmdCancel = CreateButton(406, 292, 77, 23, hwndDlg, "Cancel", 2, 0, 0, 0, WS_TABSTOP, Buttons_StaticEdge); FRMAddInsListView = CreateListView(2, 1, 482, 278, hwndDlg, 0, GlobalImageList1, 0, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP | LVS_EX_CHECKBOXES, LVS_REPORT | LVS_SINGLESEL | WS_TABSTOP | LVS_NOSORTHEADER, WS_EX_STATICEDGE); ListViewAddCol(FRMAddInsListView, "Author", 198, 0); ListViewAddCol(FRMAddInsListView, "Description", 265, 1); ListViewSetItemSel(FRMAddInsListView, 0); FillAddinsList(); hAddInsMenu = CreatePopupMenu(); MenuAddString(hAddInsMenu, "Load/Unload AddIn", ADDIN_IDBASE + ADDIN_ENABLE, TRUE); MenuSetDefaultItem(hAddInsMenu, 0); MenuAddSeparator(hAddInsMenu); MenuAddString(hAddInsMenu, "Display in AddIns menu", ADDIN_IDBASE + ADDIN_MENU, TRUE); MenuAddString(hAddInsMenu, "Remove from AddIns menu", ADDIN_IDBASE + ADDIN_REMMENU, TRUE); MenuAddSeparator(hAddInsMenu); MenuAddString(hAddInsMenu, "Update AddIn", ADDIN_IDBASE + ADDIN_UPDATE, TRUE); FreezeTimer = 1; return(0); case WM_PAINT: BeginPaint(hwndDlg, &CreatePs); GDIDrawHorzSep(hwndDlg, 0, 285, 486); EndPaint(hwndDlg, &CreatePs); break; case WM_COMMAND: if((HWND) lParam == FRMAddInsCmdOk) { SaveAddInList(); ReFillAddInsArrays(); FillAddInsMenu(); RefreshRunningStates(); ControlClose(hwndDlg); return(0); } else if((HWND) lParam == FRMAddInsCmdCancel) { ControlClose(hwndDlg); return(0); } switch(wParam) { case (ADDIN_ENABLE + ADDIN_IDBASE): AddInIcon = ListViewGetSubItemImage(FRMAddInsListView, CurrentPopupItem, 0); if(AddInIcon == ICON_ADDINR) AddInIcon = ICON_ADDINS; else AddInIcon = ICON_ADDINR; ListViewSetSubItemImage(FRMAddInsListView, AddInIcon, CurrentPopupItem, 0); return(0); case (ADDIN_MENU + ADDIN_IDBASE): ListViewSetItemCheckbox(FRMAddInsListView, CurrentPopupItem, 1); return(0); case (ADDIN_REMMENU + ADDIN_IDBASE): ListViewSetItemCheckbox(FRMAddInsListView, CurrentPopupItem, 0); return(0); case (ADDIN_UPDATE + ADDIN_IDBASE): OpFilters = AppTitle + (CStr) " AddIn (*.dll)|*.dll"; LdFile = ComDlgGetOpenFileName(hwndDlg, OpFilters, LastAddInDir, 0, CurrentDir); if(LdFile.Len() != 0) { // Check if the AddIn is located in AddIns directory if(_strcmpi(FileGetDirectory(LdFile).Get_String(), Dirs[DIR_ADDINS]) == 0) { MiscMsgBox(hwndDlg, "New AddIn can't be located in AddIns directory.", MB_ERROR, Requesters); return(0); } // Check if file exist if(FileExist(Dirs[DIR_ADDINS] + (CStr) "\\" + (CStr) FileGetFileName(LdFile)) == 0) { MiscMsgBox(hwndDlg, "No corresponding AddIn found.", MB_ERROR, Requesters); return(0); } // Check if names are identicals if(_strcmpi(LocalAddInsFiles.Get(CurrentPopupItem)->Content, FileGetFileName(LdFile).Get_String()) != 0) { MiscMsgBox(hwndDlg, "AddIn name doesn't match.", MB_ERROR, Requesters); return(0); } if(IsAddIn(LdFile) == 0) { MiscMsgBox(hwndDlg, "Not a Chromatic AddIn.", MB_ERROR, Requesters); return(0); } // Step 1: Shutdown it OldRunningState = ShutDownAddIn(CurrentPopupItem); // Step 2: Delete it BufString = Dirs[DIR_ADDINS] + (CStr) "\\" + (CStr) LocalAddInsFiles.Get(CurrentPopupItem)->Content; DeleteFile(BufString.Get_String()); // Step 3: Copy it CopyFile(LdFile.Get_String(), BufString.Get_String(), 0); // Step 4: Restart it RunningAddIns.Set(CurrentPopupItem, OldRunningState); if(RestartAddIn(CurrentPopupItem) == 0) { MiscMsgBox(hwndDlg, "Can't update this AddIn.", MB_ERROR, Requesters); return(0); } SetForegroundWindow(FRMAddInshWnd); SetActiveWindow(FRMAddInshWnd); // Step 5: Update listview with possible new infos AddInDescUpDate = GetProcAddress(AddInsDLL.Get(CurrentPopupItem)->Content, "AddInDescription"); AddInAuthUpDate = GetProcAddress(AddInsDLL.Get(CurrentPopupItem)->Content, "AddInAuthor"); ListViewSetSelItemText(FRMAddInsListView, GetDLLDescription(LocalAddInsFiles.Get(CurrentPopupItem)->Content, AddInDescUpDate), 0); ListViewSetSelItemText(FRMAddInsListView, GetDLLAuthor(AddInAuthUpDate), 1); LastAddInDir = FileGetDirectory(LdFile); MiscMsgBox(hwndDlg, "AddIn '" + GetDLLDescription(LocalAddInsFiles.Get(CurrentPopupItem)->Content, AddInDescUpDate) + (CStr) "' updated.", MB_INFORMATION, Requesters); } return(0); } break; case WM_NOTIFY: if(ControlGetNotifiedhWnd(lParam) == FRMAddInsListView) { switch(ControlGetNotifiedMsg(lParam)) { case NM_DBLCLK: CurrentLvItem = ListViewGetItemUnderCursor(FRMAddInsListView); if(CurrentLvItem != -1) { AddInIcon = ListViewGetSubItemImage(FRMAddInsListView, CurrentLvItem, 0); if(AddInIcon == ICON_ADDINR) AddInIcon = ICON_ADDINS; else AddInIcon = ICON_ADDINR; ListViewSetItemSel(FRMAddInsListView, CurrentLvItem); ListViewSetSubItemImage(FRMAddInsListView, AddInIcon, CurrentLvItem, 0); } return(0); } } break; case WM_CONTEXTMENU: CurrentLvItem = ListViewGetItemUnderCursor(FRMAddInsListView); if(CurrentLvItem != -1) { ListViewSetItemSel(FRMAddInsListView, CurrentLvItem); CurrentPopupItem = ListViewGetItemUnderCursor(FRMAddInsListView); SetFocus(FRMAddInsListView); GetCursorPos(&PopMenuCoords); TrackPopupMenu(hAddInsMenu, TPM_LEFTALIGN + TPM_LEFTBUTTON, PopMenuCoords.x, PopMenuCoords.y, 0, hwndDlg, NULL); } return(0); case WM_CLOSE: if(hAddInsMenu != 0) DestroyMenu(hAddInsMenu); FreezeTimer = 0; FRMAddInsListView = 0; EndDialog(hwndDlg, 0); } return(0); }
// ----------------------------------------------------------------------- // Refresh the running states of the addins after manager modifications void RefreshRunningStates(void) { long OldAddInIndex = 0; long AddInIndex = 0; CStr AddInFileName; CStr AddInRunning; int i = 0; // Run them or not for(i = 0; i <= 999; i++) { AddInFileName = IniReadKey("AddIns", "File" + (CStr) StringNumberComplement(i, 3).Get_String(), MainIniFile); AddInRunning = IniReadKey("AddIns", "Running" + (CStr) StringNumberComplement(i, 3).Get_String(), MainIniFile); if(AddInFileName.Len() == 0) break; OldAddInIndex = SearchOldAddInName(AddInFileName); if(OldAddInIndex != -1) { // Want to it to run ? if(_strcmpi(AddInRunning.Get_String(), "1") == 0) { // Let's run it (if it wasn't running before) if(OldRunningAddIns.Get(OldAddInIndex)->Content != 1) { AddInIndex = SearchAddInName(AddInFileName); if(AddInsLoad.Get(AddInIndex)->Content != 0) { switch(JumpToAddrArg(AddInsLoad.Get(AddInIndex)->Content, (long) &AddInLib)) { case ADDIN_FINISHED: RunningAddIns.Set(AddInIndex, 0); // Unload it now if(AddInsUnLoad.Get(AddInIndex)->Content != 0) { JumpToAddr(AddInsUnLoad.Get(AddInIndex)->Content); IniWriteKey("AddIns", "Running" + (CStr) StringNumberComplement(i, 3).Get_String(), "0", MainIniFile); } break; case ADDIN_PERSISTANT: RunningAddIns.Set(AddInIndex, 1); // Mark it as persistantly running IniWriteKey("AddIns", "Running" + (CStr) StringNumberComplement(i, 3).Get_String(), "1", MainIniFile); break; } } } } else { // Let's stop it (if it wasn't stopped before) if(OldRunningAddIns.Get(OldAddInIndex)->Content != 0) { AddInIndex = SearchAddInName(AddInFileName); if(AddInsUnLoad.Get(AddInIndex)->Content != 0) { JumpToAddr(AddInsUnLoad.Get(AddInIndex)->Content); IniWriteKey("AddIns", "Running" + (CStr) StringNumberComplement(i, 3).Get_String(), "0", MainIniFile); } } } } else { // Not found to check if user wants it to be running now if(_strcmpi(AddInRunning.Get_String(), "1") == 0) { AddInIndex = SearchAddInName(AddInFileName); if(AddInsLoad.Get(AddInIndex)->Content != 0) { switch(JumpToAddrArg(AddInsLoad.Get(AddInIndex)->Content, (long) &AddInLib)) { case ADDIN_FINISHED: RunningAddIns.Set(AddInIndex, 0); // Unload it now if(AddInsUnLoad.Get(AddInIndex)->Content != 0) { JumpToAddr(AddInsUnLoad.Get(AddInIndex)->Content); IniWriteKey("AddIns", "Running" + (CStr) StringNumberComplement(i, 3).Get_String(), "0", MainIniFile); } break; case ADDIN_PERSISTANT: RunningAddIns.Set(AddInIndex, 1); // Mark it as persistantly running IniWriteKey("AddIns", "Running" + (CStr) StringNumberComplement(i, 3).Get_String(), "1", MainIniFile); break; } } } } } }
// ----------------------------------------------------------------------- // The the listview with found AddIns void FillAddinsList(void) { int i = 0; CStr AddInName; HMODULE AddInLib = 0; FARPROC AddInDesc = 0; FARPROC AddInAuth = 0; FARPROC AddInLoad = 0; FARPROC AddInUnload = 0; FARPROC AddInMenu = 0; CStr Description; CStr Auth; long PosInIniFile = 0; CStr LoadedInIniFile; long AddInIcon = 0; CStr RunningInIniFile; CStr BufString; AddInName = FileDir(&((CStr) Dirs[DIR_ADDINS] + (CStr) "\\*.dll")); LocalAddInsFiles.Erase(); while(AddInName.Len() != 0) { BufString = Dirs[DIR_ADDINS] + (CStr) "\\" + (CStr) AddInName; AddInLib = LoadLibrary(BufString.Get_String()); if(AddInLib != 0) { AddInDesc = GetProcAddress(AddInLib, "AddInDescription"); AddInAuth = GetProcAddress(AddInLib, "AddInAuthor"); AddInLoad = GetProcAddress(AddInLib, "AddInLoad"); AddInUnload = GetProcAddress(AddInLib, "AddInUnLoad"); AddInMenu = GetProcAddress(AddInLib, "AddInMenu"); // Must have all procedures if(AddInDesc != 0 && AddInAuth != 0 && AddInLoad != 0 && AddInUnload != 0 && AddInMenu != 0) { Description = GetDLLDescription(AddInName, AddInDesc); Auth = GetDLLAuthor(AddInAuth); AddInIcon = ICON_ADDINR; PosInIniFile = CheckAddInIniList(AddInName); if(PosInIniFile != -1) { // Check if it is running if found in ini file RunningInIniFile = IniReadKey("AddIns", "Running" + (CStr) StringNumberComplement(PosInIniFile, 3).Get_String(), MainIniFile); if(_strcmpi(RunningInIniFile.Get_String(), "1") == 0) AddInIcon = ICON_ADDINS; } ListViewAddItem(FRMAddInsListView, Description, i, AddInIcon); ListViewSetSubItem(FRMAddInsListView, Auth, i, 1); // Check in the ini file if it's been already loaded PosInIniFile = CheckAddInIniList(AddInName); if(PosInIniFile != -1) { LoadedInIniFile = IniReadKey("AddIns", "Loaded" + (CStr) StringNumberComplement(PosInIniFile, 3).Get_String(), MainIniFile); if(LoadedInIniFile.Len() != 0) { if(_strcmpi(LoadedInIniFile.Get_String(), "1") == 0) { ListViewSetItemCheckbox(FRMAddInsListView, i, 1); } else { ListViewSetItemCheckbox(FRMAddInsListView, i, 0); } } else { ListViewSetItemCheckbox(FRMAddInsListView, i, 0); } } LocalAddInsFiles.Add(AddInName.Get_String()); i++; } FreeLibrary(AddInLib); // Dlg_Filters.cpp for more infos #ifndef _DEBUG CloseHandle(AddInLib); #endif } AddInName = FileDir(); } }
// ----------------------------------------------------------------------- // Display an API function // (for API name displaying purposes) CStr DisplayAPI(long dx, long dy) { CStr ReturnValue; CStr StArgs; CStr FirstSplit; CStr SecondSplit; int i = 0; int j = 0; long FoundLibLen = 0; CStr BufString; APIX = 0; APIY = 0; APIDescription = GetApiDescription(APIFile.Get_String(), APIFnc.Get_String()); if(APIDescription != 0) { FoundLibLen = strlen(APIDescription); APIFuckStr = APIFuckStr.String(FoundLibLen + 1, 1); RtlCopyMemory(APIFuckStr.Get_String(), (void *) APIDescription, FoundLibLen); APIBlock = StringSplit(APIFuckStr, "^^"); APIFound = 0; if(StringGetSplitUBound(APIBlock) != -1) { for(i = 0; i <= StringGetSplitUBound(APIBlock); i++) { FirstSplit = StringGetSplitElement(APIFuckStr, APIBlock, i); APIInfos = StringSplit(FirstSplit, "|"); if(_strcmpi(APIFnc.Get_String(), StringGetSplitElement(FirstSplit, APIInfos, 0).Upper_Case().Get_String()) == 0) { APIFound = 1; break; } // Not found: release it StringReleaseSplit(APIInfos); APIInfos = 0; } StringReleaseSplit(APIBlock); if(APIFound == 1) { // Firstsplit = last found entry SecondSplit = StringGetSplitElement(FirstSplit, APIInfos, 3); APIArgs = StringSplit(SecondSplit, ","); if(StringGetSplitUBound(APIArgs) == 0) if(strcmp(StringGetSplitElement(SecondSplit, APIArgs, 0).Get_String(), "-") == 0) goto NoArgs; for(i = 0; i <= StringGetSplitUBound(APIArgs); i++) { if(i == 2) break; StArgs = StArgs + (CStr) StringGetSplitElement(SecondSplit, APIArgs, i).Get_String() + (CStr) ","; } StArgs = StArgs + "\r\n"; while(i <= StringGetSplitUBound(APIArgs)) { for(j = 0; j <= StringGetSplitUBound(APIArgs); j++) { if(j == 2) break; if((i + j) > StringGetSplitUBound(APIArgs)) break; StArgs = StArgs + StringGetSplitElement(SecondSplit, APIArgs, i + j).Get_String() + (CStr) ","; } i = j + i; StArgs = StArgs + "\r\n"; } if(strcmp(StArgs.Right(3).Get_String(), ",\r\n") == 0) StArgs = StArgs.Left(StArgs.Len() - 3).Get_String() + (CStr) "\r\n"; NoArgs: APIString = "Function: " + (CStr) StringGetSplitElement(FirstSplit, APIInfos, 0).Get_String() + (CStr) "\r\n"; APIString = APIString + "Import lib: " + (CStr) StringGetSplitElement(FirstSplit, APIInfos, 1).Get_String() + (CStr) "\r\n"; APIString = APIString + "Return: " + (CStr) StringGetSplitElement(FirstSplit, APIInfos, 2).Get_String() + (CStr) "\r\n"; if(StringGetSplitUBound(APIArgs) == 0) if(strcmp(StringGetSplitElement(SecondSplit, APIArgs, 0).Get_String(), "-") == 0) goto NoStoreArgs; APIString = APIString + "Arguments (" + (CStr) (StringGetSplitUBound(APIArgs) + 1) + (CStr) ") : \r\n" + (CStr) StArgs + (CStr) "\r\n"; goto StoreArgs; NoStoreArgs: APIString = APIString + "-\r\n\r\n"; StoreArgs: MaxAPIArgs = StringGetSplitUBound(APIArgs); StringReleaseSplit(APIArgs); APIString = APIString + "Note: " + (CStr) StringGetSplitElement(FirstSplit, APIInfos, 4).Get_String() + (CStr) "\r\n"; APIString = APIString + "WinNT: " + (CStr) StringGetSplitElement(FirstSplit, APIInfos, 5).Get_String() + (CStr) "\r\n"; APIString = APIString + "Win95: " + (CStr) StringGetSplitElement(FirstSplit, APIInfos, 6).Get_String() + (CStr) "\r\n"; APIString = APIString + "Win32s: " + (CStr) StringGetSplitElement(FirstSplit, APIInfos, 7).Get_String(); if(APIhText == 0) { ChildStruct = LoadStructure(CurrentForm); CreateSplashDialog(dx, dy, 1, 1, "", ChildStruct->hChildCodeMax, 0, 0, &FRMAPIInitProc, &FRMAPIWinHook, 0, WS_DISABLED, SW_HIDE); } if(APIhText != 0) { APIArrParse = StringSplit(APIString, "\r\n"); if(APIhFont != 0) DeleteObject(APIhFont); APIhFont = GDIObtainFont(CurFontName, CurFontSize, hMDIform.hWnd, 0, 0); if(APIhFontBold == 0) DeleteObject(APIhFontBold); APIhFontBold = GDIObtainFont(CurFontName, CurFontSize, hMDIform.hWnd, 1, 0); ControlVisible(APIhText, 1); SendMessage(APIhText, WM_PAINT, 0, 0); } // Save API name BufString = StringGetSplitElement(FirstSplit, APIInfos, 0); } if(APIInfosLib != 0) StringReleaseSplit(APIInfos); } FreeMem((long) APIDescription); } ReturnValue = BufString; return(ReturnValue); }