diff options
Diffstat (limited to 'plugins/UserInfoEx/src')
21 files changed, 1230 insertions, 1444 deletions
diff --git a/plugins/UserInfoEx/src/classMAnnivDate.cpp b/plugins/UserInfoEx/src/classMAnnivDate.cpp index b1c4a8f9ee..940ddcda6c 100644 --- a/plugins/UserInfoEx/src/classMAnnivDate.cpp +++ b/plugins/UserInfoEx/src/classMAnnivDate.cpp @@ -588,7 +588,7 @@ int MAnnivDate::DBGetAnniversaryDate(MCONTACT hContact, uint16_t iIndex) // read description
mir_snprintf(szStamp, "Anniv%dDesc", iIndex);
DBVARIANT dbv;
- if (!DB::Setting::GetTString(hContact, USERINFO, szStamp, &dbv)) {
+ if (!DB::Setting::GetWString(hContact, USERINFO, szStamp, &dbv)) {
_strDesc = dbv.pwszVal;
db_free(&dbv);
}
diff --git a/plugins/UserInfoEx/src/classPsTree.cpp b/plugins/UserInfoEx/src/classPsTree.cpp index f4b55fa027..ac023b5b83 100644 --- a/plugins/UserInfoEx/src/classPsTree.cpp +++ b/plugins/UserInfoEx/src/classPsTree.cpp @@ -115,12 +115,12 @@ int CPsTree::AddDummyItem(LPCSTR pszGroup) psh._pszProto = _pPs->pszProto; psh._hImages = _hImages; - OPTIONSDIALOGPAGE odp = {}; - odp.flags = ODPF_UNICODE; - odp.szTitle.w = mir_utf8decodeW(pszGroup); + USERINFOPAGE uip = {}; + uip.flags = ODPF_UNICODE; + uip.szTitle.w = mir_utf8decodeW(pszGroup); auto *p = new CPsTreeItem(); - p->Create(&psh, &odp); + p->Create(&psh, &uip); _pages.insert(p); return _pages.indexOf(&p); @@ -810,21 +810,17 @@ void CPsTree::OnIconsChanged() uint8_t CPsTree::OnInfoChanged() { - PSHNOTIFY pshn; uint8_t bChanged = 0; - pshn.hdr.idFrom = 0; - pshn.hdr.code = PSN_INFOCHANGED; for (auto &it : _pages) { - pshn.hdr.hwndFrom = it->Wnd(); - if (pshn.hdr.hwndFrom != nullptr) { - pshn.lParam = (LPARAM)it->hContact(); - SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn); - if (PSP_CHANGED == GetWindowLongPtr(pshn.hdr.hwndFrom, DWLP_MSGRESULT)) - bChanged |= 1; - else - it->RemoveFlags(PSPF_CHANGED); - } + if (it->Wnd() == nullptr) + continue; + + it->Dialog()->SetContact(it->hContact()); + if (it->Dialog()->OnRefresh()) + bChanged |= 1; + else + it->RemoveFlags(PSPF_CHANGED); } return bChanged; } diff --git a/plugins/UserInfoEx/src/classPsTreeItem.cpp b/plugins/UserInfoEx/src/classPsTreeItem.cpp index 12d3ceef79..914e80da31 100644 --- a/plugins/UserInfoEx/src/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/src/classPsTreeItem.cpp @@ -44,18 +44,7 @@ BOOL CALLBACK BoldGroupTitlesEnumChildren(HWND hWnd, LPARAM lParam) * odp - optiondialogpage structure with the info about the item to add
* return: nothing
**/
-CPsTreeItem::CPsTreeItem() : _idDlg(NULL), _pTemplate(nullptr), _hInst(nullptr), _pfnDlgProc(nullptr), _hWnd(nullptr), _dwFlags(NULL),
- _hItem(nullptr), // handle to the treeview item
- _iParent(-1), // index to the parent item
- _iImage(-1), // index of treeview item's image
- _bState(NULL), // initial state of this treeitem
- _pszName(nullptr), // original name, given by plugin (not customized)
- _ptszLabel(nullptr),
- _pszProto(nullptr),
- _pszPrefix(nullptr),
- _hContact(NULL),
- _iPosition(0),
- _initParam(0)
+CPsTreeItem::CPsTreeItem()
{
}
@@ -245,7 +234,7 @@ int CPsTreeItem::ItemLabel(const uint8_t bReadDBValue) mir_free(_ptszLabel);
// try to get custom label from database
- if (!bReadDBValue || DB::Setting::GetTString(0, MODULENAME, GlobalPropertyKey(SET_ITEM_LABEL), &dbv) || (_ptszLabel = dbv.pwszVal) == nullptr) {
+ if (!bReadDBValue || DB::Setting::GetWString(0, MODULENAME, GlobalPropertyKey(SET_ITEM_LABEL), &dbv) || (_ptszLabel = dbv.pwszVal) == nullptr) {
// extract the name
LPSTR pszName = mir_strrchr(_pszName, '\\');
if (pszName && pszName[1])
@@ -294,14 +283,14 @@ HICON CPsTreeItem::ProtoIcon() * class: CPsTreeItem
* desc: load the icon, add to icolib if required and add to imagelist of treeview
* params: hIml - treeview's imagelist to add the icon to
- * odp - pointer to OPTIONSDIALOGPAGE providing the information about the icon to load
+ * odp - pointer to USERINFOPAGE providing the information about the icon to load
* hDefaultIcon - default icon to use
* return: nothing
**/
-int CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIconsOnly)
+int CPsTreeItem::Icon(HIMAGELIST hIml, USERINFOPAGE *uip, uint8_t bInitIconsOnly)
{
// check parameter
- if (!_pszName || !odp)
+ if (!_pszName || !uip)
return 1;
// load the icon if no icolib is installed or creating the required settingname failed
@@ -320,16 +309,16 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIcon sid.section.w = pwszSection;
// the item to insert brings along an icon?
- if (odp->flags & ODPF_ICON) {
+ if (uip->flags & ODPF_ICON) {
// is it uinfoex item?
- if (odp->pPlugin == &g_plugin) {
+ if (uip->pPlugin == &g_plugin) {
// the pszGroup holds the iconfile for items added by uinfoex
- sid.defaultFile.w = odp->szGroup.w;
+ sid.defaultFile.w = uip->szGroup.w;
// icon library exists?
if (sid.defaultFile.w)
- sid.iDefaultIndex = odp->dwInitParam;
+ sid.iDefaultIndex = uip->dwInitParam;
// no valid icon library
else {
bNeedFree = true;
@@ -374,20 +363,20 @@ int CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIcon * class: CPsTreeItem
* desc: inits the treeitem's attributes
* params: pPsh - pointer to the property page's header structure
- * odp - OPTIONSDIALOGPAGE structure with the information about the page to add
+ * odp - USERINFOPAGE structure with the information about the page to add
* return: 0 on success, 1 on failure
**/
-int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp)
+int CPsTreeItem::Create(CPsHdr* pPsh, USERINFOPAGE *uip)
{
int err;
wchar_t szTitle[ MAXSETTING ];
// check parameter
- if (pPsh && odp && PtrIsValid(odp->pPlugin)) {
+ if (pPsh && uip && PtrIsValid(uip->pPlugin)) {
// instance value
- _hInst = odp->pPlugin->getInst();
- _dwFlags = odp->flags;
- _initParam = odp->dwInitParam;
+ _hInst = uip->pPlugin->getInst();
+ _dwFlags = uip->flags;
+ _initParam = uip->dwInitParam;
// init page owning contact
_hContact = pPsh->_hContact;
@@ -398,15 +387,15 @@ int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp) if (pPsh->_dwFlags & PSF_PROTOPAGESONLY) {
if (_dwFlags & ODPF_USERINFOTAB)
- mir_snwprintf(szTitle, L"%s %d\\%s", odp->szTitle.w, pPsh->_nSubContact+1, odp->szTab.w);
+ mir_snwprintf(szTitle, L"%s %d\\%s", uip->szTitle.w, pPsh->_nSubContact+1, uip->szGroup.w);
else
- mir_snwprintf(szTitle, L"%s %d", odp->szTitle.w, pPsh->_nSubContact+1);
+ mir_snwprintf(szTitle, L"%s %d", uip->szTitle.w, pPsh->_nSubContact+1);
}
else {
if (_dwFlags & ODPF_USERINFOTAB)
- mir_snwprintf(szTitle, L"%s\\%s", odp->szTitle.w, odp->szTab.w);
+ mir_snwprintf(szTitle, L"%s\\%s", uip->szTitle.w, uip->szGroup.w);
else
- mir_wstrcpy(szTitle, odp->szTitle.w);
+ mir_wstrcpy(szTitle, uip->szTitle.w);
}
// set the unique utf8 encoded name for the item
if (err = Name(szTitle, (_dwFlags & ODPF_UNICODE) == ODPF_UNICODE))
@@ -415,9 +404,10 @@ int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp) // read label from database or create it
else if (err = ItemLabel(TRUE))
MsgErr(nullptr, LPGENW("Creating the label for a page failed with %d and error code %d"), err, GetLastError());
+
else {
// load icon for the item
- Icon(pPsh->_hImages, odp, (pPsh->_dwFlags & PSTVF_INITICONS) == PSTVF_INITICONS);
+ Icon(pPsh->_hImages, uip, (pPsh->_dwFlags & PSTVF_INITICONS) == PSTVF_INITICONS);
// the rest is not needed if only icons are loaded
if (pPsh->_dwFlags & PSTVF_INITICONS)
@@ -425,33 +415,16 @@ int CPsTreeItem::Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp) // load custom order
if (!(pPsh->_dwFlags & PSTVF_SORTTREE)) {
- _iPosition = (int)g_plugin.getByte(PropertyKey(SET_ITEM_POS), odp->position);
+ _iPosition = g_plugin.getByte(PropertyKey(SET_ITEM_POS), uip->position);
if ((_iPosition < 0) || (_iPosition > 0x800000A))
_iPosition = 0;
}
// read visibility state
- _bState = g_plugin.getByte(PropertyKey(SET_ITEM_STATE), DBTVIS_EXPANDED);
+ _bState = g_plugin.getByte(PropertyKey(SET_ITEM_STATE), DBTVIS_EXPANDED);
- // error for no longer supported dialog template type
- if (((UINT_PTR)odp->pszTemplate & 0xFFFF0000))
- MsgErr(nullptr, LPGENW("The dialog template type is no longer supported"));
- else {
- // fetch dialog resource id
- _idDlg = (INT_PTR)odp->pszTemplate;
- // dialog procedure
- _pfnDlgProc = odp->pfnDlgProc;
-
- // is dummy item?
- if (!_idDlg && !_pfnDlgProc)
- return 0;
-
- if (_idDlg && _pfnDlgProc) {
- // lock the property pages dialog resource
- _pTemplate = (DLGTEMPLATE*)LockResource(LoadResource(_hInst, FindResource(_hInst, (LPCTSTR)(UINT_PTR)_idDlg, RT_DIALOG)));
- if (_pTemplate)
- return 0;
- }
- }
+ // fetch dialog
+ _pDialog = uip->pDialog;
+ return 0;
}
}
return 1;
@@ -501,20 +474,15 @@ uint16_t CPsTreeItem::DBSaveItemState(LPCSTR pszGroup, int iItemPosition, UINT i **/
HWND CPsTreeItem::CreateWnd(LPPS pPs)
{
- if (pPs && !_hWnd && _pTemplate && _pfnDlgProc) {
- _hWnd = CreateDialogIndirectParam(_hInst, _pTemplate, pPs->hDlg, _pfnDlgProc, (LPARAM)_hContact);
+ if (pPs && !_hWnd && _pDialog) {
+ _pDialog->SetParent(pPs->hDlg);
+ _pDialog->SetContact(_hContact);
+ _pDialog->Create();
+ _hWnd = _pDialog->GetHwnd();
if (_hWnd != nullptr) {
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_PARAMCHANGED;
- pshn.hdr.hwndFrom = _hWnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)_initParam;
- SendMessage(_hWnd, WM_NOTIFY, 0, (LPARAM)&pshn);
-
// force child window (mainly for AIM property page)
SetWindowLongPtr(_hWnd, GWL_STYLE, (GetWindowLongPtr(_hWnd, GWL_STYLE) & ~(WS_POPUP|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME)) | WS_CHILD);
SetWindowLongPtr(_hWnd, GWL_EXSTYLE, GetWindowLongPtr(_hWnd, GWL_EXSTYLE) & ~(WS_EX_APPWINDOW|WS_EX_STATICEDGE|WS_EX_CLIENTEDGE));
- SetParent(_hWnd, pPs->hDlg);
// move dialog into the display area
SetWindowPos(_hWnd, HWND_TOP,
@@ -547,15 +515,8 @@ HWND CPsTreeItem::CreateWnd(LPPS pPs) **/
void CPsTreeItem::OnInfoChanged()
{
- if (_hWnd) {
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_INFOCHANGED;
- pshn.hdr.hwndFrom = _hWnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)_hContact;
- if (PSP_CHANGED != SendMessage(_hWnd, WM_NOTIFY, 0, (LPARAM)&pshn))
- _dwFlags &= ~PSPF_CHANGED;
- }
+ if (_hWnd)
+ _pDialog->OnRefresh();
}
/**
@@ -567,13 +528,9 @@ void CPsTreeItem::OnInfoChanged() **/
void CPsTreeItem::OnPageIconsChanged()
{
- if (_hWnd) {
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_ICONCHANGED;
- pshn.hdr.hwndFrom = _hWnd;
- pshn.hdr.idFrom = 0;
- pshn.lParam = (LPARAM)_hContact;
- SendMessage(_hWnd, WM_NOTIFY, 0, (LPARAM)&pshn);
+ if (_hWnd && _initParam) {
+ auto *pDlg = (PSPBaseDlg *)_pDialog;
+ pDlg->OnIconsChanged();
}
}
diff --git a/plugins/UserInfoEx/src/ctrl_combo.cpp b/plugins/UserInfoEx/src/ctrl_combo.cpp index 81d82220f0..512371116a 100644 --- a/plugins/UserInfoEx/src/ctrl_combo.cpp +++ b/plugins/UserInfoEx/src/ctrl_combo.cpp @@ -149,7 +149,7 @@ BOOL CCombo::OnInfoChanged(MCONTACT hContact, LPCSTR pszProto) int iVal = CB_ERR;
_Flags.B.hasCustom = _Flags.B.hasProto = _Flags.B.hasMeta = false;
- _Flags.W |= DB::Setting::GetTStringCtrl(hContact, USERINFO, USERINFO, pszProto, _pszSetting, &dbv);
+ _Flags.W |= DB::Setting::GetWStringCtrl(hContact, USERINFO, USERINFO, pszProto, _pszSetting, &dbv);
EnableWindow(_hwnd, !hContact || _Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0));
if (_Flags.B.hasCustom || _Flags.B.hasProto || _Flags.B.hasMeta) {
diff --git a/plugins/UserInfoEx/src/ctrl_contact.cpp b/plugins/UserInfoEx/src/ctrl_contact.cpp index 66c153a110..7ce07cdb30 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.cpp +++ b/plugins/UserInfoEx/src/ctrl_contact.cpp @@ -1292,7 +1292,7 @@ int CtrlContactAddItemFromDB( cbi.pszVal = nullptr;
cbi.dwID = mir_hashstr(szSettingVal);
- cbi.wFlags = CBEXIF_CATREADONLY | DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv);
+ cbi.wFlags = CBEXIF_CATREADONLY | DB::Setting::GetWStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv);
if (dbv.type >= DBVT_WCHAR) {
// no value read from database
if (cbi.wFlags == CBEXIF_CATREADONLY)
@@ -1352,7 +1352,7 @@ int CtrlContactAddMyItemsFromDB( for (i = 0;
SUCCEEDED(mir_snprintf(pszSetting, szFormatVal, i)) &&
- (cbi.wFlags = DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, pszSetting, &dbv));
+ (cbi.wFlags = DB::Setting::GetWStringCtrl(hContact, pszModule, pszModule, pszProto, pszSetting, &dbv));
i++) {
// read value
cbi.dwID = mir_hashstr(pszSetting);
@@ -1363,12 +1363,12 @@ int CtrlContactAddMyItemsFromDB( // read category
if (SUCCEEDED(mir_snprintf(pszSetting, szFormatCat, i))) {
if (cbi.wFlags & CTRLF_HASCUSTOM) {
- if (DB::Setting::GetTString(hContact, pszModule, pszSetting, &dbv))
+ if (DB::Setting::GetWString(hContact, pszModule, pszSetting, &dbv))
dbv.type = DBVT_DELETED;
}
else
if (cbi.wFlags & CTRLF_HASPROTO) {
- if (DB::Setting::GetTString(hContact, pszProto, pszSetting, &dbv))
+ if (DB::Setting::GetWString(hContact, pszProto, pszSetting, &dbv))
dbv.type = DBVT_DELETED;
}
diff --git a/plugins/UserInfoEx/src/ctrl_edit.cpp b/plugins/UserInfoEx/src/ctrl_edit.cpp index fb3b5d9e83..99d8f22b75 100644 --- a/plugins/UserInfoEx/src/ctrl_edit.cpp +++ b/plugins/UserInfoEx/src/ctrl_edit.cpp @@ -111,7 +111,7 @@ BOOL CEditCtrl::OnInfoChanged(MCONTACT hContact, LPCSTR pszProto) wchar_t szText[64]; _Flags.B.hasCustom = _Flags.B.hasProto = _Flags.B.hasMeta = false; - _Flags.W |= DB::Setting::GetTStringCtrl(hContact, _pszModule, _pszModule, pszProto, _pszSetting, &dbv); + _Flags.W |= DB::Setting::GetWStringCtrl(hContact, _pszModule, _pszModule, pszProto, _pszSetting, &dbv); EnableWindow(_hwnd, !hContact || _Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0)); diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index 24fb405c45..e254162217 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -304,18 +304,18 @@ static INT_PTR ShowDialog(WPARAM wParam, LPARAM) static INT_PTR AddPage(WPARAM wParam, LPARAM lParam)
{
CPsHdr *pPsh = (CPsHdr *)wParam;
- OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE *)lParam;
+ USERINFOPAGE *uip = (USERINFOPAGE*)lParam;
// check size of the handled structures
- if (pPsh == nullptr || odp == nullptr)
+ if (pPsh == nullptr || uip == nullptr)
return 1;
// try to check whether the flag member is initialized or not
- odp->flags = odp->flags > (ODPF_UNICODE | ODPF_BOLDGROUPS | ODPF_ICON | PSPF_PROTOPREPENDED) ? 0 : odp->flags;
+ uip->flags = uip->flags > (ODPF_UNICODE | ODPF_BOLDGROUPS | ODPF_ICON | PSPF_PROTOPREPENDED) ? 0 : uip->flags;
if (pPsh->_dwFlags & (PSF_PROTOPAGESONLY | PSF_PROTOPAGESONLY_INIT)) {
- uint8_t bIsUnicode = (odp->flags & ODPF_UNICODE) == ODPF_UNICODE;
- wchar_t *ptszTitle = bIsUnicode ? mir_wstrdup(odp->szTitle.w) : mir_a2u(odp->szTitle.a);
+ uint8_t bIsUnicode = (uip->flags & ODPF_UNICODE) == ODPF_UNICODE;
+ wchar_t *ptszTitle = bIsUnicode ? mir_wstrdup(uip->szTitle.w) : mir_a2u(uip->szTitle.a);
// avoid adding pages for a meta subcontact, which have been added for a metacontact.
if (pPsh->_dwFlags & PSF_PROTOPAGESONLY) {
@@ -334,7 +334,7 @@ static INT_PTR AddPage(WPARAM wParam, LPARAM lParam) // create the new tree item
CPsTreeItem *pNew = new CPsTreeItem();
if (pNew) {
- if (pNew->Create(pPsh, odp)) {
+ if (pNew->Create(pPsh, uip)) {
MIR_DELETE(pNew);
return 1;
}
@@ -384,79 +384,23 @@ static int InitDetails(WPARAM wParam, LPARAM lParam) if (!(pPsh->_dwFlags & PSF_PROTOPAGESONLY)) {
uint8_t bChangeDetailsEnabled = myGlobals.CanChangeDetails && g_plugin.getByte(SET_PROPSHEET_CHANGEMYDETAILS, FALSE);
if (lParam || bChangeDetailsEnabled) {
- OPTIONSDIALOGPAGE odp = {};
- odp.flags = ODPF_ICON | ODPF_UNICODE;
- odp.szGroup.w = IcoLib_GetDefaultIconFileName();
- odp.pPlugin = &g_plugin;
+ USERINFOPAGE uip = {};
+ uip.flags = ODPF_ICON | ODPF_UNICODE;
+ uip.szGroup.w = IcoLib_GetDefaultIconFileName();
+ uip.pPlugin = &g_plugin;
if (lParam) {
// ignore common pages for weather contacts
if (!pPsh->_pszProto || _stricmp(pPsh->_pszProto, "weather")) {
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_GENERAL);
- odp.position = 0x8000000;
- odp.pfnDlgProc = PSPProcGeneral;
- odp.dwInitParam = ICONINDEX(IDI_TREE_GENERAL);
- odp.szTitle.w = LPGENW("General");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ADDRESS);
- odp.position = 0x8000001;
- odp.pfnDlgProc = PSPProcContactHome;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
- odp.szTitle.w = LPGENW("General") L"\\" LPGENW("Contact (private)");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ORIGIN);
- odp.position = 0x8000002;
- odp.pfnDlgProc = PSPProcOrigin;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ADVANCED);
- odp.szTitle.w = LPGENW("General") L"\\" LPGENW("Origin");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ANNIVERSARY);
- odp.position = 0x8000003;
- odp.pfnDlgProc = PSPProcAnniversary;
- odp.dwInitParam = ICONINDEX(IDI_BIRTHDAY);
- odp.szTitle.w = LPGENW("General") L"\\" LPGENW("Anniversaries");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COMPANY);
- odp.position = 0x8000004;
- odp.pfnDlgProc = PSPProcCompany;
- odp.dwInitParam = ICONINDEX(IDI_TREE_COMPANY);
- odp.szTitle.w = LPGENW("Work");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ADDRESS);
- odp.position = 0x8000005;
- odp.pfnDlgProc = PSPProcContactWork;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
- odp.szTitle.w = LPGENW("Work") L"\\" LPGENW("Contact (work)");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ABOUT);
- odp.position = 0x8000006;
- odp.pfnDlgProc = PSPProcAbout;
- odp.dwInitParam = ICONINDEX(IDI_TREE_ABOUT);
- odp.szTitle.w = LPGENW("About");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_PROFILE);
- odp.position = 0x8000007;
- odp.pfnDlgProc = PSPProcContactProfile;
- odp.dwInitParam = ICONINDEX(IDI_TREE_PROFILE);
- odp.szTitle.w = LPGENW("About") L"\\" LPGENW("Profile");
- AddPage(wParam, (LPARAM)&odp);
-
- odp.szTitle.w = LPGENW("About") L"\\" LPGENW("Notes");
+ InitGeneralDlg(wParam, uip);
+ InitContactDlg(wParam, uip);
+ InitOriginDlg(wParam, uip);
+ InitAnniversaryDlg(wParam, uip);
+ InitCompanyDlg(wParam, uip);
+ InitOriginDlg(wParam, uip, false);
+ InitProfileDlg(wParam, uip);
}
- else odp.szTitle.w = LPGENW("Notes");
-
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_ABOUT);
- odp.position = 0x8000008;
- odp.pfnDlgProc = PSPProcMyNotes;
- odp.dwInitParam = ICONINDEX(IDI_TREE_NOTES);
- AddPage(wParam, (LPARAM)&odp);
+ else InitOriginDlg(wParam, uip, true);
}
}
}
diff --git a/plugins/UserInfoEx/src/dlg_propsheet.h b/plugins/UserInfoEx/src/dlg_propsheet.h index d8aea78665..615c98102b 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.h +++ b/plugins/UserInfoEx/src/dlg_propsheet.h @@ -32,28 +32,27 @@ 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
- uint32_t _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
- uint8_t _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 = 0; // resource id of the property page
+ HINSTANCE _hInst = 0; // instance handle of the owning plugin dll
+ CUserInfoPageDlg *_pDialog = 0; // pointer to a page dialog
+ HWND _hWnd = 0; // window handle for the property page if shown jet
+ uint32_t _dwFlags = 0; // some flags
+ int _iPosition = 0; // initiating position if custom (used for sorting)
+ MCONTACT _hContact = 0; // contact the page is accociated with (may be a meta subcontact if details dialog is shown for a meta contact)
+ LPCSTR _pszProto = 0; // protocol the page is accociated with (is the contact's protocol if _hContact is not NULL)
+ LPCSTR _pszPrefix = 0; // pointer to the dialog owning contact's protocol
+ INT_PTR _initParam = 0;
+
+ HTREEITEM _hItem = 0; // handle to the treeview item if visible (NULL if this item is hidden)
+ int _iParent = -1; // index of the owning tree item
+ int _iImage = -1; // index of treeview item's image
+ uint8_t _bState = 0; // initial state of this treeitem
+ LPSTR _pszName = 0; // original name, given by plugin (not customized)
+ LPTSTR _ptszLabel= 0; // string to setting in db holding information about this treeitem
LPCSTR GlobalName();
- int Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, uint8_t bInitIconsOnly);
+ int Icon(HIMAGELIST hIml, USERINFOPAGE *uip, uint8_t bInitIconsOnly);
int ItemLabel(const uint8_t bReadDBValue);
int Name(LPTSTR pszTitle, const uint8_t bIsUnicode);
HICON ProtoIcon();
@@ -62,30 +61,31 @@ public: CPsTreeItem();
~CPsTreeItem();
- int Create(CPsHdr* pPsh, OPTIONSDIALOGPAGE *odp);
+ int Create(CPsHdr* pPsh, USERINFOPAGE *uip);
void Rename(const LPTSTR pszLabel);
- __inline LPSTR Name() const { return _pszName; };
- __inline LPCSTR Proto() const { return _pszProto; };
- __inline LPTSTR Label() const { return _ptszLabel; };
- __inline MCONTACT hContact() const { return _hContact; };
+ __inline LPSTR Name() const { return _pszName; }
+ __inline LPCSTR Proto() const { return _pszProto; }
+ __inline LPTSTR Label() const { return _ptszLabel; }
+ __inline MCONTACT hContact() const { return _hContact; }
- __inline HWND Wnd() const { return _hWnd; };
- __inline int DlgId() const { return _idDlg; };
- __inline HINSTANCE Inst() const { return _hInst; };
+ __inline HWND Wnd() const { return _hWnd; }
+ __inline int DlgId() const { return _idDlg; }
+ __inline HINSTANCE Inst() const { return _hInst; }
+ __inline CUserInfoPageDlg* Dialog() const { return _pDialog; }
- __inline int Image() const { return _iImage; };
- __inline int Pos() const { return _iPosition; };
- __inline uint8_t State() const { return _bState; };
- __inline HTREEITEM Hti() const { return _hItem; };
- __inline void Hti(HTREEITEM hti) { _hItem = hti; };
- __inline int Parent() const { return _iParent; };
- __inline void Parent(const int iParent) { _iParent = iParent; };
+ __inline int Image() const { return _iImage; }
+ __inline int Pos() const { return _iPosition; }
+ __inline uint8_t State() const { return _bState; }
+ __inline HTREEITEM Hti() const { return _hItem; }
+ __inline void Hti(HTREEITEM hti) { _hItem = hti; }
+ __inline int Parent() const { return _iParent; }
+ __inline void Parent(const int iParent) { _iParent = iParent; }
- __inline uint32_t Flags() const { return _dwFlags; };
- __inline void Flags(uint32_t dwFlags) { _dwFlags = dwFlags; };
- __inline void AddFlags(uint32_t dwFlags) { _dwFlags |= dwFlags; };
- __inline void RemoveFlags(uint32_t dwFlags) { _dwFlags &= ~dwFlags; };
+ __inline uint32_t Flags() const { return _dwFlags; }
+ __inline void Flags(uint32_t dwFlags) { _dwFlags = dwFlags; }
+ __inline void AddFlags(uint32_t dwFlags) { _dwFlags |= dwFlags; }
+ __inline void RemoveFlags(uint32_t dwFlags) { _dwFlags &= ~dwFlags; }
uint8_t HasName(const LPCSTR pszName) const;
@@ -246,7 +246,7 @@ struct TPropSheet {
// dialogs owner
MCONTACT hContact;
- CHAR pszProto[MAXMODULELABELLENGTH];
+ char pszProto[MAXMODULELABELLENGTH];
HANDLE hProtoAckEvent; // eventhook for protocol acks
HANDLE hSettingChanged; // eventhook searching for changed contact information
diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp index 666fd84b78..773edbab63 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp @@ -282,7 +282,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar case EXIM_GROUP:
break;
case EXIM_SUBGROUP:
- if (mir_wstrncmp(pDat->ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(pDat->ExImContact->ptszName))) {
+ if (mir_wstrncmp(pDat->ExImContact->ptszName, DB::Setting::GetWString(hContact, "CList", "Group"), mir_wstrlen(pDat->ExImContact->ptszName))) {
continue;
}
break;
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index 1d008719ad..f4ea0a1e10 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -152,7 +152,7 @@ int CFileXml::Export(lpExImParam ExImContact, const wchar_t *pszFileName) // dont export meta subcontacts by default and
// export only contact with selectet group name
if (!db_mc_isSub(hContact) &&
- mir_wstrncmp(ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(ExImContact->ptszName)) == 0) {
+ mir_wstrncmp(ExImContact->ptszName, DB::Setting::GetWString(hContact, "CList", "Group"), mir_wstrlen(ExImContact->ptszName)) == 0) {
if (vContact.fromDB(hContact)) {
vContact.Export(xmlfile, &Modules);
}
diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h index e00052a450..bfb3faf468 100644 --- a/plugins/UserInfoEx/src/mir_db.h +++ b/plugins/UserInfoEx/src/mir_db.h @@ -29,12 +29,12 @@ namespace DB { **/
namespace Contact {
- uint32_t WhenAdded(uint32_t dwUIN, LPCSTR szBaseProto);
+ uint32_t WhenAdded(uint32_t dwUIN, LPCSTR szBaseProto);
} /* namespace Contact */
namespace Module {
- bool IsMeta(LPCSTR pszModule);
- bool IsMetaAndScan(LPCSTR pszModule);
+ bool IsMeta(LPCSTR pszModule);
+ bool IsMetaAndScan(LPCSTR pszModule);
} /* namespace Module */
@@ -43,7 +43,7 @@ namespace Module { **/
namespace Setting {
- uint8_t Get(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv, const uint8_t nType);
+ uint8_t Get(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv, const uint8_t nType);
static FORCEINLINE uint8_t GetAsIs(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv)
{ return Get(hContact, pszModule, pszSetting, dbv, 0); }
static FORCEINLINE uint8_t GetAString(MCONTACT hContact, LPCSTR pszModule, LPCSTR pszSetting, DBVARIANT *dbv)
@@ -77,11 +77,6 @@ namespace Setting { static FORCEINLINE uint16_t GetUStringCtrl(MCONTACT hContact, LPCSTR pszModule, LPCSTR szSubModule, LPCSTR szProto, LPCSTR pszSetting, DBVARIANT *dbv)
{ return GetCtrl(hContact, pszModule, szSubModule, szProto, pszSetting, dbv, DBVT_UTF8); }
- #define GetTString GetWString
- #define GetTStringEx GetWStringEx
- #define GetTStringCtrl GetWStringCtrl
- #define WriteTString WriteWString
-
/**
* misc operations
**/
diff --git a/plugins/UserInfoEx/src/psp_about.cpp b/plugins/UserInfoEx/src/psp_about.cpp index bacc975bd2..05b14573a0 100644 --- a/plugins/UserInfoEx/src/psp_about.cpp +++ b/plugins/UserInfoEx/src/psp_about.cpp @@ -21,83 +21,84 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the about/nodes information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcEdit(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, const CHAR *pszSetting)
+struct PSPEditDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- if (!mir_strcmp(pszSetting, SET_CONTACT_MYNOTES))
- SetDlgItemText(hDlg, IDC_PAGETITLE, LPGENW("My notes:"));
- else
- SetDlgItemText(hDlg, IDC_PAGETITLE, LPGENW("About:"));
-
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ABOUT, pszSetting, DBVT_WCHAR));
-
- // remove static edge in aero mode
- if (IsAeroMode())
- SetWindowLongPtr(GetDlgItem(hDlg, EDIT_ABOUT), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hDlg, EDIT_ABOUT), GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
-
- SendDlgItemMessage(hDlg, EDIT_ABOUT, EM_SETEVENTMASK, 0, /*ENM_KEYEVENTS | */ENM_LINK | ENM_CHANGE);
- SendDlgItemMessage(hDlg, EDIT_ABOUT, EM_AUTOURLDETECT, TRUE, NULL);
- if (!lParam) SendDlgItemMessage(hDlg, EDIT_ABOUT, EM_LIMITTEXT, 1024, NULL);
- }
- }
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
+ const char *m_szSetting;
+
+ PSPEditDlg(const char *szSetting) :
+ PSPBaseDlg(IDD_CONTACT_ABOUT),
+ m_szSetting(szSetting)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ if (!mir_strcmp(m_szSetting, SET_CONTACT_MYNOTES))
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, TranslateT("My notes:"));
+ else
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, TranslateT("About:"));
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ABOUT, m_szSetting, DBVT_WCHAR));
+
+ // remove static edge in aero mode
+ if (IsAeroMode())
+ SetWindowLongPtr(GetDlgItem(m_hwnd, EDIT_ABOUT), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(m_hwnd, EDIT_ABOUT), GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
+
+ SendDlgItemMessage(m_hwnd, EDIT_ABOUT, EM_SETEVENTMASK, 0, /*ENM_KEYEVENTS | */ENM_LINK | ENM_CHANGE);
+ SendDlgItemMessage(m_hwnd, EDIT_ABOUT, EM_AUTOURLDETECT, TRUE, NULL);
+ if (!m_hContact)
+ SendDlgItemMessage(m_hwnd, EDIT_ABOUT, EM_LIMITTEXT, 1024, NULL);
+ return true;
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ switch (uMsg) {
+ case WM_NOTIFY:
// notification handler for richedit control
+ switch (((LPNMHDR)lParam)->idFrom) {
case EDIT_ABOUT:
- {
- switch (((LPNMHDR)lParam)->code) {
-
- // notification handler for a link within the richedit control
- case EN_LINK:
- return CEditCtrl::GetObj(((LPNMHDR)lParam)->hwndFrom)->LinkNotificationHandler((ENLINK *)lParam);
- }
+ // notification handler for a link within the richedit control
+ switch (((LPNMHDR)lParam)->code) {
+ case EN_LINK:
+ return CEditCtrl::GetObj(((LPNMHDR)lParam)->hwndFrom)->LinkNotificationHandler((ENLINK *)lParam);
}
return FALSE;
}
- }
- break;
+ break;
- case WM_COMMAND:
- {
+ case WM_COMMAND:
switch (LOWORD(wParam)) {
case EDIT_ABOUT:
- {
- if (HIWORD(wParam) == EN_CHANGE)
- {
- CBaseCtrl *pResult;
-
- pResult = CBaseCtrl::GetObj((HWND)lParam);
- if (PtrIsValid(pResult) && (pResult->_cbSize == sizeof(CBaseCtrl)))
- pResult->OnChangedByUser(HIWORD(wParam));
- }
+ if (HIWORD(wParam) == EN_CHANGE) {
+ CBaseCtrl *pResult = CBaseCtrl::GetObj((HWND)lParam);
+ if (PtrIsValid(pResult) && (pResult->_cbSize == sizeof(CBaseCtrl)))
+ pResult->OnChangedByUser(HIWORD(wParam));
}
}
+ return FALSE;
}
- return FALSE;
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip, bool bReadOnly)
+{
+ if (!bReadOnly) {
+ uip.position = 0x8000006;
+ uip.pDialog = new PSPEditDlg(SET_CONTACT_ABOUT);
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ABOUT);
+ uip.szTitle.w = LPGENW("About");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.szTitle.w = LPGENW("About") L"\\" LPGENW("Notes");
+ }
+ else uip.szTitle.w = LPGENW("Notes");
+
+ uip.position = 0x8000008;
+ uip.pDialog = new PSPEditDlg(SET_CONTACT_MYNOTES);
+ uip.dwInitParam = ICONINDEX(IDI_TREE_NOTES);
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_anniversary.cpp b/plugins/UserInfoEx/src/psp_anniversary.cpp index a185512b59..5e929ace4e 100644 --- a/plugins/UserInfoEx/src/psp_anniversary.cpp +++ b/plugins/UserInfoEx/src/psp_anniversary.cpp @@ -21,19 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the anniversary add/edit dialog
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND m_hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- MAnnivDate *pDlgEditAnniv = (MAnnivDate *)GetUserData(hDlg);
+ MAnnivDate *pDlgEditAnniv = (MAnnivDate *)GetUserData(m_hwnd);
switch (uMsg) {
case WM_INITDIALOG:
@@ -41,23 +31,23 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w if (!PtrIsValid(pDlgEditAnniv))
break;
- SetUserData(hDlg, lParam);
+ SetUserData(m_hwnd, lParam);
// set icons
if (g_plugin.getByte(SET_ICONS_BUTTONS, 1)) {
- SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_OK));
- SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_CLOSE));
+ SendDlgItemMessage(m_hwnd, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_OK));
+ SendDlgItemMessage(m_hwnd, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_CLOSE));
}
- SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)g_plugin.getIcon(IDI_ANNIVERSARY, true));
+ SendDlgItemMessage(m_hwnd, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)g_plugin.getIcon(IDI_ANNIVERSARY, true));
// translate controls
- SendDlgItemMessage(hDlg, IDOK, BUTTONTRANSLATE, NULL, NULL);
- SendDlgItemMessage(hDlg, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
- TranslateDialogDefault(hDlg);
+ SendDlgItemMessage(m_hwnd, IDOK, BUTTONTRANSLATE, NULL, NULL);
+ SendDlgItemMessage(m_hwnd, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
+ TranslateDialogDefault(m_hwnd);
// init controls
- EnableWindow(GetDlgItem(hDlg, EDIT_CATEGORY), pDlgEditAnniv->Id() != ANID_BIRTHDAY);
- SetDlgItemText(hDlg, EDIT_CATEGORY, pDlgEditAnniv->Description());
+ EnableWindow(GetDlgItem(m_hwnd, EDIT_CATEGORY), pDlgEditAnniv->Id() != ANID_BIRTHDAY);
+ SetDlgItemText(m_hwnd, EDIT_CATEGORY, pDlgEditAnniv->Description());
return TRUE;
case WM_CTLCOLORSTATIC:
@@ -68,13 +58,13 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w switch (LOWORD(wParam)) {
case EDIT_CATEGORY:
if (HIWORD(wParam) == EN_UPDATE)
- EnableWindow(GetDlgItem(hDlg, IDOK), GetWindowTextLength((HWND)lParam) > 0);
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), GetWindowTextLength((HWND)lParam) > 0);
break;
case IDOK:
{
// read new description
- HWND hEdit = GetDlgItem(hDlg, EDIT_CATEGORY);
+ HWND hEdit = GetDlgItem(m_hwnd, EDIT_CATEGORY);
int len = Edit_GetTextLength(hEdit);
LPTSTR pszText;
@@ -82,7 +72,7 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w || (pszText = (LPTSTR)_alloca((len + 1) * sizeof(wchar_t))) == nullptr
|| !Edit_GetText(hEdit, pszText, len + 1))
{
- MsgErr(hDlg, LPGENW("Please enter a valid description first!"));
+ MsgErr(m_hwnd, LPGENW("Please enter a valid description first!"));
break;
}
@@ -94,167 +84,162 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w __fallthrough;
case IDCANCEL:
- return EndDialog(hDlg, LOWORD(wParam));
+ return EndDialog(m_hwnd, LOWORD(wParam));
}
}
return FALSE;
}
-/**
-* Dialog procedure for the anniversary propertysheetpage
-*
-* @param hDlg - handle to the dialog window
-* @param uMsg - the message to handle
-* @param wParam - parameter
-* @param lParam - parameter
-*
-* @return different values
-**/
-
-INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct PSPAnniversaryDlg : public PSPBaseDlg
{
- CAnnivEditCtrl *pDateCtrl = CAnnivEditCtrl::GetObj(hDlg, EDIT_ANNIVERSARY_DATE);
+ PSPAnniversaryDlg() :
+ PSPBaseDlg(IDD_CONTACT_ANNIVERSARY)
+ {}
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
- TranslateDialogDefault(hDlg);
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_AGE, SET_CONTACT_AGE, DBVT_BYTE));
+ m_ctrlList->insert(CAnnivEditCtrl::CreateObj(m_hwnd, EDIT_ANNIVERSARY_DATE, nullptr));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_AGE, SET_CONTACT_AGE, DBVT_BYTE));
- pCtrlList->insert(CAnnivEditCtrl::CreateObj(hDlg, EDIT_ANNIVERSARY_DATE, nullptr));
+ // hContact == NULL or reminder disabled
+ CAnnivEditCtrl::GetObj(m_hwnd, EDIT_ANNIVERSARY_DATE)->EnableReminderCtrl(m_hContact != NULL);
- // hContact == NULL or reminder disabled
- CAnnivEditCtrl::GetObj(hDlg, EDIT_ANNIVERSARY_DATE)->EnableReminderCtrl(lParam != NULL);
+ SendDlgItemMessage(m_hwnd, EDIT_AGE, EM_LIMITTEXT, 3, 0);
+ SendDlgItemMessage(m_hwnd, SPIN_AGE, UDM_SETRANGE32, 0, 200);
+ return true;
+ }
- SendDlgItemMessage(hDlg, EDIT_AGE, EM_LIMITTEXT, 3, 0);
- SendDlgItemMessage(hDlg, SPIN_AGE, UDM_SETRANGE32, 0, 200);
- }
- }
- break;
+ void OnIconsChanged() override
+ {
+ const ICONCTRL idIcon[] = {
+ { IDI_BIRTHDAY, STM_SETIMAGE, ICO_BIRTHDAY },
+ { IDI_BTN_ADD, BM_SETIMAGE, BTN_ADD },
+ { IDI_BTN_DELETE, BM_SETIMAGE, BTN_DELETE }
+ };
+ IcoLib_SetCtrlIcons(m_hwnd, idIcon, _countof(idIcon));
+ }
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ CAnnivEditCtrl *pDateCtrl = CAnnivEditCtrl::GetObj(m_hwnd, EDIT_ANNIVERSARY_DATE);
+
+ switch(LOWORD(wParam)) {
+ case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) {
- case PSN_ICONCHANGED:
- {
- const ICONCTRL idIcon[] = {
- { IDI_BIRTHDAY, STM_SETIMAGE, ICO_BIRTHDAY },
- { IDI_BTN_ADD, BM_SETIMAGE, BTN_ADD },
- { IDI_BTN_DELETE, BM_SETIMAGE, BTN_DELETE }
- };
- IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon));
+ case EDIT_ANNIVERSARY_DATE:
+ if (!PspIsLocked(m_hwnd) && PtrIsValid(pDateCtrl)) {
+ LPNMHDR lpNmhdr = (LPNMHDR)lParam;
+ switch (lpNmhdr->code) {
+ case DTN_DATETIMECHANGE:
+ pDateCtrl->OnDateChanged((LPNMDATETIMECHANGE)lParam);
+ break;
+ case DTN_DROPDOWN:
+ HWND hMonthCal = DateTime_GetMonthCal(lpNmhdr->hwndFrom);
+ SetWindowLongPtr(hMonthCal, GWL_STYLE, GetWindowLongPtr(hMonthCal, GWL_STYLE) | MCS_WEEKNUMBERS);
+ InvalidateRect(hMonthCal, nullptr, TRUE);
+ }
}
return FALSE;
}
- break; /* case 0 */
-
- case EDIT_ANNIVERSARY_DATE:
- if (!PspIsLocked(hDlg) && PtrIsValid(pDateCtrl)) {
- LPNMHDR lpNmhdr = (LPNMHDR)lParam;
- switch (lpNmhdr->code) {
- case DTN_DATETIMECHANGE:
- pDateCtrl->OnDateChanged((LPNMDATETIMECHANGE)lParam);
- break;
- case DTN_DROPDOWN:
- HWND hMonthCal = DateTime_GetMonthCal(lpNmhdr->hwndFrom);
- SetWindowLongPtr(hMonthCal, GWL_STYLE, GetWindowLongPtr(hMonthCal, GWL_STYLE) | MCS_WEEKNUMBERS);
- InvalidateRect(hMonthCal, nullptr, TRUE);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case EDIT_REMIND:
+ if (!PspIsLocked(m_hwnd) && HIWORD(wParam) == EN_UPDATE)
+ if (PtrIsValid(pDateCtrl))
+ pDateCtrl->OnRemindEditChanged();
+ return FALSE;
+
+ /**
+ * name: BTN_MENU
+ * desc: the button to dropdown the list to show all items is pressed
+ **/
+ case BTN_MENU:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (PtrIsValid(pDateCtrl))
+ pDateCtrl->OnMenuPopup();
}
- }
- return FALSE;
- }
- break;
+ return FALSE;
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case EDIT_REMIND:
- if (!PspIsLocked(hDlg) && HIWORD(wParam) == EN_UPDATE)
- if (PtrIsValid(pDateCtrl))
- pDateCtrl->OnRemindEditChanged();
- return FALSE;
-
- /**
- * name: BTN_MENU
- * desc: the button to dropdown the list to show all items is pressed
- **/
- case BTN_MENU:
- if (HIWORD(wParam) == BN_CLICKED) {
- if (PtrIsValid(pDateCtrl))
- pDateCtrl->OnMenuPopup();
- }
- return FALSE;
-
- /**
- * name: BTN_ADD
- * desc: creates a new dialog to add a new anniversary
- **/
- case BTN_ADD:
- if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
- MAnnivDate Date;
- if (IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), hDlg, DlgProc_AnniversaryEditor, (LPARAM)&Date)) {
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- if (!pDateCtrl->AddDate(Date))
- pDateCtrl->SetCurSel(pDateCtrl->NumDates() - 1);
+ /**
+ * name: BTN_ADD
+ * desc: creates a new dialog to add a new anniversary
+ **/
+ case BTN_ADD:
+ if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
+ MAnnivDate Date;
+ if (IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), m_hwnd, DlgProc_AnniversaryEditor, (LPARAM)&Date)) {
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, NULL, NULL);
+ if (!pDateCtrl->AddDate(Date))
+ pDateCtrl->SetCurSel(pDateCtrl->NumDates() - 1);
+ }
}
- }
- return FALSE;
-
- /**
- * name: BTN_EDIT
- * desc: edit the currently selected anniversary
- **/
- case BTN_EDIT:
- if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
- MAnnivDate *pDate = pDateCtrl->Current();
- if (!pDate)
- MsgErr(hDlg, LPGENW("No valid date selected for editing!"));
- else if (
- IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), hDlg, DlgProc_AnniversaryEditor, (LPARAM)pDate) &&
- (pDate->Flags() & (MAnnivDate::MADF_CHANGED | MAnnivDate::MADF_REMINDER_CHANGED)))
- {
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- pDateCtrl->SetCurSel(pDateCtrl->CurrentIndex());
+ return FALSE;
+
+ /**
+ * name: BTN_EDIT
+ * desc: edit the currently selected anniversary
+ **/
+ case BTN_EDIT:
+ if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
+ MAnnivDate *pDate = pDateCtrl->Current();
+ if (!pDate)
+ MsgErr(m_hwnd, LPGENW("No valid date selected for editing!"));
+ else if (
+ IDOK == DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ANNIVERSARY_EDITOR), m_hwnd, DlgProc_AnniversaryEditor, (LPARAM)pDate) &&
+ (pDate->Flags() & (MAnnivDate::MADF_CHANGED | MAnnivDate::MADF_REMINDER_CHANGED)))
+ {
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, NULL, NULL);
+ pDateCtrl->SetCurSel(pDateCtrl->CurrentIndex());
+ }
}
- }
- return FALSE;
-
- /**
- * name: BTN_DELETE
- * desc: user wants to delete an anniversary
- **/
- case BTN_DELETE:
- if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
- MAnnivDate *pCurrent = pDateCtrl->Current();
- if (pCurrent) {
- int rc = MsgBox(hDlg, MB_YESNO | MB_ICON_QUESTION | MB_NOPOPUP, LPGENW("Delete"), nullptr,
- LPGENW("Do you really want to delete the %s?"), pCurrent->Description());
-
- if (rc == IDYES)
- pDateCtrl->DeleteDate(pDateCtrl->CurrentIndex());
+ return FALSE;
+
+ /**
+ * name: BTN_DELETE
+ * desc: user wants to delete an anniversary
+ **/
+ case BTN_DELETE:
+ if (HIWORD(wParam) == BN_CLICKED && PtrIsValid(pDateCtrl)) {
+ MAnnivDate *pCurrent = pDateCtrl->Current();
+ if (pCurrent) {
+ int rc = MsgBox(m_hwnd, MB_YESNO | MB_ICON_QUESTION | MB_NOPOPUP, LPGENW("Delete"), nullptr,
+ LPGENW("Do you really want to delete the %s?"), pCurrent->Description());
+
+ if (rc == IDYES)
+ pDateCtrl->DeleteDate(pDateCtrl->CurrentIndex());
+ }
}
+ return FALSE;
+
+ /**
+ * name: CHECK_REMIND
+ * desc: state of reminder checkbox is changed
+ **/
+ case RADIO_REMIND1:
+ case RADIO_REMIND2:
+ case RADIO_REMIND3:
+ if (PtrIsValid(pDateCtrl) && HIWORD(wParam) == BN_CLICKED)
+ pDateCtrl->OnReminderChecked();
+ return FALSE;
}
- return FALSE;
-
- /**
- * name: CHECK_REMIND
- * desc: state of reminder checkbox is changed
- **/
- case RADIO_REMIND1:
- case RADIO_REMIND2:
- case RADIO_REMIND3:
- if (PtrIsValid(pDateCtrl) && HIWORD(wParam) == BN_CLICKED)
- pDateCtrl->OnReminderChecked();
- return FALSE;
- } /* switch (LOWORD(wParam)) */
- break;
+ }
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitAnniversaryDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000003;
+ uip.pDialog = new PSPAnniversaryDlg();
+ uip.dwInitParam = ICONINDEX(IDI_BIRTHDAY);
+ uip.szTitle.w = LPGENW("General") L"\\" LPGENW("Anniversaries");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_base.cpp b/plugins/UserInfoEx/src/psp_base.cpp index d8d07bd9ea..0737807bcc 100644 --- a/plugins/UserInfoEx/src/psp_base.cpp +++ b/plugins/UserInfoEx/src/psp_base.cpp @@ -29,64 +29,76 @@ void UpDate_CountryIcon(HWND hCtrl, int countryID) IcoLib_ReleaseIcon(hOld);
}
+PSPBaseDlg::PSPBaseDlg(int idDialog) :
+ CUserInfoPageDlg(g_plugin, idDialog),
+ m_ctrlList(nullptr)
+{
+}
+
+bool PSPBaseDlg::OnInitDialog()
+{
+ m_ctrlList = CCtrlList::CreateObj(m_hwnd);
+
+ HFONT hBoldFont;
+ PSGetBoldFont(m_hwnd, hBoldFont);
+ SendDlgItemMessage(m_hwnd, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
+ return true;
+}
+
+void PSPBaseDlg::OnDestroy()
+{
+ m_ctrlList->Release();
+}
+
// Default dialog procedure, which handles common functions
-INT_PTR CALLBACK PSPBaseProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+INT_PTR PSPBaseDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- CCtrlList *pCtrlList;
-
- pCtrlList = CCtrlList::GetObj(hDlg);
- if (PtrIsValid(pCtrlList)) {
- switch (uMsg) {
- case WM_INITDIALOG:
- return TRUE;
-
- // set propertysheet page's background white in aero mode
- case WM_CTLCOLORSTATIC:
- case WM_CTLCOLORDLG:
- if (IsAeroMode())
- return (INT_PTR)GetStockBrush(WHITE_BRUSH);
- break;
+ switch (uMsg) {
+ // set propertysheet page's background white in aero mode
+ case WM_CTLCOLORSTATIC:
+ case WM_CTLCOLORDLG:
+ if (IsAeroMode())
+ return (INT_PTR)GetStockBrush(WHITE_BRUSH);
+ break;
+
+ // Set text color of edit boxes according to the source of information they display.
+ case WM_CTLCOLOREDIT:
+ if (m_ctrlList)
+ return m_ctrlList->OnSetTextColour((HWND)lParam, (HDC)wParam);
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
+ LPSTR pszProto;
+
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_RESET:
+ m_ctrlList->OnReset();
+ break;
- // Set text color of edit boxes according to the source of information they display.
- case WM_CTLCOLOREDIT:
- return pCtrlList->OnSetTextColour((HWND)lParam, (HDC)wParam);
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPSTR pszProto;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_RESET:
- pCtrlList->OnReset();
- break;
-
- case PSN_INFOCHANGED:
- if (PSGetBaseProto(hDlg, pszProto) && *pszProto) {
- BOOL bChanged = (GetWindowLongPtr(hDlg, DWLP_MSGRESULT)&PSP_CHANGED) | pCtrlList->OnInfoChanged(hContact, pszProto);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
- }
- break;
-
- case PSN_APPLY:
- if (PSGetBaseProto(hDlg, pszProto) && *pszProto)
- pCtrlList->OnApply(hContact, pszProto);
- break;
+ case PSN_INFOCHANGED:
+ if (PSGetBaseProto(m_hwnd, pszProto) && *pszProto) {
+ BOOL bChanged = (GetWindowLongPtr(m_hwnd, DWLP_MSGRESULT)&PSP_CHANGED) | m_ctrlList->OnInfoChanged(hContact, pszProto);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
}
break;
- }
- break;
- case WM_COMMAND:
- if (!PspIsLocked(hDlg))
- pCtrlList->OnChangedByUser(LOWORD(wParam), HIWORD(wParam));
+ case PSN_APPLY:
+ if (PSGetBaseProto(m_hwnd, pszProto) && *pszProto)
+ m_ctrlList->OnApply(hContact, pszProto);
+ break;
+ }
break;
-
- case WM_DESTROY:
- // destroy all control objects and the list
- pCtrlList->Release();
}
+ break;
+
+ case WM_COMMAND:
+ if (m_ctrlList && !PspIsLocked(m_hwnd))
+ m_ctrlList->OnChangedByUser(LOWORD(wParam), HIWORD(wParam));
+ break;
}
- return 0;
+
+ return CUserInfoPageDlg::DlgProc(uMsg, wParam, lParam);
}
diff --git a/plugins/UserInfoEx/src/psp_base.h b/plugins/UserInfoEx/src/psp_base.h index 6f8702b99f..55c4529120 100644 --- a/plugins/UserInfoEx/src/psp_base.h +++ b/plugins/UserInfoEx/src/psp_base.h @@ -22,20 +22,35 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _UI_PSP_BASE_INCLUDE_
#define _UI_PSP_BASE_INCLUDE_
-INT_PTR CALLBACK PSPBaseProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcCompany(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcContactHome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcContactWork(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcGeneral(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PSPProcEdit(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, const CHAR* pszSetting);
-static FORCEINLINE INT_PTR CALLBACK PSPProcMyNotes(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{ return PSPProcEdit(hDlg, uMsg, wParam, lParam, SET_CONTACT_MYNOTES); }
-static FORCEINLINE INT_PTR CALLBACK PSPProcAbout(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{ return PSPProcEdit(hDlg, uMsg, wParam, lParam, SET_CONTACT_ABOUT); }
+/////////////////////////////////////////////////////////////////////////////////////////
+// Base page dialog class
+
+class PSPBaseDlg : public CUserInfoPageDlg
+{
+ friend class CPsTreeItem;
+
+protected:
+ CCtrlList *m_ctrlList;
+
+ PSPBaseDlg(int idDialog);
+
+ virtual void OnIconsChanged() {}
+
+ bool OnInitDialog() override;
+ void OnDestroy() override;
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM, LPARAM) override;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void InitGeneralDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitContactDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitCompanyDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitAnniversaryDlg(WPARAM wParam, USERINFOPAGE &uip);
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip, bool bReadOnly);
+void InitProfileDlg(WPARAM wParam, USERINFOPAGE &uip);
void UpDate_CountryIcon(HWND hCtrl, int countryID);
diff --git a/plugins/UserInfoEx/src/psp_company.cpp b/plugins/UserInfoEx/src/psp_company.cpp index 06328e885f..d55e01db2b 100644 --- a/plugins/UserInfoEx/src/psp_company.cpp +++ b/plugins/UserInfoEx/src/psp_company.cpp @@ -21,42 +21,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the company contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcCompany(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+struct PSPCompanyDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- LPIDSTRLIST pList;
- UINT nList;
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_COMPANY, SET_CONTACT_COMPANY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_DEPARTMENT, SET_CONTACT_COMPANY_DEPARTMENT, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_OFFICE, SET_CONTACT_COMPANY_OFFICE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_POSITION, SET_CONTACT_COMPANY_POSITION, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_SUPERIOR, SET_CONTACT_COMPANY_SUPERIOR, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ASSISTENT, SET_CONTACT_COMPANY_ASSISTENT, DBVT_WCHAR));
-
- GetOccupationList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_OCCUPATION, SET_CONTACT_COMPANY_OCCUPATION, DBVT_WORD, pList, nList));
- }
- }
+ PSPCompanyDlg() :
+ PSPBaseDlg(IDD_CONTACT_COMPANY)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_COMPANY, SET_CONTACT_COMPANY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_DEPARTMENT, SET_CONTACT_COMPANY_DEPARTMENT, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_OFFICE, SET_CONTACT_COMPANY_OFFICE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_POSITION, SET_CONTACT_COMPANY_POSITION, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_SUPERIOR, SET_CONTACT_COMPANY_SUPERIOR, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ASSISTENT, SET_CONTACT_COMPANY_ASSISTENT, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetOccupationList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_OCCUPATION, SET_CONTACT_COMPANY_OCCUPATION, DBVT_WORD, pList, nList));
+ return true;
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitCompanyDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000004;
+ uip.pDialog = new PSPCompanyDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_COMPANY);
+ uip.szTitle.w = LPGENW("Work");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_contact.cpp b/plugins/UserInfoEx/src/psp_contact.cpp index f4e8b4ef65..5088972e12 100644 --- a/plugins/UserInfoEx/src/psp_contact.cpp +++ b/plugins/UserInfoEx/src/psp_contact.cpp @@ -21,291 +21,260 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the home contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcContactHome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Home contact info
+
+struct PSPContactHomeDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- wchar_t szAddr[MAX_PATH];
- LPIDSTRLIST pList;
- UINT nList;
-
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address"), TranslateT("home"));
- SetDlgItemText(hDlg, IDC_PAGETITLE, szAddr);
- SendDlgItemMessage(hDlg, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STREET, SET_CONTACT_STREET, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_CITY, SET_CONTACT_CITY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ZIP, SET_CONTACT_ZIP, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STATE, SET_CONTACT_STATE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_HOMEPAGE, SET_CONTACT_HOMEPAGE, DBVT_WCHAR));
-
- GetCountryList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_COUNTRY, SET_CONTACT_COUNTRY, DBVT_WORD, pList, nList));
+ PSPContactHomeDlg() :
+ PSPBaseDlg(IDD_CONTACT_ADDRESS)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ wchar_t szAddr[MAX_PATH];
+ mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address"), TranslateT("home"));
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, szAddr);
+
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STREET, SET_CONTACT_STREET, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_CITY, SET_CONTACT_CITY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ZIP, SET_CONTACT_ZIP, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STATE, SET_CONTACT_STATE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_HOMEPAGE, SET_CONTACT_HOMEPAGE, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetCountryList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_COUNTRY, SET_CONTACT_COUNTRY, DBVT_WORD, pList, nList));
+ return true;
+ }
- break;
- }
- }
- return FALSE;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
- HWND hCtrl;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t bChanged = 0;
-
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- // phone numbers
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_FAX);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
-
- // emails
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
- }
- break;
-
- case PSN_APPLY:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_FAX);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
-
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
- SendDlgItemMessage(hDlg, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- SetDlgItemText(hDlg, BTN_GOTO, hIcon ? L"" : L"->");
-
- hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
- SendDlgItemMessage(hDlg, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- ShowWindow(GetDlgItem(hDlg, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
-
- SendDlgItemMessage(hDlg, EDIT_PHONE, WM_SETICON, NULL, NULL);
- SendDlgItemMessage(hDlg, EDIT_EMAIL, WM_SETICON, NULL, NULL);
- }
- break;
- }
- }
- }
- }
- break;
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ uint8_t bChanged = 0;
+
+ // phone numbers
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), m_hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), m_hContact, USERINFO, pszProto, SET_CONTACT_FAX);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), m_hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+
+ // emails
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+ return bChanged != 0;
+ }
- case WM_COMMAND:
- {
+ bool OnApply() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_FAX);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+ return true;
+ }
+
+ void OnIconsChanged() override
+ {
+ HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ SetDlgItemText(m_hwnd, BTN_GOTO, hIcon ? L"" : L"->");
+
+ hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
+ SendDlgItemMessage(m_hwnd, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ ShowWindow(GetDlgItem(m_hwnd, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
+
+ SendDlgItemMessage(m_hwnd, EDIT_PHONE, WM_SETICON, NULL, NULL);
+ SendDlgItemMessage(m_hwnd, EDIT_EMAIL, WM_SETICON, NULL, NULL);
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (uMsg == WM_COMMAND) {
switch (LOWORD(wParam)) {
case EDIT_HOMEPAGE:
if (HIWORD(wParam) == EN_UPDATE)
- EnableWindow(GetDlgItem(hDlg, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
+ EnableWindow(GetDlgItem(m_hwnd, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
break;
case BTN_GOTO:
- CEditCtrl::GetObj(hDlg, EDIT_HOMEPAGE)->OpenUrl();
+ CEditCtrl::GetObj(m_hwnd, EDIT_HOMEPAGE)->OpenUrl();
break;
case EDIT_COUNTRY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
LPIDSTRLIST pd = (LPIDSTRLIST)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
- UpDate_CountryIcon(GetDlgItem(hDlg, ICO_COUNTRY), pd->nID);
+ UpDate_CountryIcon(GetDlgItem(m_hwnd, ICO_COUNTRY), pd->nID);
}
break;
}
}
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
-}
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Work contact info
-/**
- * Dialog procedure for the company's contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcContactWork(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+struct PSPContactWorkDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList)
- {
- wchar_t szAddr[MAX_PATH];
- LPIDSTRLIST pList;
- UINT nList;
-
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address and contact"), TranslateT("company"));
- SetDlgItemText(hDlg, IDC_PAGETITLE, szAddr);
- SendDlgItemMessage(hDlg, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STREET, SET_CONTACT_COMPANY_STREET, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_CITY, SET_CONTACT_COMPANY_CITY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ZIP, SET_CONTACT_COMPANY_ZIP, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STATE, SET_CONTACT_COMPANY_STATE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_HOMEPAGE, SET_CONTACT_COMPANY_HOMEPAGE, DBVT_WCHAR));
-
- GetCountryList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_COUNTRY, SET_CONTACT_COMPANY_COUNTRY, DBVT_WORD, pList, nList));
- }
- }
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
- HWND hCtrl;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t bChanged = 0;
-
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- // phone numbers
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
-
- // emails
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
- bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
- bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0);
- }
- break;
-
- case PSN_APPLY:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- hCtrl = GetDlgItem(hDlg, EDIT_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
-
- hCtrl = GetDlgItem(hDlg, EDIT_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
- CtrlContactWriteItemToDB(hCtrl, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
- CtrlContactWriteMyItemsToDB(hCtrl, 3, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
- SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
- SendDlgItemMessage(hDlg, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- SetDlgItemText(hDlg, BTN_GOTO, hIcon ? L"" : L"->");
-
- hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
- SendDlgItemMessage(hDlg, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- ShowWindow(GetDlgItem(hDlg, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
-
- SendDlgItemMessage(hDlg, EDIT_PHONE, WM_SETICON, NULL, NULL);
- SendDlgItemMessage(hDlg, EDIT_EMAIL, WM_SETICON, NULL, NULL);
- }
- break;
- }
- }
- }
- }
- break;
+ PSPContactWorkDlg() :
+ PSPBaseDlg(IDD_CONTACT_ADDRESS)
+ {}
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ wchar_t szAddr[MAX_PATH];
+ mir_snwprintf(szAddr, L"%s (%s)", TranslateT("Address and contact"), TranslateT("company"));
+ SetDlgItemText(m_hwnd, IDC_PAGETITLE, szAddr);
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open in browser"), MBBF_TCHAR);
+ TranslateDialogDefault(m_hwnd);
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STREET, SET_CONTACT_COMPANY_STREET, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_CITY, SET_CONTACT_COMPANY_CITY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ZIP, SET_CONTACT_COMPANY_ZIP, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STATE, SET_CONTACT_COMPANY_STATE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_HOMEPAGE, SET_CONTACT_COMPANY_HOMEPAGE, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetCountryList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_COUNTRY, SET_CONTACT_COMPANY_COUNTRY, DBVT_WORD, pList, nList));
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
+ CtrlContactWriteItemToDB(hCtrl, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
+ CtrlContactWriteMyItemsToDB(hCtrl, 3, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_RESETCHANGED, NULL, NULL);
+ return true;
+ }
- case WM_COMMAND:
- {
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ uint8_t bChanged = 0;
+
+ // phone numbers
+ HWND hCtrl = GetDlgItem(m_hwnd, EDIT_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+
+ // emails
+ hCtrl = GetDlgItem(m_hwnd, EDIT_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0);
+ bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1);
+ bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, m_hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL);
+ SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE);
+ return bChanged != 0;
+ }
+
+ void OnIconsChanged() override
+ {
+ HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO);
+ SendDlgItemMessage(m_hwnd, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ SetDlgItemText(m_hwnd, BTN_GOTO, hIcon ? L"" : L"->");
+
+ hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS);
+ SendDlgItemMessage(m_hwnd, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
+ ShowWindow(GetDlgItem(m_hwnd, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE);
+
+ SendDlgItemMessage(m_hwnd, EDIT_PHONE, WM_SETICON, NULL, NULL);
+ SendDlgItemMessage(m_hwnd, EDIT_EMAIL, WM_SETICON, NULL, NULL);
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (uMsg == WM_COMMAND) {
switch (LOWORD(wParam)) {
case EDIT_HOMEPAGE:
if (HIWORD(wParam) == EN_UPDATE)
- EnableWindow(GetDlgItem(hDlg, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
+ EnableWindow(GetDlgItem(m_hwnd, BTN_GOTO), GetWindowTextLength((HWND)lParam) > 0);
break;
case BTN_GOTO:
- CEditCtrl::GetObj(hDlg, EDIT_HOMEPAGE)->OpenUrl();
+ CEditCtrl::GetObj(m_hwnd, EDIT_HOMEPAGE)->OpenUrl();
break;
case EDIT_COUNTRY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
LPIDSTRLIST pd = (LPIDSTRLIST)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
- UpDate_CountryIcon(GetDlgItem(hDlg, ICO_COUNTRY), pd->nID);
+ UpDate_CountryIcon(GetDlgItem(m_hwnd, ICO_COUNTRY), pd->nID);
}
break;
}
}
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module entry point
+
+void InitContactDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000001;
+ uip.pDialog = new PSPContactHomeDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
+ uip.szTitle.w = LPGENW("General") L"\\" LPGENW("Contact (private)");
+ g_plugin.addUserInfo(wParam, &uip);
+
+ uip.position = 0x8000005;
+ uip.pDialog = new PSPContactWorkDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ADDRESS);
+ uip.szTitle.w = LPGENW("Work") L"\\" LPGENW("Contact (work)");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_general.cpp b/plugins/UserInfoEx/src/psp_general.cpp index 05c8d229fd..44c8576d85 100644 --- a/plugins/UserInfoEx/src/psp_general.cpp +++ b/plugins/UserInfoEx/src/psp_general.cpp @@ -21,162 +21,96 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * Dialog procedure for the contact information propertysheetpage
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcGeneral(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+struct PSPGeneralDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- LPIDSTRLIST pList;
- UINT nList;
- HFONT hBoldFont;
-
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
- TranslateDialogDefault(hDlg);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_TITLE, SET_CONTACT_TITLE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_FIRSTNAME, SET_CONTACT_FIRSTNAME, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_SECONDNAME, SET_CONTACT_SECONDNAME, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_LASTNAME, SET_CONTACT_LASTNAME, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_NICK, SET_CONTACT_NICK, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_DISPLAYNAME, "CList", SET_CONTACT_MYHANDLE, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_PARTNER, SET_CONTACT_PARTNER, DBVT_WCHAR));
-
- GetNamePrefixList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_PREFIX, SET_CONTACT_PREFIX, DBVT_BYTE, pList, nList));
-
- // marital groupbox
- GetMaritalList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_MARITAL, SET_CONTACT_MARITAL, DBVT_BYTE, pList, nList));
-
- GetLanguageList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG1, SET_CONTACT_LANG1, DBVT_WCHAR, pList, nList));
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG2, SET_CONTACT_LANG2, DBVT_WCHAR, pList, nList));
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG3, SET_CONTACT_LANG3, DBVT_WCHAR, pList, nList));
- }
- }
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- char* pszProto;
-
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t bEnable;
- DBVARIANT dbv;
- CCtrlFlags Flags;
-
- if (PSGetBaseProto(hDlg, pszProto) && *pszProto) {
- Flags.W = DB::Setting::GetTStringCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv);
- if (Flags.B.hasCustom || Flags.B.hasProto || Flags.B.hasMeta) {
- if (dbv.type == DBVT_BYTE) {
- CheckDlgButton(hDlg, RADIO_FEMALE, (dbv.bVal == 'F') ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hDlg, RADIO_MALE, (dbv.bVal == 'M') ? BST_CHECKED : BST_UNCHECKED);
-
- bEnable = !hContact || Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0);
- EnableWindow(GetDlgItem(hDlg, RADIO_FEMALE), bEnable);
- EnableWindow(GetDlgItem(hDlg, RADIO_MALE), bEnable);
- }
- else
- db_free(&dbv);
- }
- }
- }
- break;
-
- case PSN_APPLY:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- // gender
- {
- uint8_t gender
- = IsDlgButtonChecked(hDlg, RADIO_FEMALE)
- ? 'F'
- : IsDlgButtonChecked(hDlg, RADIO_MALE)
- ? 'M'
- : 0;
-
- if (gender)
- db_set_b(hContact, hContact ? USERINFO : pszProto, SET_CONTACT_GENDER, gender);
- else
- db_unset(hContact, hContact ? USERINFO : pszProto, SET_CONTACT_GENDER);
- }
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- const ICONCTRL idIcon[] = {
- { IDI_FEMALE, STM_SETIMAGE, ICO_FEMALE },
- { IDI_MALE, STM_SETIMAGE, ICO_MALE },
- { IDI_MARITAL, STM_SETIMAGE, ICO_MARITAL },
- };
- IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon));
- }
- }
- }
- }
- }
- break;
-
- case WM_COMMAND:
- {
- MCONTACT hContact;
- LPCSTR pszProto;
-
- switch (LOWORD(wParam)) {
- case RADIO_FEMALE:
- {
- if (!PspIsLocked(hDlg) && HIWORD(wParam) == BN_CLICKED) {
- DBVARIANT dbv;
-
- PSGetContact(hDlg, hContact);
- PSGetBaseProto(hDlg, pszProto);
-
- if (!DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv)
- || dbv.type != DBVT_BYTE
- || (dbv.bVal != 'F' && SendMessage((HWND)lParam, BM_GETCHECK, NULL, NULL)))
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- }
- }
- break;
-
- case RADIO_MALE:
- {
- if (!PspIsLocked(hDlg) && HIWORD(wParam) == BN_CLICKED) {
- DBVARIANT dbv;
+ PSPGeneralDlg() :
+ PSPBaseDlg(IDD_CONTACT_GENERAL)
+ {
+ }
- PSGetContact(hDlg, hContact);
- PSGetBaseProto(hDlg, pszProto);
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_TITLE, SET_CONTACT_TITLE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_FIRSTNAME, SET_CONTACT_FIRSTNAME, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_SECONDNAME, SET_CONTACT_SECONDNAME, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_LASTNAME, SET_CONTACT_LASTNAME, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_NICK, SET_CONTACT_NICK, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_DISPLAYNAME, "CList", SET_CONTACT_MYHANDLE, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_PARTNER, SET_CONTACT_PARTNER, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetNamePrefixList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_PREFIX, SET_CONTACT_PREFIX, DBVT_BYTE, pList, nList));
+
+ // marital groupbox
+ GetMaritalList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_MARITAL, SET_CONTACT_MARITAL, DBVT_BYTE, pList, nList));
+
+ GetLanguageList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_LANG1, SET_CONTACT_LANG1, DBVT_WCHAR, pList, nList));
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_LANG2, SET_CONTACT_LANG2, DBVT_WCHAR, pList, nList));
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_LANG3, SET_CONTACT_LANG3, DBVT_WCHAR, pList, nList));
+ return true;
+ }
- if (!DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv)
- || dbv.type != DBVT_BYTE
- || (dbv.bVal != 'M' && SendMessage((HWND)lParam, BM_GETCHECK, NULL, NULL)))
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- }
+ bool OnRefresh() override
+ {
+ char *pszProto;
+ if (PSGetBaseProto(m_hwnd, pszProto) && *pszProto) {
+ DBVARIANT dbv;
+ CCtrlFlags Flags;
+ Flags.W = DB::Setting::GetWStringCtrl(m_hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv);
+ if (Flags.B.hasCustom || Flags.B.hasProto || Flags.B.hasMeta) {
+ if (dbv.type == DBVT_BYTE) {
+ CheckDlgButton(m_hwnd, RADIO_FEMALE, (dbv.bVal == 'F') ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, RADIO_MALE, (dbv.bVal == 'M') ? BST_CHECKED : BST_UNCHECKED);
+
+ bool bEnable = !m_hContact || Flags.B.hasCustom || !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0);
+ EnableWindow(GetDlgItem(m_hwnd, RADIO_FEMALE), bEnable);
+ EnableWindow(GetDlgItem(m_hwnd, RADIO_MALE), bEnable);
}
+ else db_free(&dbv);
}
}
+ return false;
+ }
+
+ bool OnApply() override
+ {
+ char *pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ // gender
+ uint8_t gender = IsDlgButtonChecked(m_hwnd, RADIO_FEMALE) ? 'F' :
+ IsDlgButtonChecked(m_hwnd, RADIO_MALE) ? 'M' : 0;
+
+ if (gender)
+ db_set_b(m_hContact, m_hContact ? USERINFO : pszProto, SET_CONTACT_GENDER, gender);
+ else
+ db_unset(m_hContact, m_hContact ? USERINFO : pszProto, SET_CONTACT_GENDER);
+ return true;
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+
+ void OnIconsChanged() override
+ {
+ const ICONCTRL idIcon[] = {
+ { IDI_FEMALE, STM_SETIMAGE, ICO_FEMALE },
+ { IDI_MALE, STM_SETIMAGE, ICO_MALE },
+ { IDI_MARITAL, STM_SETIMAGE, ICO_MARITAL },
+ };
+ IcoLib_SetCtrlIcons(m_hwnd, idIcon, _countof(idIcon));
+ }
+};
+
+void InitGeneralDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000000;
+ uip.pDialog = new PSPGeneralDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_GENERAL);
+ uip.szTitle.w = LPGENW("General");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_origin.cpp b/plugins/UserInfoEx/src/psp_origin.cpp index c10d4c0fc0..78b85cc707 100644 --- a/plugins/UserInfoEx/src/psp_origin.cpp +++ b/plugins/UserInfoEx/src/psp_origin.cpp @@ -21,126 +21,109 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/**
- * This is the dialog procedure for the advanced contact information propertysheetpage.
- *
- * @param hDlg - handle to the dialog window
- * @param uMsg - the message to handle
- * @param wParam - parameter
- * @param lParam - parameter
- *
- * @return different values
- **/
-INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+class PSPOriginDlg : public PSPBaseDlg
{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
- if (pCtrlList) {
- LPIDSTRLIST pList;
- UINT nList;
-
- HFONT hBoldFont;
- PSGetBoldFont(hDlg, hBoldFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
-
- TranslateDialogDefault(hDlg);
- SetTimer(hDlg, 1, 5000, nullptr);
-
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STREET, SET_CONTACT_ORIGIN_STREET, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_ZIP, SET_CONTACT_ORIGIN_ZIP, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_CITY, SET_CONTACT_ORIGIN_CITY, DBVT_WCHAR));
- pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_STATE, SET_CONTACT_ORIGIN_STATE, DBVT_WCHAR));
-
- GetCountryList(&nList, &pList);
- pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_COUNTRY, SET_CONTACT_ORIGIN_COUNTRY, DBVT_WORD, pList, nList));
-
- pCtrlList->insert(CTzCombo::CreateObj(hDlg, EDIT_TIMEZONE, nullptr));
- }
+ CTimer timer;
+
+public:
+ PSPOriginDlg() :
+ PSPBaseDlg(IDD_CONTACT_ORIGIN),
+ timer(this, 1)
+ {
+ timer.OnEvent = Callback(this, &PSPOriginDlg::onTimer);
+ }
+
+ bool OnInitDialog() override
+ {
+ PSPBaseDlg::OnInitDialog();
+
+ timer.Start(5000);
+
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STREET, SET_CONTACT_ORIGIN_STREET, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_ZIP, SET_CONTACT_ORIGIN_ZIP, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_CITY, SET_CONTACT_ORIGIN_CITY, DBVT_WCHAR));
+ m_ctrlList->insert(CEditCtrl::CreateObj(m_hwnd, EDIT_STATE, SET_CONTACT_ORIGIN_STATE, DBVT_WCHAR));
+
+ UINT nList;
+ LPIDSTRLIST pList;
+ GetCountryList(&nList, &pList);
+ m_ctrlList->insert(CCombo::CreateObj(m_hwnd, EDIT_COUNTRY, SET_CONTACT_ORIGIN_COUNTRY, DBVT_WORD, pList, nList));
+
+ m_ctrlList->insert(CTzCombo::CreateObj(m_hwnd, EDIT_TIMEZONE, nullptr));
+ return true;
+ }
+
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ if (!PSGetBaseProto(m_hwnd, pszProto) || *pszProto == 0)
+ return false;
+
+ if (!m_hContact)
+ return false;
+
+ MTime mt;
+ if (mt.DBGetStamp(m_hContact, USERINFO, SET_CONTACT_ADDEDTIME) && strstr(pszProto, "ICQ")) {
+ uint32_t dwStamp;
+
+ dwStamp = DB::Contact::WhenAdded(db_get_dw(m_hContact, pszProto, "UIN", 0), pszProto);
+ if (dwStamp > 0)
+ mt.FromStampAsUTC(dwStamp);
}
- break;
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
-
- switch (((LPNMHDR) lParam)->code) {
- case PSN_INFOCHANGED:
- {
- if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
- break;
-
- if (hContact) {
- MTime mt;
-
- if (mt.DBGetStamp(hContact, USERINFO, SET_CONTACT_ADDEDTIME) && strstr(pszProto, "ICQ")) {
- uint32_t dwStamp;
-
- dwStamp = DB::Contact::WhenAdded(db_get_dw(hContact, pszProto, "UIN", 0), pszProto);
- if (dwStamp > 0)
- mt.FromStampAsUTC(dwStamp);
- }
- if (mt.IsValid()) {
- wchar_t szTime[MAX_PATH];
- LPTSTR ptr;
-
- mt.UTCToLocal();
- mt.DateFormatLong(szTime, _countof(szTime));
-
- mir_wstrcat(szTime, L" - ");
- ptr = szTime + mir_wstrlen(szTime);
- mt.TimeFormat(ptr, _countof(szTime) - (ptr - szTime));
- SetDlgItemText(hDlg, TXT_DATEADDED, szTime);
- }
- }
-
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, 0);
- }
- break;
-
- case PSN_ICONCHANGED:
- {
- const ICONCTRL idIcon[] = {
- { IDI_TREE_ADDRESS, STM_SETIMAGE, ICO_ADDRESS },
- { IDI_CLOCK, STM_SETIMAGE, ICO_CLOCK },
- };
-
- IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon));
- }
- }
- }
- } /* switch (((LPNMHDR)lParam)->idFrom) */
+ if (mt.IsValid()) {
+ wchar_t szTime[MAX_PATH];
+ LPTSTR ptr;
+
+ mt.UTCToLocal();
+ mt.DateFormatLong(szTime, _countof(szTime));
+
+ mir_wstrcat(szTime, L" - ");
+ ptr = szTime + mir_wstrlen(szTime);
+ mt.TimeFormat(ptr, _countof(szTime) - (ptr - szTime));
+ SetDlgItemText(m_hwnd, TXT_DATEADDED, szTime);
}
- break;
+ return false;
+ }
+
+ void OnIconsChanged() override
+ {
+ const ICONCTRL idIcon[] = {
+ { IDI_TREE_ADDRESS, STM_SETIMAGE, ICO_ADDRESS },
+ { IDI_CLOCK, STM_SETIMAGE, ICO_CLOCK },
+ };
+
+ IcoLib_SetCtrlIcons(m_hwnd, idIcon, _countof(idIcon));
+ }
- case WM_COMMAND:
- {
+ void onTimer(CTimer *)
+ {
+ wchar_t szTime[32];
+ CTzCombo::GetObj(m_hwnd, EDIT_TIMEZONE)->GetTime(szTime, _countof(szTime));
+ SetDlgItemText(m_hwnd, TXT_TIME, szTime);
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ if (uMsg == WM_COMMAND) {
switch (LOWORD(wParam)) {
case EDIT_COUNTRY:
if (HIWORD(wParam) == CBN_SELCHANGE) {
LPIDSTRLIST pd = (LPIDSTRLIST)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam));
- UpDate_CountryIcon(GetDlgItem(hDlg, ICO_COUNTRY), pd->nID);
+ UpDate_CountryIcon(GetDlgItem(m_hwnd, ICO_COUNTRY), pd->nID);
}
break;
}
}
- break;
-
- case WM_TIMER:
- {
- wchar_t szTime[32];
- CTzCombo::GetObj(hDlg, EDIT_TIMEZONE)->GetTime(szTime, _countof(szTime));
- SetDlgItemText(hDlg, TXT_TIME, szTime);
- break;
- }
-
- case WM_DESTROY:
- KillTimer(hDlg, 1);
+
+ return PSPBaseDlg::DlgProc(uMsg, wParam, lParam);
}
- return PSPBaseProc(hDlg, uMsg, wParam, lParam);
+};
+
+void InitOriginDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000002;
+ uip.pDialog = new PSPOriginDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_ADVANCED);
+ uip.szTitle.w = LPGENW("General") L"\\" LPGENW("Origin");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/psp_profile.cpp b/plugins/UserInfoEx/src/psp_profile.cpp index 9101d41d13..38ee787e90 100644 --- a/plugins/UserInfoEx/src/psp_profile.cpp +++ b/plugins/UserInfoEx/src/psp_profile.cpp @@ -274,7 +274,7 @@ static HWND ProfileList_BeginLabelEdit(LPLISTCTRL pList, int iItem, int iSubItem {
LVITEM lvi;
LPLCITEM pItem;
- MCONTACT hContact;
+ MCONTACT m_hContact;
RECT rcList;
if (!PtrIsValid(pList))
@@ -292,10 +292,10 @@ static HWND ProfileList_BeginLabelEdit(LPLISTCTRL pList, int iItem, int iSubItem pItem = (LPLCITEM)lvi.lParam;
- PSGetContact(GetParent(pList->hList), hContact);
+ PSGetContact(GetParent(pList->hList), m_hContact);
// do not edit deviders or protocol based contact information
- if (!(lvi.state & LVIS_SELECTED) || !PtrIsValid(pItem) || (hContact && (pItem->wFlags & CTRLF_HASPROTO)))
+ if (!(lvi.state & LVIS_SELECTED) || !PtrIsValid(pItem) || (m_hContact && (pItem->wFlags & CTRLF_HASPROTO)))
return nullptr;
ListView_EnsureVisible(pList->hList, iItem, FALSE);
@@ -423,12 +423,12 @@ static uint8_t ProfileList_AddNewItem(HWND hDlg, LPLISTCTRL pList, const PROFILE {
LPLCITEM pItem;
LVITEM lvi;
- MCONTACT hContact;
+ MCONTACT m_hContact;
if (PtrIsValid(pList) && (pItem = (LPLCITEM)mir_alloc(sizeof(LCITEM)))) {
- PSGetContact(hDlg, hContact);
+ PSGetContact(hDlg, m_hContact);
pItem->nType = CTRL_LIST_ITEM;
- pItem->wFlags = hContact ? CTRLF_HASCUSTOM : 0;
+ pItem->wFlags = m_hContact ? CTRLF_HASCUSTOM : 0;
pItem->iListItem = 0;
pItem->pszText[0] = nullptr;
pItem->pszText[1] = nullptr;
@@ -457,7 +457,7 @@ static uint8_t ProfileList_AddNewItem(HWND hDlg, LPLISTCTRL pList, const PROFILE * param: hList - HANDLE to the list to fill with two columns
* iItem - index of new listviewitem
* iImage - image to draw from a imagelist associated with the listview
- * hContact - handle to the contact, whose information are read
+ * m_hContact - handle to the contact, whose information are read
* pszModule - the module the information are stored in
* szCatFormat - name of a database setting that holds the categorytext
* szValFormat - name of a database setting that holds the valuetext
@@ -470,7 +470,7 @@ static int ProfileList_AddItemlistFromDB( int &iItem,
LPIDSTRLIST idList,
UINT nList,
- MCONTACT hContact,
+ MCONTACT m_hContact,
LPCSTR pszModule,
LPCSTR szCatFormat,
LPCSTR szValFormat,
@@ -488,12 +488,12 @@ static int ProfileList_AddItemlistFromDB( for (i = 0, lvi.iItem = iItem; ; i++) {
// read the setting from db
mir_snprintf(pszSetting, szValFormat, i);
- if (DB::Setting::GetTString(hContact, pszModule, pszSetting, &dbvVal))
+ if (DB::Setting::GetWString(m_hContact, pszModule, pszSetting, &dbvVal))
break;
if (dbvVal.type != DBVT_WCHAR)
continue;
mir_snprintf(pszSetting, szCatFormat, i);
- DB::Setting::GetAString(hContact, pszModule, pszSetting, &dbvCat);
+ DB::Setting::GetAString(m_hContact, pszModule, pszSetting, &dbvCat);
// create the itemobject
if (!(pItem = (LPLCITEM)mir_alloc(sizeof(LCITEM)))) {
db_free(&dbvCat);
@@ -1016,359 +1016,352 @@ static LRESULT CALLBACK ProfileList_SubclassProc(HWND hwnd, UINT msg, WPARAM wPa *
* return: 0 or 1
**/
-INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+
+struct PSPContactProfileDlg : public PSPBaseDlg
{
- HWND hList = GetDlgItem(hDlg, LIST_PROFILE);
+ PSPContactProfileDlg() :
+ PSPBaseDlg(IDD_CONTACT_PROFILE)
+ {}
+
+ HWND hList;
LPLISTCTRL pList;
- LVHITTESTINFO hi;
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- LVCOLUMN lvc;
- RECT rc;
- LOGFONT lf;
- HFONT hFont;
- TOOLINFO ti;
+ bool OnInitDialog() override
+ {
+ LVCOLUMN lvc;
+ RECT rc;
+ LOGFONT lf;
+ HFONT hFont;
- if (!hList || !(pList = (LPLISTCTRL)mir_alloc(sizeof(LISTCTRL))))
- return FALSE;
- memset(pList, 0, sizeof(LISTCTRL));
+ hList = GetDlgItem(m_hwnd, LIST_PROFILE);
+ if (!hList || !(pList = (LPLISTCTRL)mir_calloc(sizeof(LISTCTRL))))
+ return FALSE;
+
+ Ctrl_InitTextColours();
- TranslateDialogDefault(hDlg);
- Ctrl_InitTextColours();
+ // init info structure
+ pList->hList = hList;
+ pList->nType = CTRL_LIST_PROFILE;
+ memset(&pList->labelEdit, 0, sizeof(pList->labelEdit));
+ SetUserData(hList, pList);
- // init info structure
- pList->hList = hList;
- pList->nType = CTRL_LIST_PROFILE;
- memset(&pList->labelEdit, 0, sizeof(pList->labelEdit));
- SetUserData(hList, pList);
+ // set new window procedure
+ mir_subclassWindow(hList, ProfileList_SubclassProc);
- // set new window procedure
- mir_subclassWindow(hList, ProfileList_SubclassProc);
+ // remove static edge in aero mode
+ if (IsAeroMode())
+ SetWindowLongPtr(hList, GWL_EXSTYLE, GetWindowLongPtr(hList, GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
- // remove static edge in aero mode
- if (IsAeroMode())
- SetWindowLongPtr(hList, GWL_EXSTYLE, GetWindowLongPtr(hList, GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
-
- // insert columns into the listboxes
- ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
-
-
- PSGetBoldFont(hDlg, hFont);
- SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hFont, 0);
-
- // set listfont
- pList->hFont = (HFONT)SendMessage(hList, WM_GETFONT, 0, 0);
- pList->wFlags |= LVF_EDITLABEL;
- GetObject(pList->hFont, sizeof(lf), &lf);
- lf.lfHeight -= 6;
- hFont = CreateFontIndirect(&lf);
- SendMessage(hList, WM_SETFONT, (WPARAM)hFont, 0);
-
- GetClientRect(hList, &rc);
- rc.right -= GetSystemMetrics(SM_CXVSCROLL);
-
- // initiate the tooltips
- pList->hTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_BALLOON | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hList, nullptr, g_plugin.getInst(), nullptr);
- if (pList->hTip) {
- SetWindowPos(pList->hTip, HWND_TOPMOST, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
-
- memset(&ti, 0, sizeof(TOOLINFO));
- ti.cbSize = sizeof(TOOLINFO);
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS | TTF_TRANSPARENT;
- ti.hinst = g_plugin.getInst();
- ti.hwnd = hList;
- ti.uId = (UINT_PTR)hList;
- SendMessage(pList->hTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
- SendMessage(pList->hTip, TTM_ACTIVATE, FALSE, (LPARAM)&ti);
- }
+ // insert columns into the listboxes
+ ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
- // insert columns into the listboxes
- lvc.mask = LVCF_WIDTH;
- lvc.cx = rc.right / 8 * 3;
- ListView_InsertColumn(hList, 0, &lvc);
- lvc.cx = rc.right / 8 * 5;
- ListView_InsertColumn(hList, 1, &lvc);
- return TRUE;
+ PSGetBoldFont(m_hwnd, hFont);
+ SendDlgItemMessage(m_hwnd, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hFont, 0);
+
+ // set listfont
+ pList->hFont = (HFONT)SendMessage(hList, WM_GETFONT, 0, 0);
+ pList->wFlags |= LVF_EDITLABEL;
+ GetObject(pList->hFont, sizeof(lf), &lf);
+ lf.lfHeight -= 6;
+ hFont = CreateFontIndirect(&lf);
+ SendMessage(hList, WM_SETFONT, (WPARAM)hFont, 0);
+
+ GetClientRect(hList, &rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ // initiate the tooltips
+ pList->hTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_BALLOON | TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hList, nullptr, g_plugin.getInst(), nullptr);
+ if (pList->hTip) {
+ SetWindowPos(pList->hTip, HWND_TOPMOST, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+
+ TOOLINFO ti;
+ memset(&ti, 0, sizeof(TOOLINFO));
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS | TTF_TRANSPARENT;
+ ti.hinst = g_plugin.getInst();
+ ti.hwnd = hList;
+ ti.uId = (UINT_PTR)hList;
+ SendMessage(pList->hTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
+ SendMessage(pList->hTip, TTM_ACTIVATE, FALSE, (LPARAM)&ti);
}
- case WM_CTLCOLORSTATIC:
- case WM_CTLCOLORDLG:
- if (IsAeroMode())
- return (INT_PTR)GetStockBrush(WHITE_BRUSH);
- break;
+ // insert columns into the listboxes
+ lvc.mask = LVCF_WIDTH;
+ lvc.cx = rc.right / 8 * 3;
+ ListView_InsertColumn(hList, 0, &lvc);
+ lvc.cx = rc.right / 8 * 5;
+ ListView_InsertColumn(hList, 1, &lvc);
+ return true;
+ }
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- LPCSTR pszProto;
+ bool OnApply() override
+ {
+ if (pList->wFlags & CTRLF_CHANGED) {
+ uint8_t iFmt = -1;
+ wchar_t szGroup[MAX_PATH];
+ CHAR pszSetting[MAXSETTING];
+ LPLCITEM pItem;
+ int iItem;
+ LPSTR pszModule = USERINFO;
- if (!PtrIsValid(pList = (LPLISTCTRL)GetUserData(hList)))
- break;
+ if (!m_hContact)
+ PSGetBaseProto(m_hwnd, pszModule);
- // some account data may have changed so reread database
- switch (((LPNMHDR)lParam)->code) {
- case PSN_INFOCHANGED:
- {
- uint8_t msgResult = 0;
- LPIDSTRLIST idList;
- UINT nList;
- uint8_t i;
- int iItem = 0, iGrp = 0, numProtoItems, numUserItems;
-
- if (!(pList->wFlags & CTRLF_CHANGED) && PSGetBaseProto(hDlg, pszProto) && *pszProto != 0) {
- ProfileList_Clear(hList);
-
- // insert the past information
- for (i = 0; i < 3; i++) {
- pFmt[i].GetList((WPARAM)&nList, (LPARAM)&idList);
- if ((numProtoItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hContact, pszProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASPROTO)) < 0)
- return FALSE;
-
- // scan all basic protocols for the subcontacts
- if (DB::Module::IsMetaAndScan(pszProto)) {
- int iDefault = db_mc_getDefaultNum(hContact);
- MCONTACT hSubContact, hDefContact;
- LPCSTR pszSubBaseProto;
-
- if ((hDefContact = db_mc_getSub(hContact, iDefault)) && (pszSubBaseProto = Proto_GetBaseAccountName(hDefContact))) {
- if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hDefContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
- return FALSE;
-
- // copy the missing settings from the other subcontacts
- int numSubs = db_mc_getSubCount(hContact);
- for (int j = 0; j < numSubs; j++) {
- if (j == iDefault)
- continue;
- if (!(hSubContact = db_mc_getSub(hContact, j)))
- continue;
- if (!(pszSubBaseProto = Proto_GetBaseAccountName(hSubContact)))
- continue;
- if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
- return FALSE;
- //if ((numUserItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
- // return FALSE;
- }
- }
- }
- if ((numUserItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASCUSTOM)) < 0)
- return FALSE;
- if (numUserItems || numProtoItems) {
- msgResult = PSP_CHANGED;
- ProfileList_AddGroup(hList, pFmt[i].szGroup, iGrp);
- iGrp = ++iItem;
- }
- }
- }
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, msgResult);
- break;
- }
- // user swiches to another propertysheetpage
- case PSN_KILLACTIVE:
- ProfileList_EndLabelEdit(hList, TRUE);
- break;
- // user selected to apply settings to the database
- case PSN_APPLY:
- if (pList->wFlags & CTRLF_CHANGED) {
- uint8_t iFmt = -1;
- int iItem;
- LVITEM lvi;
- wchar_t szGroup[MAX_PATH];
- CHAR pszSetting[MAXSETTING];
- LPLCITEM pItem;
- LPSTR pszModule = USERINFO;
-
- if (!hContact)
- PSGetBaseProto(hDlg, pszModule);
+ *szGroup = 0;
+ LVITEM lvi;
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.pszText = szGroup;
+ lvi.cchTextMax = _countof(szGroup);
+
+ for (iItem = lvi.iItem = lvi.iSubItem = 0; ListView_GetItem(hList, &lvi); lvi.iItem++) {
+ if (!PtrIsValid(pItem = (LPLCITEM)lvi.lParam)) {
+ // delete reluctant items
+ if (iFmt < _countof(pFmt)) {
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
+ }
+ // find information about the group
+ for (iFmt = 0; iFmt < _countof(pFmt); iFmt++) {
+ if (!mir_wstrcmp(szGroup, pFmt[iFmt].szGroup))
+ break;
+ }
+ // indicate, no group was found. should not happen!!
+ if (iFmt == _countof(pFmt)) {
*szGroup = 0;
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.pszText = szGroup;
- lvi.cchTextMax = _countof(szGroup);
-
- for (iItem = lvi.iItem = lvi.iSubItem = 0; ListView_GetItem(hList, &lvi); lvi.iItem++) {
- if (!PtrIsValid(pItem = (LPLCITEM)lvi.lParam)) {
- // delete reluctant items
- if (iFmt < _countof(pFmt)) {
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
- }
- // find information about the group
- for (iFmt = 0; iFmt < _countof(pFmt); iFmt++) {
- if (!mir_wstrcmp(szGroup, pFmt[iFmt].szGroup))
- break;
- }
- // indicate, no group was found. should not happen!!
- if (iFmt == _countof(pFmt)) {
- *szGroup = 0;
- iFmt = -1;
- }
- iItem = 0;
- }
- else if (iFmt >= 0 && iFmt < _countof(pFmt)) {
- // save value
- if (!pItem->pszText[1] || !*pItem->pszText[1])
- continue;
- if (!(pItem->wFlags & (CTRLF_HASPROTO|CTRLF_HASMETA))) {
- mir_snprintf(pszSetting, pFmt[iFmt].szValFmt, iItem);
- db_set_ws(hContact, pszModule, pszSetting, pItem->pszText[1]);
- // save category
- mir_snprintf(pszSetting, pFmt[iFmt].szCatFmt, iItem);
- if (pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount)
- db_set_s(hContact, pszModule, pszSetting, (LPSTR)pItem->idstrList[pItem->iListItem].pszText);
- else if (pItem->pszText[0] && *pItem->pszText[0])
- db_set_ws(hContact, pszModule, pszSetting, (LPTSTR)pItem->pszText[0]);
- else
- db_unset(hContact, pszModule, pszSetting);
- // redraw the item if required
- if (pItem->wFlags & CTRLF_CHANGED) {
- pItem->wFlags &= ~CTRLF_CHANGED;
- ListView_RedrawItems(hList, lvi.iItem, lvi.iItem);
- }
- iItem++;
- }
- }
- }
- // delete reluctant items
- if (iFmt >= 0 && iFmt < _countof(pFmt)) {
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
- DB::Setting::DeleteArray(hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
+ iFmt = -1;
+ }
+ iItem = 0;
+ }
+ else if (iFmt >= 0 && iFmt < _countof(pFmt)) {
+ // save value
+ if (!pItem->pszText[1] || !*pItem->pszText[1])
+ continue;
+ if (!(pItem->wFlags & (CTRLF_HASPROTO|CTRLF_HASMETA))) {
+ mir_snprintf(pszSetting, pFmt[iFmt].szValFmt, iItem);
+ db_set_ws(m_hContact, pszModule, pszSetting, pItem->pszText[1]);
+ // save category
+ mir_snprintf(pszSetting, pFmt[iFmt].szCatFmt, iItem);
+ if (pItem->idstrList && pItem->iListItem > 0 && pItem->iListItem < pItem->idstrListCount)
+ db_set_s(m_hContact, pszModule, pszSetting, (LPSTR)pItem->idstrList[pItem->iListItem].pszText);
+ else if (pItem->pszText[0] && *pItem->pszText[0])
+ db_set_ws(m_hContact, pszModule, pszSetting, (LPTSTR)pItem->pszText[0]);
+ else
+ db_unset(m_hContact, pszModule, pszSetting);
+ // redraw the item if required
+ if (pItem->wFlags & CTRLF_CHANGED) {
+ pItem->wFlags &= ~CTRLF_CHANGED;
+ ListView_RedrawItems(hList, lvi.iItem, lvi.iItem);
}
-
- pList->wFlags &= ~CTRLF_CHANGED;
+ iItem++;
}
}
}
- break;
+ // delete reluctant items
+ if (iFmt >= 0 && iFmt < _countof(pFmt)) {
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szCatFmt, iItem);
+ DB::Setting::DeleteArray(m_hContact, pszModule, pFmt[iFmt].szValFmt, iItem);
+ }
- // handle notification messages from the list control
- case LIST_PROFILE:
- pList = (LPLISTCTRL)GetUserData(((LPNMHDR)lParam)->hwndFrom);
+ pList->wFlags &= ~CTRLF_CHANGED;
+ }
+ return true;
+ }
- switch (((LPNMHDR)lParam)->code) {
- case NM_RCLICK:
- {
- HMENU hMenu = CreatePopupMenu();
- MCONTACT hContact;
- LPLCITEM pItem;
- POINT pt;
-
- if (!hMenu)
- return 1;
- PSGetContact(hDlg, hContact);
- GetCursorPos(&pt);
- hi.pt = pt;
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hi.pt);
- ListView_SubItemHitTest(((LPNMHDR)lParam)->hwndFrom, &hi);
- pItem = ProfileList_GetItemData(((LPNMHDR)lParam)->hwndFrom, hi.iItem);
-
- // insert menuitems
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_ID|MIIM_STRING;
- // insert "Add" Menuitem
- mii.wID = BTN_ADD_intEREST;
- mii.dwTypeData = TranslateT("Add interest");
- InsertMenuItem(hMenu, 0, TRUE, &mii);
- mii.wID = BTN_ADD_AFFLIATION;
- mii.dwTypeData = TranslateT("Add affiliation");
- InsertMenuItem(hMenu, 1, TRUE, &mii);
- mii.wID = BTN_ADD_PAST;
- mii.dwTypeData = TranslateT("Add past");
- InsertMenuItem(hMenu, 2, TRUE, &mii);
-
- if (hi.iItem != -1 && PtrIsValid(pItem) && !(hContact && (pItem->wFlags & CTRLF_HASPROTO))) {
- // insert separator
- mii.fMask = MIIM_FTYPE;
- mii.fType = MFT_SEPARATOR;
- InsertMenuItem(hMenu, 3, TRUE, &mii);
- // insert "Delete" Menuitem
- mii.fMask = MIIM_ID | MIIM_STRING;
- mii.wID = BTN_EDIT_CAT;
- mii.dwTypeData = TranslateT("Edit category");
- InsertMenuItem(hMenu, 4, TRUE, &mii);
- mii.wID = BTN_EDIT_VAL;
- mii.dwTypeData = TranslateT("Edit value");
- InsertMenuItem(hMenu, 5, TRUE, &mii);
- mii.fMask = MIIM_FTYPE;
- mii.fType = MFT_SEPARATOR;
- InsertMenuItem(hMenu, 6, TRUE, &mii);
- // insert "Delete" Menuitem
- mii.fMask = MIIM_ID | MIIM_STRING;
- mii.wID = BTN_DEL;
- mii.dwTypeData = TranslateT("Delete");
- InsertMenuItem(hMenu, 7, TRUE, &mii);
+ bool OnRefresh() override
+ {
+ LPCSTR pszProto;
+ uint8_t msgResult = 0;
+ LPIDSTRLIST idList;
+ UINT nList;
+ uint8_t i;
+ int iItem = 0, iGrp = 0, numProtoItems, numUserItems;
+
+ if (!(pList->wFlags & CTRLF_CHANGED) && PSGetBaseProto(m_hwnd, pszProto) && *pszProto != 0) {
+ ProfileList_Clear(hList);
+
+ // insert the past information
+ for (i = 0; i < 3; i++) {
+ pFmt[i].GetList((WPARAM)&nList, (LPARAM)&idList);
+ if ((numProtoItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, m_hContact, pszProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASPROTO)) < 0)
+ return false;
+
+ // scan all basic protocols for the subcontacts
+ if (DB::Module::IsMetaAndScan(pszProto)) {
+ int iDefault = db_mc_getDefaultNum(m_hContact);
+ MCONTACT hSubContact, hDefContact;
+ LPCSTR pszSubBaseProto;
+
+ if ((hDefContact = db_mc_getSub(m_hContact, iDefault)) && (pszSubBaseProto = Proto_GetBaseAccountName(hDefContact))) {
+ if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hDefContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
+ return false;
+
+ // copy the missing settings from the other subcontacts
+ int numSubs = db_mc_getSubCount(m_hContact);
+ for (int j = 0; j < numSubs; j++) {
+ if (j == iDefault)
+ continue;
+ if (!(hSubContact = db_mc_getSub(m_hContact, j)))
+ continue;
+ if (!(pszSubBaseProto = Proto_GetBaseAccountName(hSubContact)))
+ continue;
+ if ((numProtoItems += ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, hSubContact, pszSubBaseProto, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASMETA | CTRLF_HASPROTO)) < 0)
+ return false;
+ }
}
- TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hDlg, nullptr);
- DestroyMenu(hMenu);
}
- return 0;
+ if ((numUserItems = ProfileList_AddItemlistFromDB(pList, iItem, idList, nList, m_hContact, USERINFO, pFmt[i].szCatFmt, pFmt[i].szValFmt, CTRLF_HASCUSTOM)) < 0)
+ return false;
- case LVN_GETDISPINFO:
- if (pList->labelEdit.iTopIndex != ListView_GetTopIndex(hList))
- ProfileList_EndLabelEdit(((LPNMHDR)lParam)->hwndFrom, FALSE);
+ if (numUserItems || numProtoItems) {
+ msgResult = PSP_CHANGED;
+ ProfileList_AddGroup(hList, pFmt[i].szGroup, iGrp);
+ iGrp = ++iItem;
+ }
+ }
+ }
+ return false;
+ }
+
+ INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
+ {
+ LVHITTESTINFO hi;
+
+ switch (uMsg) {
+ case WM_CTLCOLORSTATIC:
+ case WM_CTLCOLORDLG:
+ if (IsAeroMode())
+ return (INT_PTR)GetStockBrush(WHITE_BRUSH);
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ // some account data may have changed so reread database
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_KILLACTIVE: // user swiches to another propertysheetpage
+ ProfileList_EndLabelEdit(hList, TRUE);
+ break;
+ }
break;
- case NM_CUSTOMDRAW:
- {
- LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam;
- LPLCITEM pItem = (LPLCITEM)cd->nmcd.lItemlParam;
- RECT rc;
-
- switch (cd->nmcd.dwDrawStage) {
- case CDDS_PREPAINT:
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
- return TRUE;
-
- case CDDS_ITEMPREPAINT:
- ListView_GetItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, &rc, LVIR_BOUNDS);
- if (!PtrIsValid(pItem)) {
- HFONT hBold, hFont;
- wchar_t szText[MAX_PATH];
-
- PSGetBoldFont(hDlg, hBold);
- hFont = (HFONT)SelectObject(cd->nmcd.hdc, hBold);
- SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_3DSHADOW));
- ProfileList_GetItemText(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, 0, szText, MAX_PATH);
- rc.left += 6;
- DrawText(cd->nmcd.hdc, TranslateW(szText), -1, &rc, DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
-
- rc.bottom -= 2;
- rc.top = rc.bottom - 1;
- rc.left -= 6;
- DrawEdge(cd->nmcd.hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
-
- SelectObject(cd->nmcd.hdc, hFont);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
- // draw selected item
- if ((cd->nmcd.uItemState & CDIS_SELECTED) || (pList->labelEdit.iItem == (int)cd->nmcd.dwItemSpec)) {
- SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
- FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
- }
- // draw background of unselected item
- else {
- SetTextColor(cd->nmcd.hdc,
- (pItem->wFlags & CTRLF_CHANGED)
- ? clrChanged : (pItem->wFlags & CTRLF_HASMETA)
- ? clrMeta : ((pItem->wFlags & (CTRLF_HASCUSTOM)) && (pItem->wFlags & CTRLF_HASPROTO))
- ? clrBoth : (pItem->wFlags & CTRLF_HASCUSTOM)
- ? clrCustom : clrNormal);
- FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
+ // handle notification messages from the list control
+ case LIST_PROFILE:
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_RCLICK:
+ {
+ HMENU hMenu = CreatePopupMenu();
+ if (!hMenu)
+ return 1;
+
+ POINT pt;
+ GetCursorPos(&pt);
+ hi.pt = pt;
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hi.pt);
+ ListView_SubItemHitTest(((LPNMHDR)lParam)->hwndFrom, &hi);
+ LPLCITEM pItem = ProfileList_GetItemData(((LPNMHDR)lParam)->hwndFrom, hi.iItem);
+
+ // insert menuitems
+ MENUITEMINFO mii = { 0 };
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_ID|MIIM_STRING;
+ // insert "Add" Menuitem
+ mii.wID = BTN_ADD_intEREST;
+ mii.dwTypeData = TranslateT("Add interest");
+ InsertMenuItem(hMenu, 0, TRUE, &mii);
+ mii.wID = BTN_ADD_AFFLIATION;
+ mii.dwTypeData = TranslateT("Add affiliation");
+ InsertMenuItem(hMenu, 1, TRUE, &mii);
+ mii.wID = BTN_ADD_PAST;
+ mii.dwTypeData = TranslateT("Add past");
+ InsertMenuItem(hMenu, 2, TRUE, &mii);
+
+ if (hi.iItem != -1 && PtrIsValid(pItem) && !(m_hContact && (pItem->wFlags & CTRLF_HASPROTO))) {
+ // insert separator
+ mii.fMask = MIIM_FTYPE;
+ mii.fType = MFT_SEPARATOR;
+ InsertMenuItem(hMenu, 3, TRUE, &mii);
+ // insert "Delete" Menuitem
+ mii.fMask = MIIM_ID | MIIM_STRING;
+ mii.wID = BTN_EDIT_CAT;
+ mii.dwTypeData = TranslateT("Edit category");
+ InsertMenuItem(hMenu, 4, TRUE, &mii);
+ mii.wID = BTN_EDIT_VAL;
+ mii.dwTypeData = TranslateT("Edit value");
+ InsertMenuItem(hMenu, 5, TRUE, &mii);
+ mii.fMask = MIIM_FTYPE;
+ mii.fType = MFT_SEPARATOR;
+ InsertMenuItem(hMenu, 6, TRUE, &mii);
+ // insert "Delete" Menuitem
+ mii.fMask = MIIM_ID | MIIM_STRING;
+ mii.wID = BTN_DEL;
+ mii.dwTypeData = TranslateT("Delete");
+ InsertMenuItem(hMenu, 7, TRUE, &mii);
}
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_NEWFONT | CDRF_NOTIFYSUBITEMDRAW);
- return TRUE;
+ TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, m_hwnd, nullptr);
+ DestroyMenu(hMenu);
+ }
+ return 0;
- case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
- {
-// HFONT hoFont = (HFONT)SelectObject(cd->nmcd.hdc, pList->hFont);
+ case LVN_GETDISPINFO:
+ if (pList->labelEdit.iTopIndex != ListView_GetTopIndex(hList))
+ ProfileList_EndLabelEdit(((LPNMHDR)lParam)->hwndFrom, FALSE);
+ break;
+
+ case NM_CUSTOMDRAW:
+ {
+ LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam;
+ LPLCITEM pItem = (LPLCITEM)cd->nmcd.lItemlParam;
+ RECT rc;
+ switch (cd->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT:
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW);
+ return TRUE;
+
+ case CDDS_ITEMPREPAINT:
+ ListView_GetItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, &rc, LVIR_BOUNDS);
+ if (!PtrIsValid(pItem)) {
+ HFONT hBold, hFont;
+ wchar_t szText[MAX_PATH];
+
+ PSGetBoldFont(m_hwnd, hBold);
+ hFont = (HFONT)SelectObject(cd->nmcd.hdc, hBold);
+ SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_3DSHADOW));
+ ProfileList_GetItemText(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, 0, szText, MAX_PATH);
+ rc.left += 6;
+ DrawText(cd->nmcd.hdc, TranslateW(szText), -1, &rc, DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
+
+ rc.bottom -= 2;
+ rc.top = rc.bottom - 1;
+ rc.left -= 6;
+ DrawEdge(cd->nmcd.hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
+
+ SelectObject(cd->nmcd.hdc, hFont);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
+ return TRUE;
+ }
+ // draw selected item
+ if ((cd->nmcd.uItemState & CDIS_SELECTED) || (pList->labelEdit.iItem == (int)cd->nmcd.dwItemSpec)) {
+ SetTextColor(cd->nmcd.hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
+ }
+ // draw background of unselected item
+ else {
+ SetTextColor(cd->nmcd.hdc,
+ (pItem->wFlags & CTRLF_CHANGED)
+ ? clrChanged : (pItem->wFlags & CTRLF_HASMETA)
+ ? clrMeta : ((pItem->wFlags & (CTRLF_HASCUSTOM)) && (pItem->wFlags & CTRLF_HASPROTO))
+ ? clrBoth : (pItem->wFlags & CTRLF_HASCUSTOM)
+ ? clrCustom : clrNormal);
+ FillRect(cd->nmcd.hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
+ }
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_NEWFONT | CDRF_NOTIFYSUBITEMDRAW);
+ return TRUE;
+
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
ListView_GetSubItemRect(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec, cd->iSubItem, LVIR_BOUNDS, &rc);
if (cd->iSubItem == 0) {
RECT rc2;
@@ -1383,47 +1376,55 @@ INT_PTR CALLBACK PSPProcContactProfile(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR ? pItem->idstrList[pItem->iListItem].ptszTranslated
: TranslateT("<empty>"),
-1, &rc, DT_END_ELLIPSIS | DT_NOCLIP | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
- SetWindowLongPtr(hDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
return TRUE;
- }
- } /* switch (cd->nmcd.dwDrawStage) */
- break;
- } /* case NM_CUSTOMDRAW: */
- } /* (((LPNMHDR)lParam)->code) */
- break;
- }
- break; /* case WM_NOTIFY: */
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case BTN_ADD_intEREST:
- return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[2]);
- case BTN_ADD_AFFLIATION:
- return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[1]);
- case BTN_ADD_PAST:
- return ProfileList_AddNewItem(hDlg, (LPLISTCTRL)GetUserData(hList), &pFmt[0]);
- case BTN_EDIT_CAT:
- ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 0);
- break;
- case BTN_EDIT_VAL:
- ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 1);
- break;
- case BTN_DEL:
- if (IDYES == MsgBox(hDlg, MB_YESNO | MB_ICON_QUESTION, LPGENW("Question"), LPGENW("Delete an entry"), LPGENW("Do you really want to delete this entry?"))) {
- int iItem = ListView_GetSelectionMark(hList);
- pList = (LPLISTCTRL)GetUserData(hList);
-
- ProfileList_DeleteItem(hList, iItem);
- if (PtrIsValid(pList))
- pList->wFlags |= CTRLF_CHANGED;
- SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
- // check if to delete any devider
- if (!ProfileList_GetItemData(hList, iItem--) && !ProfileList_GetItemData(hList, iItem))
- ListView_DeleteItem(hList, iItem);
+ } /* switch (cd->nmcd.dwDrawStage) */
+ break;
+ } /* case NM_CUSTOMDRAW: */
+ } /* (((LPNMHDR)lParam)->code) */
+ break;
+ }
+ break; /* case WM_NOTIFY: */
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case BTN_ADD_intEREST:
+ return ProfileList_AddNewItem(m_hwnd, (LPLISTCTRL)GetUserData(hList), &pFmt[2]);
+ case BTN_ADD_AFFLIATION:
+ return ProfileList_AddNewItem(m_hwnd, (LPLISTCTRL)GetUserData(hList), &pFmt[1]);
+ case BTN_ADD_PAST:
+ return ProfileList_AddNewItem(m_hwnd, (LPLISTCTRL)GetUserData(hList), &pFmt[0]);
+ case BTN_EDIT_CAT:
+ ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 0);
+ break;
+ case BTN_EDIT_VAL:
+ ProfileList_BeginLabelEdit(hList, ListView_GetSelectionMark(hList), 1);
+ break;
+ case BTN_DEL:
+ if (IDYES == MsgBox(m_hwnd, MB_YESNO | MB_ICON_QUESTION, LPGENW("Question"), LPGENW("Delete an entry"), LPGENW("Do you really want to delete this entry?"))) {
+ int iItem = ListView_GetSelectionMark(hList);
+ ProfileList_DeleteItem(hList, iItem);
+
+ if (PtrIsValid(pList))
+ pList->wFlags |= CTRLF_CHANGED;
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, NULL, NULL);
+ // check if to delete any devider
+ if (!ProfileList_GetItemData(hList, iItem--) && !ProfileList_GetItemData(hList, iItem))
+ ListView_DeleteItem(hList, iItem);
+ }
+ break;
}
break;
}
- break;
+ return FALSE;
}
- return FALSE;
+};
+
+void InitProfileDlg(WPARAM wParam, USERINFOPAGE &uip)
+{
+ uip.position = 0x8000007;
+ uip.pDialog = new PSPContactProfileDlg();
+ uip.dwInitParam = ICONINDEX(IDI_TREE_PROFILE);
+ uip.szTitle.w = LPGENW("About") L"\\" LPGENW("Profile");
+ g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/plugins/UserInfoEx/src/stdafx.h b/plugins/UserInfoEx/src/stdafx.h index cafc703717..2d71b7698a 100644 --- a/plugins/UserInfoEx/src/stdafx.h +++ b/plugins/UserInfoEx/src/stdafx.h @@ -103,6 +103,14 @@ using namespace std; #define GetUserData(p) GetWindowLongPtr((p), GWLP_USERDATA)
#define SetUserData(p, l) SetWindowLongPtr((p), GWLP_USERDATA, (LONG_PTR) (l))
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin();
+
+ int Load() override;
+ int Unload() override;
+};
+
#include "resource.h"
#include "version.h"
#include "../IconPacks/default/src/icons.h"
@@ -150,14 +158,6 @@ using namespace std; * UserInfoEx global variables
***********************************************************************************************************/
-struct CMPlugin : public PLUGIN<CMPlugin>
-{
- CMPlugin();
-
- int Load() override;
- int Unload() override;
-};
-
typedef struct _MGLOBAL
{
uint8_t CanChangeDetails : 1; // is service to upload own contact information for icq present?
|