Пример #1
0
//---------------------------------------------------------------------------
int CSendHTTPServer::Send()
{
	if (!m_hContact) return 1;
	if (CallService(MS_HTTP_ACCEPT_CONNECTIONS, TRUE, 0) != 0) {
		Error(LPGENT("Could not start the HTTP Server plugin."));
		Exit(ACKRESULT_FAILED);
		return !m_bAsync;
	}

	if (!m_pszFileName) {
		m_pszFileName = GetFileNameA(m_pszFile);
	}
	mir_freeAndNil(m_fsi_pszSrvPath);
	mir_stradd(m_fsi_pszSrvPath, "/");
	mir_stradd(m_fsi_pszSrvPath, m_pszFileName);

	replaceStr(m_fsi_pszRealPath, _T2A(m_pszFile));

	memset(&m_fsi, 0, sizeof(m_fsi));
	m_fsi.lStructSize = sizeof(STFileShareInfo);
	m_fsi.pszSrvPath = m_fsi_pszSrvPath;
	m_fsi.nMaxDownloads = -1;					// -1 = infinite
	m_fsi.pszRealPath = m_fsi_pszRealPath;

	//start Send thread
	mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this);
	return 0;
}
Пример #2
0
//---------------------------------------------------------------------------
void CSendImageShack::MFDR_Reset() {
	char	Temp[64];
	DWORD	dwBoundaryRand1 = GetTickCount();
	DWORD	dwBoundaryRand2 = rand();

	mir_freeAndNil(m_MFDRboundary);
	mir_snprintf(Temp, SIZEOF(Temp), "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2);
	mir_stradd(m_MFDRboundary,Temp);
}
Пример #3
0
void CSendImageShack::SendThread() {
	//send DATA and wait for m_nlreply
	m_nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) &m_nlhr);
	mir_freeAndNil(m_nlhr.pData);
	mir_freeAndNil(m_nlhr.headers);
	if(m_nlreply){
		if( m_nlreply->resultCode >= 200 && m_nlreply->resultCode < 300 ){
			m_nlreply->pData[m_nlreply->dataLength] = 0;// make sure its null terminated
			const char* URL = NULL;
			URL = GetTagContent(m_nlreply->pData, "<image_link>", "</image_link>");
			if (URL && URL[0]!= NULL) {
				m_Url = mir_strdup(URL);
				if(m_SendSync) {
					Exit(ACKRESULT_SUCCESS);
					return;
				}
				m_ChatRoom ? svcSendChat(URL) : svcSendMsg(URL);
				return;
			}else{//check error mess from server
				LPTSTR err = mir_a2t(GetTagContent(m_nlreply->pData, "<error ", "</error>"));
				if (!err || !*err){//fallback to server response mess
					mir_freeAndNil(err);
					err = mir_a2t(m_nlreply->pData);
				}
				Error(NULL, err);
				mir_free(err);
			}
		}
		else {
				Error(NULL, TranslateT("Upload server did not respond timely."));
		}
		CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply);
		m_nlreply = NULL;
	}
	else {
		Error(SS_ERR_INIT, m_pszSendTyp);
	}
	Exit(ACKRESULT_FAILED);
}
Пример #4
0
void CSend::svcSendFileExit()
{
	//szMessage should be encoded as the File followed by the description, the
	//separator being a single nul (\0). If there is no description, do not forget
	//to end the File with two nuls.
	if (m_bSilent) {
		Exit(ACKRESULT_SUCCESS); return;
	}
	if (!m_hContact) {
		Error(LPGENT("%s requires a valid contact!"), m_pszSendTyp);
		Exit(ACKRESULT_FAILED); return;
	}
	mir_freeAndNil(m_szEventMsg);
	char* szFile = mir_t2a(m_pszFile);
	m_cbEventMsg = (DWORD)mir_strlen(szFile) + 2;
	m_szEventMsg = (char*)mir_realloc(m_szEventMsg, (sizeof(char) * m_cbEventMsg));
	memset(m_szEventMsg, 0, (sizeof(char) * m_cbEventMsg));
	mir_strcpy(m_szEventMsg, szFile);
	if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
		char* temp = mir_t2a(m_pszFileDesc);
		m_cbEventMsg += (DWORD)mir_strlen(temp);
		m_szEventMsg = (char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
		mir_strcpy(m_szEventMsg + mir_strlen(szFile) + 1, temp);
		m_szEventMsg[m_cbEventMsg - 1] = 0;
		mir_free(temp);
	}
	mir_free(szFile);

	//create a HookEventObj on ME_PROTO_ACK
	if (!m_hOnSend) {
		m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this);
	}

	// Start miranda PSS_FILE based on mir ver (T)
	TCHAR* ppFile[2] = { 0, 0 };
	TCHAR* pDesc = mir_tstrdup(m_pszFileDesc);
	ppFile[0] = mir_tstrdup(m_pszFile);
	ppFile[1] = NULL;
	m_hSend = (HANDLE)CallContactService(m_hContact, PSS_FILE, (WPARAM)pDesc, (LPARAM)ppFile);
	mir_free(pDesc);
	mir_free(ppFile[0]);

	// check we actually got an ft handle back from the protocol
	if (!m_hSend) {
		Unhook();
		Error(SS_ERR_INIT, m_pszSendTyp);
		Exit(ACKRESULT_FAILED); return;
	}
}
Пример #5
0
void CSendFTPFile::SendThread() {
	mir_freeAndNil(m_URL);

	INT_PTR ret = FTPFileUploadA(m_hContact, FNUM_DEFAULT, FMODE_RAWFILE, &m_pszFileName,1);
	if (ret != 0) {
		Error(TranslateT("%s (%i):\nCould not add a share to the FTP File plugin."),TranslateTS(m_pszSendTyp),ret);
		Exit(ret);
	}

	//Can't delete the file since FTP File plugin will use it
	m_bDeleteAfterSend = false;

	if (m_URL && m_URL[0]!= NULL) {
		m_ChatRoom ? svcSendChat(m_URL) : svcSendMsg(m_URL);
	}
}
Пример #6
0
void CSendImageShack::GetContentType() {
	if (m_pszContentType) mir_freeAndNil(m_pszContentType);
	LPSTR FileExtension = (LPSTR)GetFileExt(m_pszFile, DBVT_ASCIIZ);

	if ((strcmp(FileExtension, ".jpeg")==0) || (strcmp(FileExtension, ".jpe")==0) || (strcmp(FileExtension ,".jpg")==0))
		m_pszContentType="image/jpeg";
	else if (strcmp(FileExtension, ".bmp")==0)
		m_pszContentType="image/bmp";
	else if (strcmp(FileExtension, ".png")==0)
		m_pszContentType="image/png";
	else if (strcmp(FileExtension, ".gif")==0)
		m_pszContentType="image/gif";
	else if ((strcmp(FileExtension, ".tif")==0) || (strcmp(FileExtension, ".tiff")==0))
		m_pszContentType="image/tiff";
	else
		m_pszContentType="application/octet-stream";

	mir_free(FileExtension);
	return;
}
Пример #7
0
//---------------------------------------------------------------------------
void	CSendFTPFile::Send() {

	/*********************************************************************************************
	 * Send file (files) to the FTP server and copy file URL
	 * to message log or clipboard (according to plugin setting)
	 *   wParam = (HANDLE)hContact
	 *   lParam = (char *)filename
	 * Filename format is same as GetOpenFileName (OPENFILENAME.lpstrFile) returns,
	 * see http://msdn2.microsoft.com/en-us/library/ms646839.aspx
	 * Returns 0 on success or nonzero on failure
	 * if (!wParam || !lParam) return 1
	 ********************************************************************************************/
	mir_freeAndNil(m_pszFileName);
	m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ);
	size_t size = sizeof(char)*(strlen(m_pszFileName)+2);
	m_pszFileName = (LPSTR) mir_realloc(m_pszFileName, size);
	m_pszFileName[size-1] = NULL;

	//start Send thread
	m_bFreeOnExit = TRUE;
	mir_forkthread(&CSendFTPFile::SendThreadWrapper, this);
}
Пример #8
0
void CSend::svcSendMsgExit(const char* szMessage)
{
	if (m_bSilent) {
		Exit(ACKRESULT_SUCCESS); return;
	}
	if (!m_hContact) {
		if (!m_pszFileDesc)
			m_pszFileDesc = mir_a2t(szMessage);
		Exit(CSEND_DIALOG); return;
	}
	if (m_ChatRoom) {
		TCHAR* tmp = mir_a2t(szMessage);
		if (m_pszFileDesc) {
			mir_tstradd(tmp, _T("\r\n"));
			mir_tstradd(tmp, m_pszFileDesc);
		}
		GC_INFO gci = { 0 };
		int res = GC_RESULT_NOSESSION;
		int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_pszProto);

		//loop on all gc session to get the right (save) ptszID for the chatroom from m_hContact
		gci.pszModule = m_pszProto;
		for (int i = 0; i < cnt; i++) {
			gci.iItem = i;
			gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
			CallService(MS_GC_GETINFO, 0, (LPARAM)&gci);
			if (gci.hContact == m_hContact) {
				GCDEST gcd = { m_pszProto, gci.pszID, GC_EVENT_SENDMESSAGE };
				GCEVENT gce = { sizeof(gce), &gcd };
				gce.bIsMe = TRUE;
				gce.dwFlags = GCEF_ADDTOLOG;
				gce.ptszText = tmp;
				gce.time = time(NULL);

				//* returns 0 on success or error code on failure
				res = 200 + (int)CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
				break;
			}
		}
		Exit(res); return;
	}
	else {
		mir_freeAndNil(m_szEventMsg);
		m_cbEventMsg = (DWORD)mir_strlen(szMessage) + 1;
		m_szEventMsg = (char*)mir_realloc(m_szEventMsg, (sizeof(char) * m_cbEventMsg));
		memset(m_szEventMsg, 0, (sizeof(char) * m_cbEventMsg));
		mir_strcpy(m_szEventMsg, szMessage);
		if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
			char *temp = mir_t2a(m_pszFileDesc);
			mir_stradd(m_szEventMsg, "\r\n");
			mir_stradd(m_szEventMsg, temp);
			m_cbEventMsg = (DWORD)mir_strlen(m_szEventMsg) + 1;
			mir_free(temp);
		}
		//create a HookEventObj on ME_PROTO_ACK
		if (!m_hOnSend) {
			m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this);
		}
		//start PSS_MESSAGE service
		m_hSend = (HANDLE)CallContactService(m_hContact, PSS_MESSAGE, NULL, ptrA(mir_utf8encode(m_szEventMsg)));
		// check we actually got an ft handle back from the protocol
		if (!m_hSend) {
			Unhook();
			Error(SS_ERR_INIT, m_pszSendTyp);
			Exit(ACKRESULT_FAILED); return;
		}
	}
}
Пример #9
0
//---------------------------------------------------------------------------
INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
    //generate File name
    FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
    LPTSTR ret;
    LPTSTR path = NULL;
    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"));//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_free(path);

    //Generate a description according to the screenshot
    TCHAR winText[1024];
    mir_tcsadd(pszFileDesc, TranslateT("Screenshot "));
    if (m_opt_tabCapture == 0 && m_opt_chkClientArea) {
        mir_tcsadd(pszFileDesc, TranslateT("for Client area "));
    }
    mir_tcsadd(pszFileDesc, TranslateT("of \""));
    GetDlgItemText(m_hwndTabPage, ID_edtCaption, winText, 1024);
    mir_tcsadd(pszFileDesc, winText);
    if(m_opt_tabCapture==1)
        mir_tcsadd(pszFileDesc, _T("\""));
    else
        mir_tcsadd(pszFileDesc, TranslateT("\" Window"));

    // convert to 32Bits (make shure it is 32bit)
    FIBITMAP *dib_new = FIP->FI_ConvertTo32Bits(dib);
    //RGBQUAD appColor = { 245, 0, 254, 0 };	//bgr0	schwarz
    //FIP->FI_SetBackgroundColor(dib_new, &appColor);
    FIP->FI_SetTransparent(dib_new,TRUE);

    // Investigates the color type of the bitmap (test for RGB or CMYK colour space)
    switch (FREE_IMAGE_COLOR_TYPE ColTye=FIP->FI_GetColorType(dib_new)) {
    case FIC_MINISBLACK:
    //Monochrome bitmap (1-bit) : first palette entry is black.
    //Palletised bitmap (4 or 8-bit) and single channel non standard bitmap: the bitmap has a greyscale palette
    case FIC_MINISWHITE:
    //Monochrome bitmap (1-bit) : first palette entry is white.
    //Palletised bitmap (4 or 8-bit) : the bitmap has an inverted greyscale palette
    case FIC_PALETTE:
    //Palettized bitmap (1, 4 or 8 bit)
    case FIC_RGB:
    //High-color bitmap (16, 24 or 32 bit), RGB16 or RGBF
    case FIC_RGBALPHA:
    //High-color bitmap with an alpha channel (32 bit bitmap, RGBA16 or RGBAF)
    case FIC_CMYK:
    //CMYK bitmap (32 bit only)
    default:
        break;
    }

