From 06fcc164841b81fadf2d6197bcc8c2f2aa20e950 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 28 Oct 2019 12:52:02 +0300 Subject: code cleaning --- plugins/UserInfoEx/src/classPsTreeItem.cpp | 2 +- plugins/UserInfoEx/src/dlg_propsheet.cpp | 17 ++- plugins/UserInfoEx/src/dlg_propsheet.h | 166 ++++++++++++++--------------- 3 files changed, 91 insertions(+), 94 deletions(-) (limited to 'plugins/UserInfoEx/src') diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp index aac56ca1bd..fa09565ef9 100644 --- a/plugins/UserInfoEx/src/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp @@ -383,7 +383,7 @@ int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp) wchar_t szTitle[ MAXSETTING ]; // check parameter - if (pPsh && pPsh->_dwSize == sizeof(CPsHdr) && odp && PtrIsValid(odp->pPlugin)) { + if (pPsh && odp && PtrIsValid(odp->pPlugin)) { // instance value _hInst = odp->pPlugin->getInst(); _dwFlags = odp->flags; diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index ae3378cfff..8946945159 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -64,7 +64,6 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar CPsHdr::CPsHdr() : _ignore(10, wcscmp) { - _dwSize = sizeof(*this); _hContact = NULL; _pszProto = nullptr; _pszPrefix = nullptr; @@ -314,7 +313,7 @@ static INT_PTR AddPage(WPARAM wParam, LPARAM lParam) OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE *)lParam; // check size of the handled structures - if (pPsh == nullptr || odp == nullptr || pPsh->_dwSize != sizeof(CPsHdr)) + if (pPsh == nullptr || odp == nullptr) return 1; // try to check whether the flag member is initialized or not @@ -557,16 +556,12 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar switch (uMsg) { case WM_INITDIALOG: + TranslateDialogDefault(hDlg); { - CPsHdr* pPsh = (CPsHdr *)lParam; - WORD needWidth = 0; - RECT rc; - - if (!pPsh || pPsh->_dwSize != sizeof(CPsHdr)) + CPsHdr *pPsh = (CPsHdr *)lParam; + if (!pPsh) return FALSE; - TranslateDialogDefault(hDlg); - // create data structures if (!(pPs = (LPPS)mir_alloc(sizeof(PS)))) return FALSE; @@ -623,6 +618,7 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar pPs->hBoldFont = CreateFontIndirect(&lf); // initialize the optionpages and tree control + WORD needWidth = 0; if (!pPs->pTree->InitTreeItems((LPWORD)&needWidth)) return FALSE; @@ -658,7 +654,10 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar pPs->rcDisplay.bottom - pPs->rcDisplay.top, FALSE); } + + RECT rc; GetClientRect(GetDlgItem(hDlg, IDC_PAGETITLEBG), &rc); + // calculate dislpay area for pages OffsetRect(&pPs->rcDisplay, -pt.x, -pt.y); pPs->rcDisplay.bottom = rcTree.bottom; diff --git a/plugins/UserInfoEx/src/dlg_propsheet.h b/plugins/UserInfoEx/src/dlg_propsheet.h index a71addd386..6bdd973173 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.h +++ b/plugins/UserInfoEx/src/dlg_propsheet.h @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef struct TPropSheet PS, *LPPS; -class CPsHdr; +struct CPsHdr; class CPsTree; /*********************************************************************************************************** @@ -32,42 +32,42 @@ class CPsTree; class CPsTreeItem { - int _idDlg; // resource id of the property page - LPDLGTEMPLATE _pTemplate; // locked template for the property page - HINSTANCE _hInst; // instance handle of the owning plugin dll - DLGPROC _pfnDlgProc; // dialog procedure for the property page - HWND _hWnd; // window handle for the property page if shown jet - DWORD _dwFlags; // some flags - int _iPosition; // initiating position if custom (used for sorting) - LPARAM _initParam; - MCONTACT _hContact; // contact the page is accociated with (may be a meta subcontact if details dialog is shown for a meta contact) - LPCSTR _pszProto; // protocol the page is accociated with (is the contact's protocol if _hContact is not NULL) - LPCSTR _pszPrefix; // pointer to the dialog owning contact's protocol - - HTREEITEM _hItem; // handle to the treeview item if visible (NULL if this item is hidden) - int _iParent; // index of the owning tree item - int _iImage; // index of treeview item's image - BYTE _bState; // initial state of this treeitem - LPSTR _pszName; // original name, given by plugin (not customized) - LPTSTR _ptszLabel; // string to setting in db holding information about this treeitem + int _idDlg; // resource id of the property page + LPDLGTEMPLATE _pTemplate; // locked template for the property page + HINSTANCE _hInst; // instance handle of the owning plugin dll + DLGPROC _pfnDlgProc; // dialog procedure for the property page + HWND _hWnd; // window handle for the property page if shown jet + DWORD _dwFlags; // some flags + int _iPosition; // initiating position if custom (used for sorting) + LPARAM _initParam; + MCONTACT _hContact; // contact the page is accociated with (may be a meta subcontact if details dialog is shown for a meta contact) + LPCSTR _pszProto; // protocol the page is accociated with (is the contact's protocol if _hContact is not NULL) + LPCSTR _pszPrefix; // pointer to the dialog owning contact's protocol + + HTREEITEM _hItem; // handle to the treeview item if visible (NULL if this item is hidden) + int _iParent; // index of the owning tree item + int _iImage; // index of treeview item's image + BYTE _bState; // initial state of this treeitem + LPSTR _pszName; // original name, given by plugin (not customized) + LPTSTR _ptszLabel; // string to setting in db holding information about this treeitem LPCSTR GlobalName(); - int Name(LPTSTR pszTitle, const BYTE bIsUnicode); - int ItemLabel(const BYTE bReadDBValue); - + int Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, BYTE bInitIconsOnly); + int ItemLabel(const BYTE bReadDBValue); + int Name(LPTSTR pszTitle, const BYTE bIsUnicode); HICON ProtoIcon(); - int Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, BYTE bInitIconsOnly); public: CPsTreeItem(); ~CPsTreeItem(); + int Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp); + void Rename(const LPTSTR pszLabel); __inline LPSTR Name() const { return _pszName; }; __inline LPCSTR Proto() const { return _pszProto; }; __inline LPTSTR Label() const { return _ptszLabel; }; - void Rename( const LPTSTR pszLabel ); __inline MCONTACT hContact() const { return _hContact; }; __inline HWND Wnd() const { return _hWnd; }; @@ -132,17 +132,18 @@ public: #define PSTVF_STATE_CHANGED 0x00100000 #define PSTVF_INITICONS 0x00200000 // flag that indicates the AddPage handler to load only basic stuff -class CPsTree { - HWND _hWndTree; - HIMAGELIST _hImages; - CPsTreeItem** _pItems; - int _curItem; - int _numItems; - DWORD _dwFlags; - HWND _hLabelEdit; - HTREEITEM _hDragItem; - BYTE _isDragging; - LPPS _pPs; +class CPsTree +{ + HWND _hWndTree; + HIMAGELIST _hImages; + CPsTreeItem **_pItems; + int _curItem; + int _numItems; + DWORD _dwFlags; + HWND _hLabelEdit; + HTREEITEM _hDragItem; + BYTE _isDragging; + LPPS _pPs; WORD SaveItemsState(LPCSTR pszGroup, HTREEITEM hRootItem, int& iItem); @@ -171,35 +172,35 @@ public: __inline int CurrentItemIndex() const { return _curItem; }; __inline CPsTreeItem* CurrentItem() const { return TreeItem(CurrentItemIndex()); }; - int AddDummyItem(LPCSTR pszGroup); - BYTE Create(HWND hWndTree, CPsHdr* pPsh); - BYTE InitTreeItems(LPWORD needWidth); - - void HideItem(const int iPageIndex); + int AddDummyItem(LPCSTR pszGroup); + BYTE Create(HWND hWndTree, CPsHdr *pPsh); + BYTE InitTreeItems(LPWORD needWidth); + + void HideItem(const int iPageIndex); HTREEITEM ShowItem(const int iPageIndex, LPWORD needWidth); HTREEITEM MoveItem(HTREEITEM hItem, HTREEITEM hInsertAfter, BYTE bAsChild = FALSE); - void SaveState(); - void DBResetState(); - - int FindItemIndexByHandle(HTREEITEM hItem); - int FindItemIndexByName(LPCSTR pszName); - - CPsTreeItem* FindItemByName(LPCSTR pszName); - CPsTreeItem* FindItemByHandle(HTREEITEM hItem); - HTREEITEM FindItemHandleByName(LPCSTR pszName); - CPsTreeItem* FindItemByResource(HINSTANCE hInst, int idDlg); - - int BeginLabelEdit( HTREEITEM hItem ); - int EndLabelEdit( const BYTE bSave ); - void PopupMenu(); - - void OnIconsChanged(); - BYTE OnInfoChanged(); - BYTE OnSelChanging(); - void OnSelChanged(LPNMTREEVIEW lpnmtv); - void OnCancel(); - int OnApply(); + void SaveState(); + void DBResetState(); + + int FindItemIndexByHandle(HTREEITEM hItem); + int FindItemIndexByName(LPCSTR pszName); + + CPsTreeItem *FindItemByName(LPCSTR pszName); + CPsTreeItem *FindItemByHandle(HTREEITEM hItem); + HTREEITEM FindItemHandleByName(LPCSTR pszName); + CPsTreeItem *FindItemByResource(HINSTANCE hInst, int idDlg); + + int BeginLabelEdit(HTREEITEM hItem); + int EndLabelEdit(const BYTE bSave); + void PopupMenu(); + + void OnIconsChanged(); + BYTE OnInfoChanged(); + BYTE OnSelChanging(); + void OnSelChanged(LPNMTREEVIEW lpnmtv); + void OnCancel(); + int OnApply(); }; /*********************************************************************************************************** @@ -207,33 +208,30 @@ public: ***********************************************************************************************************/ // internal flags for the PSP structure -#define PSPF_CHANGED 4096 -#define PSPF_PROTOPREPENDED 8192 // the first token of the title is the protocol +#define PSPF_CHANGED 4096 +#define PSPF_PROTOPREPENDED 8192 // the first token of the title is the protocol -#define PSF_PROTOPAGESONLY 64 // load only contact's protocol pages -#define PSF_PROTOPAGESONLY_INIT 128 +#define PSF_PROTOPAGESONLY 64 // load only contact's protocol pages +#define PSF_PROTOPAGESONLY_INIT 128 class CPsUpload; -class CPsHdr +struct CPsHdr { -public: - DWORD _dwSize; // size of this class in bytes - MCONTACT _hContact; // handle to the owning contact - LPCSTR _pszProto; // owning contact's protocol - LPCSTR _pszPrefix; // name prefix for treeitem settings - CPsTreeItem** _pPages; // the pages - WORD _numPages; // number of pages - DWORD _dwFlags; // some option flags - HIMAGELIST _hImages; // the imagelist with all tree item icons - LIST _ignore; // list of to skipp items when adding metasubcontacts pages - int _nSubContact; // index of a current subcontact + MCONTACT _hContact; // handle to the owning contact + LPCSTR _pszProto; // owning contact's protocol + LPCSTR _pszPrefix; // name prefix for treeitem settings + CPsTreeItem** _pPages; // the pages + WORD _numPages; // number of pages + DWORD _dwFlags; // some option flags + HIMAGELIST _hImages; // the imagelist with all tree item icons + LIST _ignore; // list of skipped items when adding metasubcontacts pages + int _nSubContact; // index of a current subcontact CPsHdr(); ~CPsHdr(); void Free_pPages(); - }; struct TAckInfo @@ -249,9 +247,9 @@ struct TPropSheet MCONTACT hContact; CHAR pszProto[MAXMODULELABELLENGTH]; - HANDLE hProtoAckEvent; // eventhook for protocol acks - HANDLE hSettingChanged; // eventhook searching for changed contact information - HANDLE hIconsChanged; // eventhook for changed icons in icolib + HANDLE hProtoAckEvent; // eventhook for protocol acks + HANDLE hSettingChanged; // eventhook searching for changed contact information + HANDLE hIconsChanged; // eventhook for changed icons in icolib HFONT hCaptionFont; HFONT hBoldFont; RECT rcDisplay; @@ -268,6 +266,6 @@ struct TPropSheet CPsUpload *pUpload; }; -void DlgContactInfoInitTreeIcons(); -void DlgContactInfoLoadModule(); -void DlgContactInfoUnLoadModule(); +void DlgContactInfoInitTreeIcons(); +void DlgContactInfoLoadModule(); +void DlgContactInfoUnLoadModule(); -- cgit v1.2.3