diff --git a/src/plugins/shared/winliblt.cpp b/src/plugins/shared/winliblt.cpp index 812212afd..04e350842 100644 --- a/src/plugins/shared/winliblt.cpp +++ b/src/plugins/shared/winliblt.cpp @@ -1,5 +1,6 @@ // SPDX-FileCopyrightText: 2023 Open Salamander Authors // SPDX-License-Identifier: GPL-2.0-or-later +// CommentsTranslationProject: TRANSLATED //**************************************************************************** // @@ -16,7 +17,7 @@ #endif // _MSC_VER #include #include -//#include // potrebuju HIMAGELIST +//#include // HIMAGELIST is needed #include #ifdef __BORLANDC__ #include @@ -44,14 +45,14 @@ char CWINDOW_CLASSNAME[100] = ""; char CWINDOW_CLASSNAME2[100] = ""; // nema CS_VREDRAW | CS_HREDRAW -ATOM AtomObject = 0; // "property" okna s ukazatelem na objekt (pouzivane ve WindowsManageru) +ATOM AtomObject = 0; // windows "property" with a pointer to the object (used in WindowsManager) CWindowsManager WindowsManager; char WinLibStrings[WLS_COUNT][101] = { "Invalid number!", "Error"}; -FWinLibLTHelpCallback WinLibLTHelpCallback = NULL; // callbacku pro pripojeni na HTML help +FWinLibLTHelpCallback WinLibLTHelpCallback = NULL; // callback for connecting to HTML help // // **************************************************************************** @@ -74,7 +75,7 @@ BOOL InitializeWinLib(const char* pluginName, HINSTANCE dllInstance) lstrcpyn(CWINDOW_CLASSNAME2, pluginName, 50); strcat(CWINDOW_CLASSNAME2, " - WinLib Universal Window2"); - AtomObject = GlobalAddAtom("object handle"); // vsechny pluginy budou pouzivat stejny atom, zadna kolize + AtomObject = GlobalAddAtom("object handle"); // all plugins will use the same atom, no collision if (AtomObject == 0) { TRACE_E("GlobalAddAtom has failed"); @@ -104,13 +105,13 @@ void ReleaseWinLib(HINSTANCE dllInstance) { if (WindowsManager.WindowsCount != 0) { - // pruser - po unloadu pluginu muze spadnout soft, protoze se zavola window-procedura - // v unloadnutem DLL (jde-li o okna zabita v ramci zabitych threadu, je to OK) + // a difficult situation - after unload of the plugin, the soft can crash, because the window procedure is called + // in the unloaded DLL (if the window was killed in the killed thread, it is OK) TRACE_E("Unable to release WinLibLT - some window or dialog (count = " << WindowsManager.WindowsCount << ") is still attached to WinLibLT!"); - // return; // pokud slo o okno v killnutem threadu, pujde WinLibLT uvolnit, jinak unregister-funkce vrati error + // return; // if it was a window in the killed thread, WinLibLT will be able to be released, otherwise the unregister function will return an error } - // provedeme odregistrovani trid, aby pri dalsim loadu pluginu mohly byt znovu zaregistrovany + // deregister classes, so that they can be registered again when the plugin is loaded again if (CWINDOW_CLASSNAME2[0] != 0 && CWINDOW_CLASSNAME[0] != 0) { if (!UnregisterClass(CWINDOW_CLASSNAME2, dllInstance)) @@ -127,8 +128,8 @@ void ReleaseWinLib(HINSTANCE dllInstance) // **************************************************************************** // CWindow // -// lpvParam - v pripade, ze se pri CreateWindow zavola CWindow::CWindowProc -// (je v tride okna), musi obsahovat adresu objektu vytvareneho okna +// lpvParam - in case of calling CreateWindow from CWindow::CWindowProc +// (it is in the window class), it must contain the address of the created window object HWND CWindow::CreateEx(DWORD dwExStyle, // extended window style LPCTSTR lpszClassName, // address of registered class name @@ -141,7 +142,7 @@ HWND CWindow::CreateEx(DWORD dwExStyle, // extended window style HWND hwndParent, // handle of parent or owner window HMENU hmenu, // handle of menu or child-window identifier HINSTANCE hinst, // handle of application instance - LPVOID lpvParam) // ukazatel na objekt vytvareneho okna + LPVOID lpvParam) // pointer to the object of the created window { HWND hWnd = CreateWindowEx(dwExStyle, lpszClassName, @@ -157,8 +158,8 @@ HWND CWindow::CreateEx(DWORD dwExStyle, // extended window style lpvParam); if (hWnd != 0) { - if (WindowsManager.GetWindowPtr(hWnd) == NULL) // pokud se jeste neni ve WindowsManageru - AttachToWindow(hWnd); // tak ho pridame -> subclassing + if (WindowsManager.GetWindowPtr(hWnd) == NULL) // if it is not in WindowsManager yet + AttachToWindow(hWnd); // we will add it -> subclassing } return hWnd; } @@ -173,7 +174,7 @@ HWND CWindow::Create(LPCTSTR lpszClassName, // address of registered class name HWND hwndParent, // handle of parent or owner window HMENU hmenu, // handle of menu or child-window identifier HINSTANCE hinst, // handle of application instance - LPVOID lpvParam) // ukazatel na objekt vytvareneho okna + LPVOID lpvParam) // pointer to the object of the created window { return CreateEx(0, lpszClassName, @@ -207,7 +208,7 @@ void CWindow::AttachToWindow(HWND hWnd) HWindow = hWnd; SetWindowLongPtr(HWindow, GWLP_WNDPROC, (LONG_PTR)CWindowProc); - if (DefWndProc == CWindow::CWindowProc) // to by byla rekurze + if (DefWndProc == CWindow::CWindowProc) // this would be recursion { TRACE_C("This should never happen."); DefWndProc = DefWindowProc; @@ -252,8 +253,8 @@ CWindow::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) return TRUE; } if (GetWindowLong(HWindow, GWL_STYLE) & WS_CHILD) - break; // pokud F1 nezpracujeme a pokud je to child okno, nechame F1 propadnout do parenta - return TRUE; // pokud to neni child, ukoncime zpracovani F1 + break; // if we won't process F1 and it is a child window, we will let F1 go to the parent + return TRUE; // if it is not a child, we will end processing of F1 } } return CallWindowProc((WNDPROC)DefWndProc, HWindow, uMsg, wParam, lParam); @@ -265,9 +266,9 @@ CWindow::CWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) CWindow* wnd; switch (uMsg) { - case WM_CREATE: // prvni zprava - pripojeni objektu k oknu + case WM_CREATE: // first message - attaching the object to the window { - // osetrim MDI_CHILD_WINDOW + // handling MDI_CHILD_WINDOW if (((CREATESTRUCT*)lParam)->dwExStyle & WS_EX_MDICHILD) wnd = (CWindow*)((MDICREATESTRUCT*)((CREATESTRUCT*)lParam)->lpCreateParams)->lParam; else @@ -280,8 +281,8 @@ CWindow::CWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) else { wnd->HWindow = hwnd; - //--- zarazeni okna podle hwnd do seznamu oken - if (!WindowsManager.AddWindow(hwnd, wnd)) // chyba + //--- including the window by hwnd into the list of windows + if (!WindowsManager.AddWindow(hwnd, wnd)) // error { TRACE_E("Error during creating of window."); return FALSE; @@ -290,22 +291,22 @@ CWindow::CWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; } - case WM_DESTROY: // posledni zprava - odpojeni objektu od okna + case WM_DESTROY: // the last message - detaching the object from the window { wnd = (CWindow*)WindowsManager.GetWindowPtr(hwnd); if (wnd != NULL && wnd->Is(otWindow)) { - // Petr: posunul jsem dolu pod wnd->WindowProc(), aby behem WM_DESTROY - // jeste dochazely zpravy (potreboval Lukas) + // Petr: I moved it down below wnd->WindowProc() so that during WM_DESTROY + // messages could still arrive (Lukas needed it) // WindowsManager.DetachWindow(hwnd); LRESULT res = wnd->WindowProc(uMsg, wParam, lParam); - // ted uz zase do stare procedury (kvuli subclassingu) + // now into the old procedure again (because of subclassing) WindowsManager.DetachWindow(hwnd); - // pokud aktualni WndProc je jina nez nase, nebudeme ji menit, - // protoze nekdo v rade subclasseni uz vratil puvodni WndProc + // if the current WndProc is different from ours, we won't change it, + // because someone in the subclassing queue has already returned the original WndProc WNDPROC currentWndProc = (WNDPROC)GetWindowLongPtr(wnd->HWindow, GWLP_WNDPROC); if (currentWndProc == CWindow::CWindowProc) SetWindowLongPtr(wnd->HWindow, GWLP_WNDPROC, (LONG_PTR)wnd->DefWndProc); @@ -313,9 +314,9 @@ CWindow::CWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (wnd->IsAllocated()) delete wnd; else - wnd->HWindow = NULL; // uz neni pripojeny + wnd->HWindow = NULL; // not connected anymore if (res == 0) - return 0; // aplikace ji zpracovala + return 0; // processed by application wnd = NULL; } break; @@ -333,12 +334,12 @@ CWindow::CWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) #endif } } - //--- zavolani metody WindowProc(...) prislusneho objektu okna + //--- calling the method WindowProc(...) of the related object of the window if (wnd != NULL) return wnd->WindowProc(uMsg, wParam, lParam); else return DefWindowProc(hwnd, uMsg, wParam, lParam); - // chyba nebo message prisla pred WM_CREATE + // an error or the message came before WM_CREATE } BOOL CWindow::RegisterUniversalClass(HINSTANCE dllInstance) @@ -443,7 +444,7 @@ CDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: { TransferData(ttDataToWindow); - return TRUE; // chci focus od DefDlgProc + return TRUE; // focus from DefDlgProc is needed } case WM_HELP: @@ -453,7 +454,7 @@ CDialog::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { WinLibLTHelpCallback(HWindow, HelpID); } - return TRUE; // F1 nenechame propadnout do parenta ani pokud nevolame WinLibLTHelpCallback() + return TRUE; // F1 won't be passed to the parent even if we don't call WinLibLTHelpCallback() } case WM_COMMAND: @@ -497,7 +498,7 @@ CDialog::CDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) CDialog* dlg; switch (uMsg) { - case WM_INITDIALOG: // prvni zprava - pripojeni objektu k dialogu + case WM_INITDIALOG: // first message - attaching the object to the window { dlg = (CDialog*)lParam; if (dlg == NULL) @@ -508,25 +509,25 @@ CDialog::CDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) else { dlg->HWindow = hwndDlg; - //--- zarazeni okna podle hwndDlg do seznamu oken - if (!WindowsManager.AddWindow(hwndDlg, dlg)) // chyba + //--- including the window by hwndDlg into the list of windows + if (!WindowsManager.AddWindow(hwndDlg, dlg)) // error { TRACE_E("Error during creating of dialog."); return TRUE; } - dlg->NotifDlgJustCreated(); // zavedeno jako misto pro upravu layoutu dialogu + dlg->NotifDlgJustCreated(); // loaded as a place for layout modification of the dialog } break; } - case WM_DESTROY: // posledni zprava - odpojeni objektu od dialogu + case WM_DESTROY: // the last message - detaching the object from the window { dlg = (CDialog*)WindowsManager.GetWindowPtr(hwndDlg); - INT_PTR ret = FALSE; // pro pripad, ze ji nezpracuje + INT_PTR ret = FALSE; // in case it won't be processed if (dlg != NULL && dlg->Is(otDialog)) { - // Petr: posunul jsem dolu pod wnd->WindowProc(), aby behem WM_DESTROY - // jeste dochazely zpravy (potreboval Lukas) + // Petr: I moved it down below wnd->WindowProc() so that during WM_DESTROY + // messages could still arrive (Lukas needed it) // WindowsManager.DetachWindow(hwndDlg); ret = dlg->DialogProc(uMsg, wParam, lParam); @@ -535,7 +536,7 @@ CDialog::CDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if (dlg->IsAllocated()) delete dlg; else - dlg->HWindow = NULL; // informace o odpojeni + dlg->HWindow = NULL; // connection information } return ret; } @@ -552,11 +553,11 @@ CDialog::CDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) #endif } } - //--- zavolani metody DialogProc(...) prislusneho objektu dialogu + //--- calling the method DialogProc(...) of the related object of the dialog if (dlg != NULL) return dlg->DialogProc(uMsg, wParam, lParam); else - return FALSE; // chyba nebo message neprisla mezi WM_INITDIALOG a WM_DESTROY + return FALSE; // the error or the message did not come between WM_INITDIALOG and WM_DESTROY } // @@ -596,7 +597,7 @@ void CPropSheetPage::Init(char* title, HINSTANCE modul, int resID, Flags = flags; Icon = icon; - ParentDialog = NULL; // nastavuje se z CPropertyDialog::Execute() + ParentDialog = NULL; // set from CPropertyDialog::Execute() } CPropSheetPage::~CPropSheetPage() @@ -664,7 +665,7 @@ CPropSheetPage::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { ParentDialog->HWindow = Parent; TransferData(ttDataToWindow); - return TRUE; // chci focus od DefDlgProc + return TRUE; // focus from DefDlgProc is needed } case WM_HELP: @@ -675,38 +676,38 @@ CPropSheetPage::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) WinLibLTHelpCallback(HWindow, HelpID); return TRUE; } - break; // F1 nechame propadnout do parenta + break; // F1 to be passed to the parent } case WM_NOTIFY: { - if (((NMHDR*)lParam)->code == PSN_KILLACTIVE) // deaktivace stranky + if (((NMHDR*)lParam)->code == PSN_KILLACTIVE) // page deactivation { if (ValidateData()) SetWindowLongPtr(HWindow, DWLP_MSGRESULT, FALSE); - else // nepovolime deaktivaci stranky + else // we won't allow deactivation of the page SetWindowLongPtr(HWindow, DWLP_MSGRESULT, TRUE); return TRUE; } if (((NMHDR*)lParam)->code == PSN_HELP) - { // stisknuto tlacitko Help + { // Help button pressed if (WinLibLTHelpCallback != NULL && HelpID != -1) WinLibLTHelpCallback(HWindow, HelpID); return TRUE; } - if (((NMHDR*)lParam)->code == PSN_SETACTIVE) // aktivace stranky + if (((NMHDR*)lParam)->code == PSN_SETACTIVE) // page activation { if (ParentDialog != NULL && ParentDialog->LastPage != NULL) - { // zapamatovani posledni stranky + { // remembering the last page *ParentDialog->LastPage = ParentDialog->GetCurSel(); } break; } if (((NMHDR*)lParam)->code == PSN_APPLY) - { // stisknuto tlacitko ApplyNow nebo OK + { // ApplyNow or OK button pressed if (TransferData(ttDataFromWindow)) SetWindowLongPtr(HWindow, DWLP_MSGRESULT, PSNRET_NOERROR); else @@ -715,15 +716,15 @@ CPropSheetPage::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } if (((NMHDR*)lParam)->code == PSN_WIZFINISH) - { // stisknuto tlacitko Finish - // neprislo PSN_KILLACTIVE - provedu validaci + { // Finish button pressed + // PSN_KILLACTIVE not received - will validate if (!ValidateData()) { SetWindowLongPtr(HWindow, DWLP_MSGRESULT, TRUE); return TRUE; } - // obehnu vsechny stranky pro transfer + // going through all pages for transfer for (int i = 0; i < ParentDialog->Count; i++) { if (ParentDialog->At(i)->HWindow != NULL) @@ -751,7 +752,7 @@ CPropSheetPage::CPropSheetPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, CPropSheetPage* dlg; switch (uMsg) { - case WM_INITDIALOG: // prvni zprava - pripojeni objektu k dialogu + case WM_INITDIALOG: // the first message - attaching the object to the dialog { dlg = (CPropSheetPage*)((PROPSHEETPAGE*)lParam)->lParam; if (dlg == NULL) @@ -763,25 +764,25 @@ CPropSheetPage::CPropSheetPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, { dlg->HWindow = hwndDlg; dlg->Parent = ::GetParent(hwndDlg); - //--- zarazeni okna podle hwndDlg do seznamu oken + //--- including the window by hwndDlg into the list of windows if (!WindowsManager.AddWindow(hwndDlg, dlg)) // chyba { TRACE_E("Error during creating of dialog."); return TRUE; } - dlg->NotifDlgJustCreated(); // zavedeno jako misto pro upravu layoutu dialogu + dlg->NotifDlgJustCreated(); // loaded as a place for layout modification of the dialog } break; } - case WM_DESTROY: // posledni zprava - odpojeni objektu od dialogu + case WM_DESTROY: // the last message - detaching the object from the dialog { dlg = (CPropSheetPage*)WindowsManager.GetWindowPtr(hwndDlg); - INT_PTR ret = FALSE; // pro pripad, ze ji nezpracuje + INT_PTR ret = FALSE; // in case it won't be processed if (dlg != NULL && dlg->Is(otDialog)) { - // Petr: posunul jsem dolu pod wnd->WindowProc(), aby behem WM_DESTROY - // jeste dochazely zpravy (potreboval Lukas) + // Petr: I moved it down below wnd->WindowProc() so that during WM_DESTROY + // messages could still arrive (Lukas needed it) // WindowsManager.DetachWindow(hwndDlg); ret = dlg->DialogProc(uMsg, wParam, lParam); @@ -790,7 +791,7 @@ CPropSheetPage::CPropSheetPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, if (dlg->IsAllocated()) delete dlg; else - dlg->HWindow = NULL; // informace o odpojeni + dlg->HWindow = NULL; // information about disconnection } return ret; } @@ -807,11 +808,11 @@ CPropSheetPage::CPropSheetPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, #endif } } - //--- zavolani metody DialogProc(...) prislusneho objektu dialogu + //--- calling the method DialogProc(...) of the related object of the dialog if (dlg != NULL) return dlg->DialogProc(uMsg, wParam, lParam); else - return FALSE; // chyba nebo message neprisla mezi WM_INITDIALOG a WM_DESTROY + return FALSE; // the error or the message did not come between WM_INITDIALOG and WM_DESTROY } // @@ -915,9 +916,9 @@ CWindowsManager::GetWindowPtr(HWND hWnd) CWindowQueue::~CWindowQueue() { if (!Empty()) - TRACE_E("Some window is still opened in " << QueueName << " queue!"); // nemelo by nastat... - // tady uz multi-threadovost nehrozi (konci plugin, thready jsou/byly ukonceny) - // dealokujeme aspon nejakou pamet + TRACE_E("Some window is still opened in " << QueueName << " queue!"); // should not happen... + // multi-threadiness is not a problem here (plugin is ending, threads are/will be terminated) + // we will deallocate at least some memory CWindowQueueItem* last; CWindowQueueItem* item = Head; while (item != NULL) @@ -949,7 +950,7 @@ void CWindowQueue::Remove(HWND hWindow) CWindowQueueItem* item = Head; while (item != NULL) { - if (item->HWindow == hWindow) // nalezeno, odstranime + if (item->HWindow == hWindow) // found, to be removed { if (last != NULL) last->Next = item->Next; @@ -988,16 +989,16 @@ void CWindowQueue::BroadcastMessage(DWORD uMsg, WPARAM wParam, LPARAM lParam) BOOL CWindowQueue::CloseAllWindows(BOOL force, int waitTime, int forceWaitTime) { - // posleme zadost o zavreni vsech oken + // sending request to close all windows BroadcastMessage(WM_CLOSE, 0, 0); - // pockame az/jestli se zavrou + // waiting until/if all windows are closed DWORD ti = GetTickCount(); DWORD w = force ? forceWaitTime : waitTime; while ((w == INFINITE || w > 0) && !Empty()) { DWORD t = GetTickCount() - ti; - if (w == INFINITE || t < w) // mame jeste cekat + if (w == INFINITE || t < w) // should we wait more? { if (w == INFINITE || 50 < w - t) Sleep(50); @@ -1021,7 +1022,7 @@ BOOL CWindowQueue::CloseAllWindows(BOOL force, int waitTime, int forceWaitTime) BOOL CTransferInfo::GetControl(HWND& ctrlHWnd, int ctrlID, BOOL ignoreIsGood) { if (!ignoreIsGood && !IsGood()) - return FALSE; // dalsi nema cenu zpracovavat + return FALSE; // not worth processing another ctrlHWnd = GetDlgItem(HDialog, ctrlID); if (ctrlHWnd == NULL) { @@ -1041,8 +1042,8 @@ void CTransferInfo::EnsureControlIsFocused(int ctrlID) HWND wnd = GetFocus(); while (wnd != NULL && wnd != ctrl) wnd = ::GetParent(wnd); - if (wnd == NULL) // fokusime jen pokud neni ctrl predek GetFocusu - { // jako napr. edit-line v combo-boxu + if (wnd == NULL) // focus only if ctrl is not a child of GetFocus() + { // like e.g. edit-line in combo-box SendMessage(HDialog, WM_NEXTDLGCTL, (WPARAM)ctrl, TRUE); } } @@ -1100,8 +1101,8 @@ void CTransferInfo::EditLine(int ctrlID, double& value, char* format, BOOL selec BOOL decPoints = FALSE; BOOL expPart = FALSE; if (*s == '-' || *s == '+') - s++; // preskok znamenka - while (*s != 0) // prevod carky na tecku + s++; // skipping sign + while (*s != 0) // conversion of comma to dot { if (!expPart && !decPoints && (*s == ',' || *s == '.')) { @@ -1114,7 +1115,7 @@ void CTransferInfo::EditLine(int ctrlID, double& value, char* format, BOOL selec { expPart = TRUE; if (*(s + 1) == '+' || *(s + 1) == '-') - s++; // preskok +- za E + s++; // skipping +- after exponent } else { @@ -1130,9 +1131,9 @@ void CTransferInfo::EditLine(int ctrlID, double& value, char* format, BOOL selec s++; } if (*s == 0) - value = atof(buff); // jen pokud je cislo + value = atof(buff); // only if it is a number else - value = 0; // pri chybe dame nulu + value = 0; // on error we will give zero break; } } @@ -1162,8 +1163,8 @@ void CTransferInfo::EditLine(int ctrlID, int& value, BOOL select) char* s = buff; if (*s == '-' || *s == '+') - s++; // preskok znamenka - while (*s != 0) // kontrola cisla + s++; // skipping sign + while (*s != 0) // checking the number { if (*s < '0' || *s > '9') { @@ -1176,7 +1177,7 @@ void CTransferInfo::EditLine(int ctrlID, int& value, BOOL select) } char* endptr; - value = strtoul(buff, &endptr, 10); // nahrada za atoi / _ttoi, ktere misto 4000000000 vraci 2147483647 (protoze je to SIGNED INT) + value = strtoul(buff, &endptr, 10); // replacement for atoi / _ttoi, which returns 2147483647 instead of 4000000000 (because it is SIGNED INT) break; } } diff --git a/src/plugins/shared/winliblt.h b/src/plugins/shared/winliblt.h index 58dedbd68..22b8bc63f 100644 --- a/src/plugins/shared/winliblt.h +++ b/src/plugins/shared/winliblt.h @@ -1,5 +1,6 @@ // SPDX-FileCopyrightText: 2023 Open Salamander Authors // SPDX-License-Identifier: GPL-2.0-or-later +// CommentsTranslationProject: TRANSLATED //**************************************************************************** // @@ -9,33 +10,35 @@ // //**************************************************************************** -// "light" verze WinLibu +// "light" version of WinLib #pragma once -// makra pro potlaceni nepotrebnych casti WinLibLT (snazsi kompilace): -// ENABLE_PROPERTYDIALOG - je-li definovano, je mozne pouzivat property sheet dialog (CPropertyDialog) +// macros to suppress unnecessary parts of WinLibLT (easier compilation): +// ENABLE_PROPERTYDIALOG - if defined, it is possible to use the property sheet dialog (CPropertyDialog) +// Set custom strings in WinLib // nastaveni vlastnich textu do WinLibu -void SetWinLibStrings(const char* invalidNumber, // "neni cislo" (u transferbufferu cisel) - const char* error); // titulek "chyba" (u transferbufferu cisel) - -// je potreba zavolat pred pouzitim WinLibu; 'pluginName' je jmeno pluginu (napr. "DEMOPLUG"), -// pouziva se pro odliseni jmen trid univerzalnich oken WinLibu (mezi pluginy se musi lisit, -// jinak nastane kolize jmen trid a WinLib nemuze fungovat - bude fungovat jen prvni spusteny -// plugin); 'dllInstance' je modul pluginu (pouziva se pri registraci univerzalnich trid WinLibu) +void SetWinLibStrings(const char* invalidNumber, // "not a number" (for number transfer buffer) + const char* error); // title "error" (for number transfer buffer) + +// must be called before using WinLib; 'pluginName' is the name of the plugin (e.g. "DEMOPLUG"), +// it is used to distinguish the names from WibLib universal windows classes (the names of the +// classes must be different for different plugins, otherwise there will be a conflict of class +// names and WinLib will not work - only the first loaded plugin will work); 'dllInstance' is +// the module of the plugin (it is used for registration of WinLib universal classes) BOOL InitializeWinLib(const char* pluginName, HINSTANCE dllInstance); -// je potreba zavolat po pouziti WinLibu; 'dllInstance' je modul pluginu (pouziva se pri zruseni -// registrace univerzalnich trid WinLibu) +// must be called after using WinLib; 'dllInstance' is the module of the plugin (it is used for +// cancellation of registration of WinLib universal classes) void ReleaseWinLib(HINSTANCE dllInstance); -// typ callbacku pro pripojeni na HTML help +// callback type for connection to HTML help typedef void(WINAPI* FWinLibLTHelpCallback)(HWND hWindow, UINT helpID); -// nastaveni callbacku pro pripojeni na HTML help +// set callback for connection to HTML help void SetupWinLibHelp(FWinLibLTHelpCallback helpCallback); -// konstanty pro stringy WinLibu (jen interni pouziti ve WinLibu) +// constants for WinLib strings (only internal use in WinLib) enum CWLS { WLS_INVALID_NUMBER, @@ -44,21 +47,21 @@ enum CWLS WLS_COUNT }; -extern char CWINDOW_CLASSNAME[100]; // jmeno tridy universalniho okna -extern char CWINDOW_CLASSNAME2[100]; // jmeno tridy universalniho okna - nema CS_VREDRAW | CS_HREDRAW +extern char CWINDOW_CLASSNAME[100]; // class name of universal window +extern char CWINDOW_CLASSNAME2[100]; // class name of universal window - without CS_VREDRAW | CS_HREDRAW // **************************************************************************** -enum CObjectOrigin // pouzito pri destrukci oken a dialogu +enum CObjectOrigin // used for destruction of windows and dialogs { - ooAllocated, // pri WM_DESTROY se bude dealokovat - ooStatic, // pri WM_DESTROY se HWindow nastavi na NULL - ooStandard // pro modalni dlg =ooStatic, pro nemodalni dlg =ooAllocated + ooAllocated, // will be deallocated in WM_DESTROY + ooStatic, // HWindows will be set to NULL in WM_DESTROY + ooStandard // for modal dialog ==ooStatic, for non-modal dialog ==ooAllocated }; // **************************************************************************** -enum CObjectType // pro rozpoznani typu objektu +enum CObjectType // for recognition of object type { otBase, otWindow, @@ -71,7 +74,7 @@ enum CObjectType // pro rozpoznani typu objektu // **************************************************************************** -class CWindowsObject // predek vsech MS-Windows objektu +class CWindowsObject // parent of all MS-Windows objects { public: HWND HWindow; @@ -90,9 +93,9 @@ class CWindowsObject // predek vsech MS-Windows objektu SetHelpID(helpID); } - virtual ~CWindowsObject() {} // aby se u potomku volal jejich destruktor + virtual ~CWindowsObject() {} // so that the destructor of the child is called - virtual BOOL Is(int) { return FALSE; } // identifikace objektu + virtual BOOL Is(int) { return FALSE; } // object identification virtual int GetObjectType() { return otBase; } virtual BOOL IsAllocated() { return ObjectOrigin == ooAllocated; } @@ -132,11 +135,13 @@ class CWindow : public CWindowsObject virtual BOOL Is(int type) { return type == otWindow; } virtual int GetObjectType() { return otWindow; } - // registruje univerzalni tridy WinLibu, vola se automaticky (registraci rusi tez automaticky) + // registers universal WinLib classes, it is called automatically (the registration is also + // cancelled automatically) static BOOL RegisterUniversalClass(HINSTANCE dllInstance); - // registrace vlastni univerzalni tridy; POZOR: pri unloadu pluginu je nutne zrusit registraci tridy, - // jinak pri opakovanem loadu pluginu dojde k chybe pri registraci (konflikt se starou tridou) + // registration of a custom universal class; WARNING: when unloading the plugin, it is necessary + // to cancel the registration of the class, otherwise there will be an error when registering + // (conflict with the old class) static BOOL RegisterUniversalClass(UINT style, int cbClsExtra, int cbWndExtra, @@ -158,7 +163,7 @@ class CWindow : public CWindowsObject HWND hwndParent, // handle of parent or owner window HMENU hmenu, // handle of menu or child-window identifier HINSTANCE hinst, // handle of application instance - LPVOID lpvParam); // ukazatel na objekt vytvareneho okna + LPVOID lpvParam); // pointer to the object of the created window HWND CreateEx(DWORD dwExStyle, // extended window style LPCTSTR lpszClassName, // address of registered class name @@ -171,7 +176,7 @@ class CWindow : public CWindowsObject HWND hwndParent, // handle of parent or owner window HMENU hmenu, // handle of menu or child-window identifier HINSTANCE hinst, // handle of application instance - LPVOID lpvParam); // ukazatel na objekt vytvareneho okna + LPVOID lpvParam); // pointer to the object of the created window void AttachToWindow(HWND hWnd); void AttachToControl(HWND dlg, int ctrlID); @@ -190,8 +195,8 @@ class CWindow : public CWindowsObject enum CTransferType { - ttDataToWindow, // data jdou do okna - ttDataFromWindow // data jdou z okna + ttDataToWindow, // data come to window + ttDataFromWindow // data come from window }; // **************************************************************************** @@ -199,7 +204,7 @@ enum CTransferType class CTransferInfo { public: - int FailCtrlID; // INT_MAX - vse v poradku, jinak ID controlu s chybou + int FailCtrlID; // INT_MAX - everything is OK, otherwise ID of the control with error CTransferType Type; CTransferInfo(HWND hDialog, CTransferType type) @@ -218,15 +223,15 @@ class CTransferInfo void RadioButton(int ctrlID, int ctrlValue, int& value); void CheckBox(int ctrlID, int& value); // 0-unchecked, 1-checked, 2-grayed - // kontroluje double hodnotu (pokud to neni cislo, neprojde), oddelovac muze byt '.' i ','; - // 'format' se pouziva v sprintf pri prevodu cisla na retezec (napr. "%.2f" nebo "%g") + // checks double value (if it is not a number, it will not pass), the separator can be '.' or ','; + // 'format' is used in sprintf when converting a number to a string (e.g. "%.2f" or "%g") void EditLine(int ctrlID, double& value, char* format, BOOL select = TRUE); - // kontroluje int hodnotu (pokud to neni cislo, neprojde) + // checks int value (if it is not a number, it will not pass) void EditLine(int ctrlID, int& value, BOOL select = TRUE); protected: - HWND HDialog; // handle dialogu, pro ktery se provadi transfer + HWND HDialog; // handle of the dialog which the transfer is for }; // **************************************************************************** @@ -235,8 +240,8 @@ class CDialog : public CWindowsObject { public: #ifdef ENABLE_PROPERTYDIALOG - CWindowsObject::HWindow; // kvuli zkompilovatelnosti CPropSheetPage - CWindowsObject::SetObjectOrigin; // kvuli zkompilovatelnosti CPropSheetPage + CWindowsObject::HWindow; // for compilability of CPropSheetPage + CWindowsObject::SetObjectOrigin; // for compilability of CPropSheetPage #endif // ENABLE_PROPERTYDIALOG CDialog(HINSTANCE modul, int resID, HWND parent, @@ -268,8 +273,8 @@ class CDialog : public CWindowsObject (!Modal && ObjectOrigin == ooStandard); } void SetParent(HWND parent) { Parent = parent; } - INT_PTR Execute(); // modalni dialog - HWND Create(); // nemodalni dialog + INT_PTR Execute(); // modal dialog + HWND Create(); // non-modal dialog static INT_PTR CALLBACK CDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -279,7 +284,7 @@ class CDialog : public CWindowsObject virtual void NotifDlgJustCreated() {} - BOOL Modal; // kvuli zpusobu destrukce dialogu + BOOL Modal; // due to the method of destruction of the dialog HINSTANCE Modul; int ResID; HWND Parent; @@ -294,14 +299,14 @@ class CPropertyDialog; class CPropSheetPage : protected CDialog { public: - CDialog::HWindow; // HWindow zustane pristupne + CDialog::HWindow; // HWindow remains accessible - CDialog::SetObjectOrigin; // zpristupneni povolenych metod predku + CDialog::SetObjectOrigin; // making the allowed methods of the parent accessible CDialog::Transfer; - // testovano s resourcem dialogu stranky se stylem: + // tested with the resource of the dialog of the page with the style: // DS_CONTROL | DS_3DLOOK | WS_CHILD | WS_CAPTION; - // pokud chceme pouzit primo titulek z resourcu, staci dat 'title'==NULL a + // if we want to use the title directly from the resource, it is enough to set 'title'==NULL and // 'flags'==0 CPropSheetPage(char* title, HINSTANCE modul, int resID, DWORD flags /* = PSP_USETITLE*/, HICON icon, @@ -332,7 +337,7 @@ class CPropSheetPage : protected CDialog DWORD Flags; HICON Icon; - CPropertyDialog* ParentDialog; // vlastnik teto stranky + CPropertyDialog* ParentDialog; // owner of this page friend class CPropertyDialog; }; @@ -342,11 +347,11 @@ class CPropSheetPage : protected CDialog class CPropertyDialog : public TIndirectArray { public: - // do tohoto objektu je idealni pridat objekty jednotlivych stranek - // a pak je jako "staticke" (defaultni volba) napridavat pres metodu Add; - // 'startPage' a 'lastPage' muze byt jen jedina promenna (hodnota in/odkaz out); - // 'flags' viz help k 'PROPSHEETHEADER', pouzitelne hlavne konstanty - // PSH_NOAPPLYNOW, PSH_USECALLBACK a PSH_HASHELP (jinak staci 'flags'==0) + // it is ideal to add objects of individual pages to this object + // and then add them as "static" (default choice) via the Add method; + // 'startPage' and 'lastPage' can be only one variable (value in/link out); + // 'flags' see help for 'PROPSHEETHEADER', useful constants are + // PSH_NOAPPLYNOW, PSH_USECALLBACK and PSH_HASHELP (otherwise 'flags'==0) CPropertyDialog(HWND parent, HINSTANCE modul, char* caption, int startPage, DWORD flags, HICON icon = NULL, DWORD* lastPage = NULL, PFNPROPSHEETCALLBACK callback = NULL) @@ -368,7 +373,7 @@ class CPropertyDialog : public TIndirectArray virtual int GetCurSel(); protected: - HWND Parent; // parametry pro vytvareni dialogu + HWND Parent; // parameters for creating the dialog HWND HWindow; HINSTANCE Modul; HICON Icon; @@ -377,7 +382,7 @@ class CPropertyDialog : public TIndirectArray DWORD Flags; PFNPROPSHEETCALLBACK Callback; - DWORD* LastPage; // posledni zvolena stranka (muze byt NULL, pokud nezajima) + DWORD* LastPage; // the last selected page (can be NULL, if not interested) friend class CPropSheetPage; }; @@ -389,7 +394,7 @@ class CPropertyDialog : public TIndirectArray class CWindowsManager { public: - int WindowsCount; // pocet oken obsluhovanych WinLibem (aktualni stav) + int WindowsCount; // number of windows handled by WinLib (current state) public: CWindowsManager() { WindowsCount = 0; } @@ -416,10 +421,10 @@ struct CWindowQueueItem class CWindowQueue { protected: - const char* QueueName; // jmeno fronty (jen pro debugovaci ucely) + const char* QueueName; // queue name (only for debugging purposes) CWindowQueueItem* Head; - struct CCS // pristup z vice threadu -> nutna synchronizace + struct CCS // access from multiple threads -> synchronization is necessary { CRITICAL_SECTION cs; @@ -431,24 +436,25 @@ class CWindowQueue } CS; public: - CWindowQueue(const char* queueName /* napr. "DemoPlug Viewers" */) + CWindowQueue(const char* queueName /* e.g. "DemoPlug Viewers" */) { QueueName = queueName; Head = NULL; } ~CWindowQueue(); - BOOL Add(CWindowQueueItem* item); // prida polozku do fronty, vraci uspech - void Remove(HWND hWindow); // odstrani polozku z fronty - BOOL Empty(); // vraci TRUE pokud je fronta prazdna + BOOL Add(CWindowQueueItem* item); // adds item to the queue, returns success + void Remove(HWND hWindow); // removes item from the queue + BOOL Empty(); // returns TRUE if the queue is empty - // posle (PostMessage - okna muzou byt v ruznych threadech) vsem oknum zpravu + // sends (PostMessage - windows can be in different threads) message to all windows in the queue void BroadcastMessage(DWORD uMsg, WPARAM wParam, LPARAM lParam); - // broadcastne WM_CLOSE, pak ceka na prazdnou frontu (max. cas dle 'force' bud 'forceWaitTime' - // nebo 'waitTime'); vraci TRUE pokud je fronta prazdna (vsechna okna se zavrela) - // nebo je 'force' TRUE; cas INFINITE = neomezene dlouhe cekani - // Poznamka: pri 'force' TRUE vraci vzdy TRUE, nema smysl na nic cekat, proto forceWaitTime = 0 + // broadcasts WM_CLOSE, then waits for an empty queue (max. time according to 'force' will be + // 'forceWaitTime' or 'waitTime'); returns TRUE if the queue is empty (all windows were closed) + // or 'force' is TRUE; time INFINITE = unlimited waiting + // Note: when 'force' is TRUE, it always returns TRUE, there is no point in waiting for anything, + // therefore forceWaitTime = 0 BOOL CloseAllWindows(BOOL force, int waitTime = 1000, int forceWaitTime = 0); };