//	bool bDummy = !(FIP->FI_GetICCProfile(dib_new)->flags & FIICC_COLOR_IS_CMYK);

    FIBITMAP *dib32,*dib24;
    HWND hwndCombo = GetDlgItem(m_hWnd, ID_cboxFormat);
    switch (ComboBox_GetItemData(hwndCombo, ComboBox_GetCurSel(hwndCombo))) {
    case 0: //PNG
        ret = SaveImage(fif,dib_new, pszFilename, _T("png"));
        break;

    case 1: //JPG
        /*
        #define JPEG_QUALITYSUPERB  0x80	// save with superb quality (100:1)
        #define JPEG_QUALITYGOOD    0x0100	// save with good quality (75:1)
        #define JPEG_QUALITYNORMAL  0x0200	// save with normal quality (50:1)
        #define JPEG_QUALITYAVERAGE 0x0400	// save with average quality (25:1)
        #define JPEG_QUALITYBAD     0x0800	// save with bad quality (10:1)
        #define JPEG_PROGRESSIVE	0x2000	// save as a progressive-JPEG (use | to combine with other save flags)
        */
        dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL);
        dib24 = FIP->FI_ConvertTo24Bits(dib32);
        FIP->FI_Unload(dib32);
        ret = SaveImage(fif,dib24, pszFilename, _T("jpg"));
        FIP->FI_Unload(dib24);
        break;

    case 2: //BMP
        //	ret = SaveImage(FIF_BMP,dib_new, pszFilename, _T("bmp")); //32bit alpha BMP
        dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL);
        dib24 = FIP->FI_ConvertTo24Bits(dib32);
        FIP->FI_Unload(dib32);
        ret = SaveImage(FIF_BMP,dib24, pszFilename, _T("bmp"));
        FIP->FI_Unload(dib24);
        break;

    case 3: //TIFF (miranda freeimage interface do not support save tiff, we udse GDI+)
    {
        LPTSTR pszFile = NULL;
        mir_tcsadd(pszFile, pszFilename);
        mir_tcsadd(pszFile, _T(".tif"));

        dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL);
        dib24 = FIP->FI_ConvertTo24Bits(dib32);
        FIP->FI_Unload(dib32);

        HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib24);
        FIP->FI_Unload(dib24);
        SaveTIF(hBmp, pszFile);
        ret=pszFile;
        DeleteObject(hBmp);
    }
    break;

    case 4: //GIF
    {
        //dib24 = FIP->FI_ConvertTo8Bits(dib_new);
        //ret = SaveImage(FIF_GIF,dib24, pszFilename, _T("gif"));
        //FIP->FI_Unload(dib24);
        LPTSTR pszFile = NULL;
        mir_tcsadd(pszFile, pszFilename);
        mir_tcsadd(pszFile, _T(".gif"));
        HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib_new);
        SaveGIF(hBmp, pszFile);
        ret=pszFile;
        DeleteObject(hBmp);
    }
    break;

    default:
        ret=NULL;
    }
    /*	//load PNG and save file in user format (if differ)
    	//this get better result for transparent aereas
    	//LPTSTR pszFormat = (LPTSTR)ComboBox_GetItemData(hwndCombo, ComboBox_GetCurSel(hwndCombo));
    	TCHAR pszFormat[6];
    	ComboBox_GetText(hwndCombo, pszFormat, 6);
    	if(ret && (_tcsicmp (pszFormat,_T("png")) != 0)) {

    			fif = FIP->FI_GetFIFFromFilenameU(ret);
    			dib_new = FIP->FI_LoadU(fif, ret,0);


    		if(dib_new) {
    			DeleteFile(ret);
    			mir_freeAndNil(ret);
    			FIBITMAP *dib_save = FIP->FI_ConvertTo24Bits(dib_new);
    			ret = SaveImage(FIF_UNKNOWN,dib_save, pszFilename, pszFormat);
    			FIP->FI_Unload(dib_new); dib_new = NULL;
    			FIP->FI_Unload(dib_save); dib_save = NULL;
    		}
    	}*/
    FIP->FI_Unload(dib_new);
    mir_freeAndNil(pszFilename);

    if(ret) {
        db_set_dw(NULL,SZ_SENDSS,"FileNumber",FileNumber);
        mir_freeAndNil(m_pszFile);
        m_pszFile=ret;
        mir_freeAndNil(m_pszFileDesc);
        if(IsWindowEnabled(GetDlgItem(m_hWnd,ID_btnDesc)) && m_opt_btnDesc) {
            m_pszFileDesc=pszFileDesc;
        } else {
            mir_free(pszFileDesc);
            mir_tcsadd(m_pszFileDesc, _T(""));
        }

        if(m_cSend) {
            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);
        }
        return 0;//OK
    }
    mir_free(pszFileDesc);
    return 1;//error
}
Пример #10
0
//---------------------------------------------------------------------------
//WM_INITDIALOG:
void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) {
    HWND hCtrl;
    //Taskbar and Window icon
    SendMessage(m_hWnd, WM_SETICON, ICON_BIG,	(LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true));
    SendMessage(m_hWnd, WM_SETICON, ICON_SMALL,	(LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2));
    LPTSTR pt = mir_a2t(__PLUGIN_NAME);
    SetWindowText(m_hWnd, pt);
    mir_freeAndNil(pt);

    // Headerbar
    pt = mir_tstrdup((LPTSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)m_hContact, (LPARAM)GCDNF_TCHAR));
    if (pt && (m_hContact != 0)) {
        LPTSTR lptString = NULL;
        mir_tcsadd(lptString , TranslateT("Send screenshot to\n"));
        mir_tcsadd(lptString , pt);
        SetDlgItemText(m_hWnd, IDC_HEADERBAR, lptString);
        mir_free(lptString);
    }
    mir_freeAndNil(pt);

    SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true));

    //Timed controls
    CheckDlgButton(m_hWnd,ID_chkTimed,				m_opt_chkTimed ? BST_CHECKED : BST_UNCHECKED);
    SetDlgItemInt (m_hWnd,ID_edtTimed,				(UINT)m_opt_edtTimed, FALSE);
    SendDlgItemMessage(m_hWnd, ID_upTimed,			UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, 1));
    chkTimedClick();		//enable disable Timed controls

    //create Image list for tab control
    if(m_himlTab == 0) {
        //m_himlTab = ImageList_Create(16, 16, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 2, 0);
        m_himlTab = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0);
        ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2));
        ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2));
    }

    //create the tab control.
    {
        TAB_INFO itab;
        RECT rcClient, rcTab;
        m_hwndTab = GetDlgItem(m_hWnd, IDC_CAPTURETAB);
        TabCtrl_SetItemExtra(m_hwndTab, sizeof(TAB_INFO) - sizeof(TCITEMHEADER));

        ZeroMemory(&itab, sizeof(itab));
        itab.hwndMain	= m_hWnd;
        itab.hwndTab	= m_hwndTab;

        GetWindowRect(m_hwndTab, &rcTab);
        GetWindowRect(m_hWnd, &rcClient);

        TabCtrl_SetImageList(m_hwndTab, m_himlTab);

        // Add a tab for each of the three child dialog boxes.
        itab.tcih.mask		= TCIF_PARAM|TCIF_TEXT|TCIF_IMAGE;

        itab.tcih.pszText	= TranslateT("Window");
        itab.tcih.iImage	= 0;
        itab.hwndTabPage	= CreateDialog(hInst,MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd,DlgProc_CaptureWindow);
        TabCtrl_InsertItem(m_hwndTab, 0, &itab);
        MoveWindow(itab.hwndTabPage, (rcTab.left - rcClient.left)+2, (rcTab.top - rcClient.top), (rcTab.right - rcTab.left) - 2*5, (rcTab.bottom - rcTab.top) - 2*20, TRUE);
        ShowWindow(itab.hwndTabPage, SW_HIDE);
        CheckDlgButton(itab.hwndTabPage, ID_chkClientArea, m_opt_chkClientArea ? BST_CHECKED : BST_UNCHECKED);

        itab.tcih.pszText	= TranslateT("Desktop");
        itab.tcih.iImage	= 1;
        itab.hwndTabPage	= CreateDialog(hInst,MAKEINTRESOURCE(IDD_UMain_CaptureDesktop), m_hWnd, DlgProc_CaptureDesktop);
        TabCtrl_InsertItem(m_hwndTab, 1, &itab);
        MoveWindow(itab.hwndTabPage, (rcTab.left - rcClient.left)+2, (rcTab.top - rcClient.top), (rcTab.right - rcTab.left) - 2*5, (rcTab.bottom - rcTab.top) - 2*20, TRUE);
        ShowWindow(itab.hwndTabPage, SW_HIDE);

        hCtrl = GetDlgItem(itab.hwndTabPage, ID_edtCaption);
        ComboBox_ResetContent(hCtrl);
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("<Entire Desktop>"))  ,0);
        ComboBox_SetCurSel (hCtrl,0);
        if(m_MonitorCount >1) {
            TCHAR	tszTemp[120];
            for (size_t i = 0; i < m_MonitorCount; ++i) {
                mir_sntprintf(tszTemp, SIZEOF(tszTemp),_T("%i. %s%s"),
                              i+1,
                              TranslateT("Monitor"),
                              (m_Monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? TranslateT(" (primary)") : _T("")
                             );
                ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, tszTemp)  , i+1);
            }
            ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxDesktop);	//use Workaround for MS bug ComboBox_SelectItemData
        }
        PostMessage(m_hWnd, WM_COMMAND, MAKEWPARAM(ID_edtCaption, CBN_SELCHANGE),(LPARAM)hCtrl);

        //select tab and set m_hwndTabPage
        TabCtrl_SetCurSel(m_hwndTab, m_opt_tabCapture);
        ZeroMemory(&itab, sizeof(itab));
        itab.tcih.mask = TCIF_PARAM;
        TabCtrl_GetItem(m_hwndTab,TabCtrl_GetCurSel(m_hwndTab),&itab);
        ShowWindow(itab.hwndTabPage,SW_SHOW);
        m_hwndTabPage = itab.hwndTabPage;
    }
    //init Format combo box
    {
        hCtrl = GetDlgItem(m_hWnd, ID_cboxFormat);
        ComboBox_ResetContent(hCtrl);
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("PNG")),0);
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("JPG")),1);
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("BMP")),2);
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("TIF")),3);
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("GIF")),4);
        ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxFormat);	//use Workaround for MS bug ComboBox_SelectItemData
    }
    //init SendBy combo box
    {
        hCtrl = GetDlgItem(m_hWnd, ID_cboxSendBy);
        ComboBox_ResetContent(hCtrl);
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("<Only save>"))  ,SS_JUSTSAVE);
        if (m_hContact) {
            ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("File Transfer")),SS_FILESEND);
        }
        else if(m_opt_cboxSendBy == SS_FILESEND) {
            m_opt_cboxSendBy = SS_IMAGESHACK;
        }
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("E-mail"))       ,SS_EMAIL);
        if (myGlobals.PluginHTTPExist) {
            ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("HTTP Server"))  ,SS_HTTPSERVER);
        }
        else if(m_opt_cboxSendBy == SS_HTTPSERVER) {
            m_opt_cboxSendBy = SS_IMAGESHACK;
        }
        if (myGlobals.PluginFTPExist) {
            ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("FTP File"))     ,SS_FTPFILE);
        }
        else if(m_opt_cboxSendBy == SS_FTPFILE) {
            m_opt_cboxSendBy = SS_IMAGESHACK;
        }
        ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("ImageShack"))   ,(BYTE)SS_IMAGESHACK);
        ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxSendBy);	//use Workaround for MS bug ComboBox_SelectItemData
        cboxSendByChange();		//enable disable controls
    }
    //init footer options
    CheckDlgButton(m_hWnd,ID_chkOpenAgain, m_opt_chkOpenAgain ? BST_CHECKED : BST_UNCHECKED);

    if (hCtrl = GetDlgItem(m_hWnd, ID_btnAbout)) {
        SendDlgItemMessage(m_hWnd, ID_btnAbout, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Information"), MBBF_TCHAR);
        HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSHELP);
        SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
        SetWindowText(hCtrl, hIcon ? _T("") : _T("?"));
    }

    if (hCtrl = GetDlgItem(m_hWnd, ID_btnExplore)) {
        SendDlgItemMessage(m_hWnd, ID_btnExplore, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open Folder"), MBBF_TCHAR);
        HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSFOLDERO);
        SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
        SetWindowText(hCtrl, hIcon ? _T("") : _T("..."));
    }

    if (hCtrl = GetDlgItem(m_hWnd, ID_btnDesc)) {
        SendDlgItemMessage(m_hWnd, ID_btnDesc, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Fill description textbox."), MBBF_TCHAR);
        HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF);
        SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
        SetWindowText(hCtrl, hIcon ? _T("") : _T("D"));
        SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDesc ? BST_CHECKED : BST_UNCHECKED, NULL);
    }

    if (hCtrl = GetDlgItem(m_hWnd, ID_btnDeleteAfterSend)) {
        SendDlgItemMessage(m_hWnd, ID_btnDeleteAfterSend, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete after send"), MBBF_TCHAR);
        HICON hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF);
        SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
        SetWindowText(hCtrl, hIcon ? _T("") : _T("X"));
        SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDeleteAfterSend ? BST_CHECKED : BST_UNCHECKED, NULL);
    }

    if (hCtrl = GetDlgItem(m_hWnd, ID_btnCapture)) {
        SendDlgItemMessage(m_hWnd, ID_btnCapture, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Capture"), MBBF_TCHAR);
        HICON hIcon = IcoLib_GetIcon(ICO_PLUG_OK);
        SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
        SetWindowText(hCtrl, TranslateT("&Capture"));
        SendMessage(hCtrl, BUTTONSETDEFAULT, (WPARAM)1, NULL);
    }

//	CheckDlgButton(m_hWnd,ID_chkEditor, m_opt_chkEditor ? BST_CHECKED : BST_UNCHECKED);
    TranslateDialogDefault(m_hWnd);
}