summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SendScreenshotPlus/src')
-rw-r--r--plugins/SendScreenshotPlus/src/Main.cpp6
-rw-r--r--plugins/SendScreenshotPlus/src/Main.h1
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp163
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.h6
-rw-r--r--plugins/SendScreenshotPlus/src/Utils.cpp37
-rw-r--r--plugins/SendScreenshotPlus/src/Utils.h2
-rw-r--r--plugins/SendScreenshotPlus/src/global.h1
7 files changed, 71 insertions, 145 deletions
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp
index 162dbd452d..8a24201943 100644
--- a/plugins/SendScreenshotPlus/src/Main.cpp
+++ b/plugins/SendScreenshotPlus/src/Main.cpp
@@ -85,6 +85,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
* Initializes the services provided and the link to those needed
* Called when the plugin is loaded into Miranda
*/
+ATOM g_clsTargetHighlighter=0;
HANDLE g_hookModulesLoaded=0;
HANDLE g_hookSystemPreShutdown=0;
extern "C" __declspec(dllexport) int Load(void)
@@ -105,7 +106,9 @@ extern "C" __declspec(dllexport) int Load(void)
AddMenuItems();
RegisterServices();
-
+ HBRUSH brush=CreateSolidBrush(0x0000FF00);//owned by class
+ WNDCLASS wndclass={CS_HREDRAW|CS_VREDRAW,DefWindowProc,0,0,hInst,NULL,NULL,brush,NULL,L"SendSSHighlighter"};
+ g_clsTargetHighlighter=RegisterClass(&wndclass);
return 0;
}
@@ -140,6 +143,7 @@ extern "C" __declspec(dllexport) int Unload(void)
UnRegisterServices();
if(g_hookModulesLoaded) UnhookEvent(g_hookModulesLoaded),g_hookModulesLoaded=0;
if(g_hookSystemPreShutdown) UnhookEvent(g_hookSystemPreShutdown),g_hookSystemPreShutdown=0;
+ if(g_clsTargetHighlighter) UnregisterClass((LPTSTR)g_clsTargetHighlighter,hInst),g_clsTargetHighlighter=0;
return 0;
}
diff --git a/plugins/SendScreenshotPlus/src/Main.h b/plugins/SendScreenshotPlus/src/Main.h
index ef61e1af1d..5e18f59bc0 100644
--- a/plugins/SendScreenshotPlus/src/Main.h
+++ b/plugins/SendScreenshotPlus/src/Main.h
@@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//---------------------------------------------------------------------------
+extern ATOM g_clsTargetHighlighter;
extern HANDLE hNetlibUser;
//---------------------------------------------------------------------------
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index 909e5f7c5c..5a1d20a728 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -74,9 +74,6 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureWindow(HWND hDlg, UINT uMsg, WPARAM wP
case WM_COMMAND:
SendMessage(GetParent(hDlg), uMsg, wParam, lParam);
break;
- case WM_MOUSEMOVE:
- SendMessage(GetParent(hDlg), UM_TAB1, uMsg, 0);
- break;
case WM_NOTIFY:
SendMessage(GetParent(hDlg), uMsg, wParam, lParam);
break;
@@ -389,7 +386,11 @@ void TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) {
case ID_chkEditor:
m_opt_chkEditor = (BYTE)Button_GetCheck((HWND)lParam);
break;
-
+
+ case ID_bvlTarget:
+ if(m_opt_tabCapture==0) SetTimer(m_hWnd,ID_bvlTarget,BUTTON_POLLDELAY,NULL);
+ break;
+
case ID_btnAbout:
TfrmMain::btnAboutClick();
break;
@@ -465,60 +466,62 @@ void TfrmMain::wmClose(WPARAM wParam, LPARAM lParam) {
}
//WM_TIMER:
+const int g_iTargetBorder=7;
void TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {// @todo : improve this
- if (wParam == ID_bvlTarget) { // Timer for Target selector
- if (m_hCursor) { //imgTarget is activ
- //LmouseButton = false
- if (!GetLmouse()) {
- TfrmMain::imgTargetMouseUp();
- return;
- }
- //Timer action if LmouseButton = true
- m_hLastWin = m_hTargetWindow;
- POINT point={0};
- GetCursorPos(&point);
- HWND hCurrentWin = WindowFromPoint(point);
- while (GetParent(hCurrentWin)) {
- hCurrentWin = GetParent(hCurrentWin);
- }
- if (m_hLastWin != hCurrentWin) {
- LPTSTR lpTitle = NULL;
- if (m_hLastWin) {
- DrawBorderInverted(m_hLastWin);
- }
- int Count = GetWindowTextLength(hCurrentWin)+1;
- if(Count > 1){
- lpTitle = (LPTSTR)mir_alloc(Count*sizeof(TCHAR));
- GetWindowText(hCurrentWin, lpTitle, Count);
- }
- else {
- //no WindowText present, use WindowClass
- lpTitle = (LPTSTR)mir_alloc(MAX_PATH*sizeof(TCHAR));
- RealGetWindowClass(hCurrentWin, lpTitle, MAX_PATH);
- }
- SetDlgItemText(m_hwndTabPage, ID_edtCaption, lpTitle);
- mir_free(lpTitle);
- edtSizeUpdate(hCurrentWin, m_opt_chkClientArea, m_hwndTabPage, ID_edtSize);
- DrawBorderInverted(hCurrentWin);
- m_hTargetWindow = hCurrentWin;
- }
- return;
+ if (wParam == ID_bvlTarget){// Timer for Target selector
+ static int primarymouse;
+ if(!m_hTargetHighlighter){
+ primarymouse=GetSystemMetrics(SM_SWAPBUTTON)?VK_RBUTTON:VK_LBUTTON;
+ m_hTargetHighlighter=CreateWindowEx(WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW,(LPTSTR)g_clsTargetHighlighter,NULL,WS_POPUP,0,0,0,0,NULL,NULL,hInst,NULL);
+ if(!m_hTargetHighlighter) return;
+ SetLayeredWindowAttributes(m_hTargetHighlighter,0,123,LWA_ALPHA);
+ SetSystemCursor(CopyCursor(IcoLib_GetIcon(ICO_PLUG_SSTARGET)),OCR_NORMAL);
+ Hide();
}
- //imgTarget is not activ (check if cursor is over ID_bvlTarget control)
- RECT rc;
- POINT pt;
- GetWindowRect(GetDlgItem(m_hwndTabPage, wParam),&rc);
- GetCursorPos(&pt);
- //check Mouse cursor
- if(!PtInRect(&rc,pt)) { // mouse must be gone, trigger mouse leave
- //PostMessage(m_hWnd,WM_MOUSELEAVE,wParam,lParam);
- KillTimer(m_hWnd,wParam);
+ if(!(GetAsyncKeyState(primarymouse)&0x8000)){
+ KillTimer(m_hWnd,ID_bvlTarget);
+ SystemParametersInfo(SPI_SETCURSORS,0,NULL,0);
+ DestroyWindow(m_hTargetHighlighter),m_hTargetHighlighter=NULL;
+ Show();
+ return;
}
- else if (GetLmouse() && !m_hCursor) { //mouse hover + LButton
- TfrmMain::imgTargetMouseDown();
+ POINT point; GetCursorPos(&point);
+ m_hTargetWindow=WindowFromPoint(point);
+ if(!((GetAsyncKeyState(VK_SHIFT)|GetAsyncKeyState(VK_MENU))&0x8000))
+ for(HWND hTMP; (hTMP=GetParent(m_hTargetWindow)); m_hTargetWindow=hTMP);
+ if(m_hTargetWindow!=m_hLastWin){
+ m_hLastWin=m_hTargetWindow;
+ RECT rect; GetWindowRect(m_hLastWin,&rect);
+ int width=rect.right-rect.left;
+ int height=rect.bottom-rect.top;
+ if(g_iTargetBorder){
+ SetWindowPos(m_hTargetHighlighter,NULL,0,0,0,0,SWP_HIDEWINDOW|SWP_NOMOVE|SWP_NOSIZE);
+ /// @todo (White-Tiger#1#): inform WindowDetective about improvements / leaks (he uses 3 HRGN and doesn't delete 2 unneeded, HighlightWindow)
+ if(width>g_iTargetBorder*2 && height>g_iTargetBorder*2) {
+ HRGN hRegnNew=CreateRectRgn(0,0,width,height);
+ HRGN hRgnHole=CreateRectRgn(g_iTargetBorder,g_iTargetBorder,width-g_iTargetBorder,height-g_iTargetBorder);
+ CombineRgn(hRegnNew,hRegnNew,hRgnHole,RGN_XOR);
+ DeleteObject(hRgnHole);
+ SetWindowRgn(m_hTargetHighlighter,hRegnNew,FALSE);//cleans up hRegnNew
+ }else SetWindowRgn(m_hTargetHighlighter,NULL,FALSE);
+ }
+ SetWindowPos(m_hTargetHighlighter,HWND_TOPMOST,rect.left,rect.top,width,height,SWP_SHOWWINDOW|SWP_NOACTIVATE);
+ width=GetWindowTextLength(m_hTargetWindow)+1;
+ LPTSTR lpTitle;
+ if(width>1){
+ lpTitle=(LPTSTR)mir_alloc(width*sizeof(TCHAR));
+ GetWindowText(m_hTargetWindow,lpTitle,width);
+ }else{//no WindowText present, use WindowClass
+ lpTitle=(LPTSTR)mir_alloc(64*sizeof(TCHAR));
+ RealGetWindowClass(m_hTargetWindow,lpTitle,64);
+ }
+ SetDlgItemText(m_hwndTabPage,ID_edtCaption,lpTitle);
+ mir_free(lpTitle);
+ edtSizeUpdate(m_hTargetWindow,m_opt_chkClientArea,m_hwndTabPage,ID_edtSize);
}
+ return;
}
- if (wParam == ID_chkTimed) { // Timer for Screenshot
+ if (wParam == ID_chkTimed){// Timer for Screenshot
#ifdef _DEBUG
OutputDebugStringA("SS Bitmap Timer Start\r\n" );
#endif
@@ -610,21 +613,6 @@ void TfrmMain::UMClosing(WPARAM wParam, LPARAM lParam) {
}
}
-//UM_TAB1:
-LRESULT TfrmMain::UMTab1(WPARAM wParam, LPARAM lParam) {
- switch (wParam) {
- case WM_MOUSEMOVE:
- if (m_opt_tabCapture == 0) {
- // Call timer, used to start cheesy TrackMouseEvent faker
- SetTimer(m_hWnd,ID_bvlTarget,BUTTON_POLLDELAY,NULL);
- }
- break;
- default:
- break;
- }
- return FALSE;
-}
-
//UM_EVENT:
void TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) {
//HWND hWnd = (HWND)wParam;
@@ -685,7 +673,7 @@ TfrmMain::TfrmMain() {
m_hContact = NULL;
m_bDeleteAfterSend=m_bFormAbout=m_bFormEdit=false;
m_hTargetWindow =m_hLastWin=NULL;
- m_hCursor = NULL;
+ m_hTargetHighlighter=NULL;
m_FDestFolder =m_pszFile=m_pszFileDesc=NULL;
m_Screenshot = NULL;
/* m_AlphaColor */
@@ -707,6 +695,10 @@ TfrmMain::~TfrmMain() {
mir_free(m_Monitors);
if (m_Screenshot) FIP->FI_Unload(m_Screenshot);
if (m_cSend) delete m_cSend;
+ if(m_hTargetHighlighter){
+ DestroyWindow(m_hTargetHighlighter),m_hTargetHighlighter=NULL;
+ SystemParametersInfo(SPI_SETCURSORS,0,NULL,0);
+ }
}
//---------------------------------------------------------------------------
@@ -812,33 +804,6 @@ void TfrmMain::chkTimedClick() {
}
//---------------------------------------------------------------------------
-void TfrmMain::imgTargetMouseDown() {
- //if (Button != mbLeft) return;
- m_hCursor = CopyCursor(GetCursor()); //backup cursor
- //SetSystemCursor need a copy coz it destroy the handle
- SetSystemCursor(CopyCursor(IcoLib_GetIcon(ICO_PLUG_SSTARGET)),OCR_NORMAL);
- m_bSelectingWindow = true;
- m_hTargetWindow = NULL;
- Hide();
- SetCapture(m_hWnd);
-}
-
-//---------------------------------------------------------------------------
-void TfrmMain::imgTargetMouseUp() {
- //if (Button == mbLeft && m_bSelectingWindow && TimerCheckFocus->Enabled)
- if (m_bSelectingWindow && m_hCursor) {
- Show();
- ReleaseCapture();
- SetSystemCursor(m_hCursor, OCR_NORMAL);
- m_hCursor = NULL;
- if (m_hTargetWindow){
- DrawBorderInverted(m_hTargetWindow);
- }
- m_bSelectingWindow = false;
- }
-}
-
-//---------------------------------------------------------------------------
void TfrmMain::cboxSendByChange() {
BOOL bState;
HICON hIcon;
@@ -1102,10 +1067,8 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
}
if(m_cSend) {
- mir_freeAndNil(m_cSend->m_pszFile);
- mir_freeAndNil(m_cSend->m_pszFileDesc);
- m_cSend->m_pszFile = mir_tstrdup(m_pszFile);
- m_cSend->m_pszFileDesc = mir_tstrdup(m_pszFileDesc);
+ mir_freeAndNil(m_cSend->m_pszFile); m_cSend->m_pszFile=mir_tstrdup(m_pszFile);
+ mir_freeAndNil(m_cSend->m_pszFileDesc); m_cSend->m_pszFileDesc=mir_tstrdup(m_pszFileDesc);
}
mir_free(ret);
return 0; //OK
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.h b/plugins/SendScreenshotPlus/src/UMainForm.h
index 9ad0a146e7..06c513708a 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.h
+++ b/plugins/SendScreenshotPlus/src/UMainForm.h
@@ -78,19 +78,18 @@ class TfrmMain{
private:
HWND m_hWnd;
HANDLE m_hContact;
- bool m_bSelectingWindow, m_bDeleteAfterSend;
+ bool m_bDeleteAfterSend;
bool m_bFormAbout, m_bFormEdit;
HWND m_hTargetWindow, m_hLastWin;
+ HWND m_hTargetHighlighter;
LPTSTR m_FDestFolder;
LPTSTR m_pszFile;
LPTSTR m_pszFileDesc;
FIBITMAP* m_Screenshot;//Graphics::TBitmap *Screenshot;
RGBQUAD m_AlphaColor;
- HCURSOR m_hCursor;
CSend* m_cSend;
void chkTimedClick();
- void imgTargetMouseDown();
void imgTargetMouseUp();
void btnAboutClick();
void btnAboutOnCloseWindow(HWND hWnd);
@@ -130,7 +129,6 @@ class TfrmMain{
void UMevent(WPARAM wParam, LPARAM lParam);
void UMClosing(WPARAM wParam, LPARAM lParam);
- LRESULT UMTab1(WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK DlgProc_CaptureWindow (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK DlgProc_CaptureDesktop(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/SendScreenshotPlus/src/Utils.cpp b/plugins/SendScreenshotPlus/src/Utils.cpp
index f6daf450d5..f9e10251c8 100644
--- a/plugins/SendScreenshotPlus/src/Utils.cpp
+++ b/plugins/SendScreenshotPlus/src/Utils.cpp
@@ -326,43 +326,6 @@ LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTST
}
//---------------------------------------------------------------------------
-//Draws a selection border on the window under cursor
-void DrawBorderInverted(HWND hWindow) {
- if (!hWindow){
- return;
- }
- HDC hDC=GetWindowDC(hWindow);
- RECT rect={0};
- GetWindowRect(hWindow, &rect);
-
- int dcSave = SaveDC(hDC);
-
- SetROP2(hDC, R2_NOT);
-
- HPEN hPen=0;
- hPen = CreatePen(PS_SOLID, 10, RGB(0, 0, 0));
-
- SelectObject(hDC, &hPen);
- SelectObject(hDC, GetStockObject(NULL_BRUSH));
-
- Rectangle(hDC, 0, 0, rect.right-rect.left, rect.bottom-rect.top);
- Rectangle(hDC, 1, 1, rect.right-rect.left-1, rect.bottom-rect.top-1);
- Rectangle(hDC, 2, 2, rect.right-rect.left-2, rect.bottom-rect.top-2);
-
- RestoreDC(hDC, dcSave);
-}
-
-//---------------------------------------------------------------------------
-//is left mouse button down
-BOOL GetLmouse() {
- SHORT temp = GetAsyncKeyState((GetSystemMetrics(SM_SWAPBUTTON)) ? VK_RBUTTON : VK_LBUTTON);
- if ((temp & 0x8000) == 0x8000) { // LBUTTON down
- return TRUE;
- }
- return FALSE;
-}
-
-//---------------------------------------------------------------------------
INT_PTR GetFileName(LPTSTR pszPath, UINT typ) {
/*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/
LPTSTR slash = _tcsrchr(pszPath,_T('\\'));
diff --git a/plugins/SendScreenshotPlus/src/Utils.h b/plugins/SendScreenshotPlus/src/Utils.h
index da9e13eff3..70704eb78a 100644
--- a/plugins/SendScreenshotPlus/src/Utils.h
+++ b/plugins/SendScreenshotPlus/src/Utils.h
@@ -53,8 +53,6 @@ FIBITMAP* CaptureScreen(HDC hDC, SIZE size, HWND hCapture=0);
//FIBITMAP* CaptureDesktop(); /*emulate print screen (not used)*/
LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag=0);
-void DrawBorderInverted(HWND hWindow);
-BOOL GetLmouse();
INT_PTR GetFileName(LPTSTR pszPath, UINT typ);
INT_PTR GetFileExt (LPTSTR pszPath, UINT typ);
diff --git a/plugins/SendScreenshotPlus/src/global.h b/plugins/SendScreenshotPlus/src/global.h
index 5cceba5f3d..b1c63cbc1b 100644
--- a/plugins/SendScreenshotPlus/src/global.h
+++ b/plugins/SendScreenshotPlus/src/global.h
@@ -94,7 +94,6 @@ using namespace std;
#define UM_CLOSING WM_USER+1
#define UM_EVENT WM_USER+2
-#define UM_TAB1 WM_USER+11
// Generic Message Box for Errors
#define MSGERROR(text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONERROR)