summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/VKontakte/res/resource.rc12
-rw-r--r--protocols/VKontakte/src/vk_dialogs.cpp54
-rw-r--r--protocols/VKontakte/src/vk_dialogs.h43
-rw-r--r--protocols/VKontakte/src/vk_wallpost.cpp70
4 files changed, 102 insertions, 77 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index 54510e8797..ff8e88addb 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -112,7 +112,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 309
TOPMARGIN, 7
- BOTTOMMARGIN, 137
+ BOTTOMMARGIN, 127
END
END
#endif // APSTUDIO_INVOKED
@@ -314,17 +314,17 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,160,211,50,14
END
-IDD_WALLPOST DIALOGEX 0, 0, 316, 144
-STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+IDD_WALLPOST DIALOGEX 0, 0, 316, 134
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "Share",IDOK,205,123,50,14
- PUSHBUTTON "Cancel",IDCANCEL,259,123,50,14
+ PUSHBUTTON "Share",IDOK,205,113,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,259,113,50,14
EDITTEXT IDC_ED_MSG,7,7,302,70,ES_MULTILINE | ES_AUTOHSCROLL
EDITTEXT IDC_ED_URL,61,82,248,12,ES_AUTOHSCROLL
RTEXT "URL:",IDC_STATIC,7,84,49,8
CONTROL "Only for friends",IDC_ONLY_FRIENDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,61,98,248,10
- CTEXT "Attention",IDC_ST_WARNING,7,112,302,10
END
diff --git a/protocols/VKontakte/src/vk_dialogs.cpp b/protocols/VKontakte/src/vk_dialogs.cpp
index bfd08e0e86..b934d14cf7 100644
--- a/protocols/VKontakte/src/vk_dialogs.cpp
+++ b/protocols/VKontakte/src/vk_dialogs.cpp
@@ -17,8 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+////////////////////////////////// IDD_CAPTCHAFORM ////////////////////////////////////////
+
CaptchaForm::CaptchaForm(CVkProto *proto, CAPTCHA_FORM_PARAMS* param) :
- CVkDlgBase(proto, IDD_CAPTCHAFORM),
+ CVkDlgBase(proto, IDD_CAPTCHAFORM, false),
m_instruction(this, IDC_INSTRUCTION),
m_edtValue(this, IDC_VALUE),
m_btnOpenInBrowser(this, IDOPENBROWSER),
@@ -98,5 +100,51 @@ void CaptchaForm::On_btnOk_Click(CCtrlButton*)
void CaptchaForm::On_edtValue_Change(CCtrlEdit*)
{
- m_btnOk.Enable(mir_strlen(ptrA(m_edtValue.GetTextA())));
-} \ No newline at end of file
+ m_btnOk.Enable(!IsEmpty(ptrA(m_edtValue.GetTextA())));
+}
+
+////////////////////////////////// IDD_WALLPOST ///////////////////////////////////////////
+
+WallPostForm::WallPostForm(CVkProto * proto, WALLPOST_FORM_PARAMS * param) :
+ CVkDlgBase(proto, IDD_WALLPOST, false),
+ m_edtMsg(this, IDC_ED_MSG),
+ m_edtUrl(this, IDC_ED_URL),
+ m_cbOnlyForFriends(this, IDC_ONLY_FRIENDS),
+ m_btnShare(this, IDOK),
+ m_param(param)
+{
+ m_btnShare.OnClick = Callback(this, &WallPostForm::On_btnShare_Click);
+ m_edtMsg.OnChange = Callback(this, &WallPostForm::On_edtValue_Change);
+ m_edtUrl.OnChange = Callback(this, &WallPostForm::On_edtValue_Change);
+}
+
+void WallPostForm::OnInitDialog()
+{
+ SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(GetIconHandle(IDI_WALL), TRUE));
+ SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(GetIconHandle(IDI_WALL)));
+
+ CMString tszTitle(FORMAT, _T("%s %s"), TranslateT("Wall message for"), m_param->ptszNick);
+ SetCaption(tszTitle);
+
+ m_btnShare.Disable();
+}
+
+void WallPostForm::OnDestroy()
+{
+ IcoLib_ReleaseIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
+ IcoLib_ReleaseIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
+}
+
+void WallPostForm::On_btnShare_Click(CCtrlButton *)
+{
+ m_param->ptszUrl = mir_tstrdup(m_edtUrl.GetText());
+ m_param->ptszMsg = mir_tstrdup(m_edtMsg.GetText());
+ m_param->bFriendsOnly = m_cbOnlyForFriends.GetState();
+
+ EndDialog(m_hwnd, 1);
+}
+
+void WallPostForm::On_edtValue_Change(CCtrlEdit *)
+{
+ m_btnShare.Enable(!IsEmpty(ptrT(m_edtMsg.GetText())) || !IsEmpty(ptrT(m_edtUrl.GetText())));
+}
diff --git a/protocols/VKontakte/src/vk_dialogs.h b/protocols/VKontakte/src/vk_dialogs.h
index f881e8f618..bfdbc272c2 100644
--- a/protocols/VKontakte/src/vk_dialogs.h
+++ b/protocols/VKontakte/src/vk_dialogs.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
typedef CProtoDlgBase<CVkProto> CVkDlgBase;
+////////////////////////////////// IDD_CAPTCHAFORM ////////////////////////////////////////
+
struct CAPTCHA_FORM_PARAMS
{
HBITMAP bmp;
@@ -44,4 +46,45 @@ public:
void On_btnOk_Click(CCtrlButton*);
void On_edtValue_Change(CCtrlEdit*);
+};
+
+////////////////////////////////// IDD_WALLPOST ///////////////////////////////////////////
+
+struct WALLPOST_FORM_PARAMS
+{
+ TCHAR* ptszMsg;
+ TCHAR* ptszUrl;
+ TCHAR* ptszNick;
+ bool bFriendsOnly;
+
+ WALLPOST_FORM_PARAMS(TCHAR* nick) :
+ ptszNick(nick),
+ bFriendsOnly(false)
+ {
+ ptszMsg = ptszUrl = NULL;
+ }
+
+ ~WALLPOST_FORM_PARAMS()
+ {
+ mir_free(ptszMsg);
+ mir_free(ptszUrl);
+ mir_free(ptszNick);
+ }
+};
+
+class WallPostForm : public CVkDlgBase
+{
+ CCtrlEdit m_edtMsg;
+ CCtrlEdit m_edtUrl;
+ CCtrlCheck m_cbOnlyForFriends;
+ CCtrlButton m_btnShare;
+
+ WALLPOST_FORM_PARAMS* m_param;
+
+public:
+ WallPostForm(CVkProto *proto, WALLPOST_FORM_PARAMS* param);
+ void OnInitDialog();
+ void OnDestroy();
+ void On_btnShare_Click(CCtrlButton*);
+ void On_edtValue_Change(CCtrlEdit*);
}; \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_wallpost.cpp b/protocols/VKontakte/src/vk_wallpost.cpp
index 909d167269..8adf6e2deb 100644
--- a/protocols/VKontakte/src/vk_wallpost.cpp
+++ b/protocols/VKontakte/src/vk_wallpost.cpp
@@ -17,79 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-struct WALLPOST_FORM_PARAMS
-{
- TCHAR* ptszMsg;
- TCHAR* ptszUrl;
- TCHAR* ptszNick;
- bool bFriendsOnly;
-
- WALLPOST_FORM_PARAMS(TCHAR* nick) :
- ptszNick(nick),
- bFriendsOnly(false)
- {
- ptszMsg = ptszUrl = NULL;
- }
-
- ~WALLPOST_FORM_PARAMS()
- {
- mir_free(ptszMsg);
- mir_free(ptszUrl);
- mir_free(ptszNick);
- }
-};
-
-static INT_PTR CALLBACK WallPostFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- WALLPOST_FORM_PARAMS *param = (WALLPOST_FORM_PARAMS *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg) {
- case WM_INITDIALOG:
- param = (WALLPOST_FORM_PARAMS *)lParam;
- TranslateDialogDefault(hwndDlg);
- {
- SetDlgItemText(hwndDlg, IDC_ST_WARNING, _T(""));
- CMString tszTitle(FORMAT, _T("%s %s"), TranslateT("Wall message for"), param->ptszNick);
- SetWindowText(hwndDlg, tszTitle);
- }
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)param);
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDCANCEL:
- EndDialog(hwndDlg, 0);
- return TRUE;
-
- case IDOK:
- TCHAR tszMsg[4096], tszUrl[4096];
- GetDlgItemText(hwndDlg, IDC_ED_MSG, tszMsg, _countof(tszMsg));
- GetDlgItemText(hwndDlg, IDC_ED_URL, tszUrl, _countof(tszUrl));
-
- if (IsEmpty(tszMsg) && IsEmpty(tszUrl)) {
- SetDlgItemText(hwndDlg, IDC_ST_WARNING, TranslateT("Attention! Message body or url should not be empty!"));
- return FALSE;
- }
-
- if (!IsEmpty(tszMsg))
- param->ptszMsg = mir_tstrdup(tszMsg);
- if (!IsEmpty(tszUrl))
- param->ptszUrl = mir_tstrdup(tszUrl);
-
- param->bFriendsOnly = IsDlgButtonChecked(hwndDlg, IDC_ONLY_FRIENDS) == BST_CHECKED;
- EndDialog(hwndDlg, (INT_PTR)param);
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
INT_PTR __cdecl CVkProto::SvcWallPost(WPARAM hContact, LPARAM)
{
debugLogA("CVkProto::SvcWallPost");
WALLPOST_FORM_PARAMS param(db_get_tsa(hContact, m_szModuleName, "Nick"));
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WALLPOST), NULL, WallPostFormDlgProc, (LPARAM)&param) == 0)
+ WallPostForm dlg(this, &param);
+ if (!dlg.DoModal())
return 1;
WallPost((MCONTACT)hContact, param.ptszMsg, param.ptszUrl, param.bFriendsOnly);