summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2013-11-05 17:59:29 +0000
committerRené Schümann <white06tiger@gmail.com>2013-11-05 17:59:29 +0000
commitf6f7445b5887ce9f3a7464cd95abc7e649daa292 (patch)
tree8c2e79eab6d79b733dd7cfa23964d527f0aa7562 /plugins/SendScreenshotPlus
parent4d110f6db480ccb999e2089aff73a85e6e349ab5 (diff)
ooops...
- removed slipped through todo's / comments ! fixed bug I introduced (file numbering...) also fixed a case were file-number exceeds "maximum" of 99999 (5 chars) * changed default output format to "png" instead of "tif" (why tif? it can't even be used by everyone...) ! fixed "maybe" uninitialized variable ! fixed memory leak ! fixed freeing a pointer thats still used (man this code's ugly..) git-svn-id: http://svn.miranda-ng.org/main/trunk@6791 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus')
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp37
-rw-r--r--plugins/SendScreenshotPlus/src/Utils.cpp2
2 files changed, 18 insertions, 21 deletions
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index 5a1d20a728..ca25f6b163 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -398,7 +398,7 @@ void TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) {
TfrmMain::btnExploreClick();
break;
case ID_btnDesc:{
- m_opt_btnDesc = (m_opt_btnDesc == 0);
+ m_opt_btnDesc=!m_opt_btnDesc;
HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF);
SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
break;}
@@ -467,7 +467,7 @@ void TfrmMain::wmClose(WPARAM wParam, LPARAM lParam) {
//WM_TIMER:
const int g_iTargetBorder=7;
-void TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {// @todo : improve this
+void TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam){
if (wParam == ID_bvlTarget){// Timer for Target selector
static int primarymouse;
if(!m_hTargetHighlighter){
@@ -496,7 +496,6 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {// @todo : improve this
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);
@@ -719,7 +718,7 @@ void TfrmMain::LoadOptions(void) {
m_opt_chkTimed = db_get_b(NULL, SZ_SENDSS, "TimedCap", 0);
m_opt_edtTimed = db_get_b(NULL, SZ_SENDSS, "CapTime", 3);
- m_opt_cboxFormat = db_get_b(NULL, SZ_SENDSS, "OutputFormat", 3);
+ m_opt_cboxFormat = db_get_b(NULL, SZ_SENDSS, "OutputFormat", 0);
m_opt_cboxSendBy = db_get_b(NULL, SZ_SENDSS, "SendBy", 0);
m_opt_chkEditor = db_get_b(NULL, SZ_SENDSS, "Preview", 0);
@@ -913,16 +912,15 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
LPTSTR pszFilename = NULL;
LPTSTR pszFileDesc = NULL;
if (!dib) return 1; //error
-
+ unsigned FileNumber=db_get_dw(NULL,SZ_SENDSS,"FileNumber",0)+1;
+ if(FileNumber>99999) FileNumber=1;
//Generate FileName
mir_tcsadd(path, m_FDestFolder);
if (path[_tcslen(path)-1] != _T('\\')) mir_tcsadd(path, _T("\\"));
- mir_tcsadd(path, _T("shot%.5u"));
- unsigned FileNumber=db_get_dw(NULL, SZ_SENDSS, "FileNumber", 0) + 1;
- // '00000'-'%.5ld'=0 (add more or less len if differ from 5
- size_t len = (_tcslen(path)+0+1);
+ mir_tcsadd(path, _T("shot%.5u"));//on format change, adapt "len" below
+ size_t len=_tcslen(path)+2;
pszFilename = (LPTSTR)mir_alloc(sizeof(TCHAR)*(len));
- mir_sntprintf(pszFilename, len, path, FileNumber);
+ mir_sntprintf(pszFilename,len,path,FileNumber);
mir_free(path);
//Generate a description according to the screenshot
@@ -1030,7 +1028,7 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
break;
default:
- break;
+ ret=NULL;
}
/* //load PNG and save file in user format (if differ)
//this get better result for transparent aereas
@@ -1055,14 +1053,14 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
FIP->FI_Unload(dib_new);
mir_freeAndNil(pszFilename);
- if (ret) {
- db_set_dw(NULL, SZ_SENDSS, "FileNumber", FileNumber);
- mir_freeAndNil(m_pszFile);
+ if(ret){
+ db_set_dw(NULL,SZ_SENDSS,"FileNumber",FileNumber);
+ mir_freeAndNil(m_pszFile); m_pszFile=ret;
mir_freeAndNil(m_pszFileDesc);
- m_pszFile = ret;
- if (IsWindowEnabled(GetDlgItem(m_hWnd, ID_btnDesc)) && m_opt_btnDesc) {
- m_pszFileDesc = pszFileDesc;
+ if(IsWindowEnabled(GetDlgItem(m_hWnd,ID_btnDesc)) && m_opt_btnDesc){
+ m_pszFileDesc=pszFileDesc;
}else{
+ mir_free(pszFileDesc);
mir_tcsadd(m_pszFileDesc, _T(""));
}
@@ -1070,11 +1068,10 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
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
+ return 0;//OK
}
mir_free(pszFileDesc);
- return 1; //error
+ return 1;//error
}
//---------------------------------------------------------------------------
diff --git a/plugins/SendScreenshotPlus/src/Utils.cpp b/plugins/SendScreenshotPlus/src/Utils.cpp
index f9e10251c8..de98ff1e6a 100644
--- a/plugins/SendScreenshotPlus/src/Utils.cpp
+++ b/plugins/SendScreenshotPlus/src/Utils.cpp
@@ -261,7 +261,7 @@ FIBITMAP* CaptureScreen (HDC hDC,SIZE size,HWND hCapture){
break;
}
BOOL inf = FIP->FI_IsTransparent(dib);
- OutputDebugStringA(inf ? "FIBITMAP Transparent: true\r\n" : "FIBITMAP Transparent: fase\r\n");
+ OutputDebugStringA(inf ? "FIBITMAP Transparent: true\r\n" : "FIBITMAP Transparent: false\r\n");
#endif
return dib;