summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx/src/ctrl_edit.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-06-08 19:41:14 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-06-08 19:41:14 +0000
commit038f6cc65778c17300ce5c62bb25723f7fa16714 (patch)
tree61b97dfd9eca190a017495f11e0a2c780590f6d3 /plugins/UserInfoEx/src/ctrl_edit.cpp
parent9c4ba307862a3408c67a55bd0c003b6f0f2bdc7d (diff)
UserInfoEx:
- minor warnings fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@14067 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/UserInfoEx/src/ctrl_edit.cpp')
-rw-r--r--plugins/UserInfoEx/src/ctrl_edit.cpp72
1 files changed, 33 insertions, 39 deletions
diff --git a/plugins/UserInfoEx/src/ctrl_edit.cpp b/plugins/UserInfoEx/src/ctrl_edit.cpp
index 3ccc3d6fbf..01d6bb911c 100644
--- a/plugins/UserInfoEx/src/ctrl_edit.cpp
+++ b/plugins/UserInfoEx/src/ctrl_edit.cpp
@@ -289,21 +289,21 @@ void CEditCtrl::OnChangedByUser(WORD wChangedMsg)
void CEditCtrl::OpenUrl()
{
int lenUrl = 1 + Edit_GetTextLength(_hwnd);
- LPSTR szUrl;
+ LPTSTR szUrl;
BYTE need_free = 0;
__try
{
- szUrl = (LPSTR)alloca((8 + lenUrl) * sizeof(CHAR));
+ szUrl = (LPTSTR)alloca((8 + lenUrl) * sizeof(TCHAR));
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
- szUrl = (LPSTR)mir_alloc((8 + lenUrl) * sizeof(CHAR));
+ szUrl = (LPTSTR)mir_alloc((8 + lenUrl) * sizeof(TCHAR));
need_free = 1;
}
- if (szUrl && (GetWindowTextA(_hwnd, szUrl, lenUrl) > 0))
+ if (szUrl && (GetWindowText(_hwnd, szUrl, lenUrl) > 0))
{
- CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)szUrl);
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)szUrl);
}
if (need_free)
{
@@ -313,6 +313,8 @@ void CEditCtrl::OpenUrl()
LRESULT CEditCtrl::LinkNotificationHandler(ENLINK* lnk)
{
+ if (lnk == NULL)
+ return FALSE;
switch (lnk->msg)
{
case WM_SETCURSOR:
@@ -324,46 +326,38 @@ LRESULT CEditCtrl::LinkNotificationHandler(ENLINK* lnk)
case WM_LBUTTONUP:
{
- if (lnk)
+ TEXTRANGE tr;
+ BYTE need_free = 0;
+
+ // do not call function if user selected some chars of the url string
+ SendMessage(_hwnd, EM_EXGETSEL, NULL, (LPARAM) &tr.chrg);
+ if (tr.chrg.cpMax == tr.chrg.cpMin)
{
- TEXTRANGE tr;
- BYTE need_free = 0;
+ // retrieve the url string
+ tr.chrg = lnk->chrg;
- // do not call function if user selected some chars of the url string
- SendMessage(_hwnd, EM_EXGETSEL, NULL, (LPARAM) &tr.chrg);
- if (tr.chrg.cpMax == tr.chrg.cpMin)
+ __try
{
- // retrieve the url string
- tr.chrg = lnk->chrg;
-
- __try
- {
- tr.lpstrText = (LPTSTR)alloca((tr.chrg.cpMax - tr.chrg.cpMin + 8) * sizeof(TCHAR));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
+ tr.lpstrText = (LPTSTR)alloca((tr.chrg.cpMax - tr.chrg.cpMin + 8) * sizeof(TCHAR));
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ tr.lpstrText = (LPTSTR)mir_alloc((tr.chrg.cpMax - tr.chrg.cpMin + 8) * sizeof(TCHAR));
+ need_free = 1;
+ }
+ if (tr.lpstrText && (SendMessage(_hwnd, EM_GETTEXTRANGE, NULL, (LPARAM)&tr) > 0))
+ {
+ if (_tcschr(tr.lpstrText, '@') != NULL && _tcschr(tr.lpstrText, ':') == NULL && _tcschr(tr.lpstrText, '/') == NULL)
{
- tr.lpstrText = (LPTSTR)mir_alloc((tr.chrg.cpMax - tr.chrg.cpMin + 8) * sizeof(TCHAR));
- need_free = 1;
+ memmove(tr.lpstrText + 7, tr.lpstrText, (tr.chrg.cpMax - tr.chrg.cpMin + 1)*sizeof(TCHAR));
+ memcpy(tr.lpstrText, _T("mailto:"), (7*sizeof(TCHAR)));
}
- if (tr.lpstrText && (SendMessage(_hwnd, EM_GETTEXTRANGE, NULL, (LPARAM)&tr) > 0))
- {
- if (_tcschr(tr.lpstrText, '@') != NULL && _tcschr(tr.lpstrText, ':') == NULL && _tcschr(tr.lpstrText, '/') == NULL)
- {
- memmove(tr.lpstrText + (7*sizeof(TCHAR)), tr.lpstrText, (tr.chrg.cpMax - tr.chrg.cpMin + 1)*sizeof(TCHAR));
- memcpy(tr.lpstrText, _T("mailto:"), (7*sizeof(TCHAR)));
- }
- LPSTR pszUrl = mir_t2a(tr.lpstrText);
- if (pszUrl)
- {
- CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)pszUrl);
- mir_free(pszUrl);
- }
- }
- if (need_free)
- {
- MIR_FREE(tr.lpstrText);
- }
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)tr.lpstrText);
+ }
+ if (need_free)
+ {
+ MIR_FREE(tr.lpstrText);
}
}
}