BOOL CMailMsg::MAPIInitialize() { // Determine if there is default email program CString sMailClientName; if(!DetectMailClient(sMailClientName)) { m_sErrorMsg = _T("Error detecting E-mail client"); return FALSE; } else { m_sErrorMsg = _T("Detected E-mail client ") + sMailClientName; } // Load MAPI.dll m_hMapi = AtlLoadSystemLibraryUsingFullPath(_T("mapi32.dll")); if (!m_hMapi) { m_sErrorMsg = _T("Error loading mapi32.dll"); return FALSE; } m_lpMapiSendMail = (LPMAPISENDMAIL)::GetProcAddress(m_hMapi, "MAPISendMail"); m_bReady = !!m_lpMapiSendMail; if(!m_bReady) { m_sErrorMsg = _T("Not found required function entries in mapi32.dll"); } return m_bReady; }
static void CheckCommCtrlsVersion() { // Check Common Controls version SecureZeroMemory(&g_dviCommCtrls, sizeof(DLLVERSIONINFO)); HMODULE hMod = AtlLoadSystemLibraryUsingFullPath(_T("comctl32.dll")); if (hMod != NULL) { // Get the version function DLLGETVERSIONPROC pfnDllGetVersion; pfnDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hMod, "DllGetVersion"); if (pfnDllGetVersion != NULL) { // Obtain version information g_dviCommCtrls.cbSize = sizeof(DLLVERSIONINFO); if (SUCCEEDED(pfnDllGetVersion(&g_dviCommCtrls))) { ::FreeLibrary(hMod); return; } } ::FreeLibrary(hMod); } // Set values for the worst case g_dviCommCtrls.dwMajorVersion = 4; g_dviCommCtrls.dwMinorVersion = 0; g_dviCommCtrls.dwBuildNumber = 0; g_dviCommCtrls.dwPlatformID = DLLVER_PLATFORM_WINDOWS; }
BOOL CGitProgressDlg::OnInitDialog() { __super::OnInitDialog(); // Let the TaskbarButtonCreated message through the UIPI filter. If we don't // do this, Explorer would be unable to send that message to our window if we // were running elevated. It's OK to make the call all the time, since if we're // not elevated, this is a no-op. CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) }; typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct); CAutoLibrary hUser = AtlLoadSystemLibraryUsingFullPath(_T("user32.dll")); if (hUser) { ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx"); if (pfnChangeWindowMessageFilterEx) { pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs); } } m_ProgList.m_pTaskbarList.Release(); if (FAILED(m_ProgList.m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList))) m_ProgList.m_pTaskbarList = nullptr; UpdateData(FALSE); AddAnchor(IDC_SVNPROGRESS, TOP_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_TITLE_ANIMATE, TOP_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_PROGRESSLABEL, BOTTOM_LEFT, BOTTOM_CENTER); AddAnchor(IDC_PROGRESSBAR, BOTTOM_CENTER, BOTTOM_RIGHT); AddAnchor(IDC_INFOTEXT, BOTTOM_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_NONINTERACTIVE, BOTTOM_LEFT, BOTTOM_RIGHT); AddAnchor(IDCANCEL, BOTTOM_RIGHT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDC_LOGBUTTON, BOTTOM_RIGHT); //SetPromptParentWindow(this->m_hWnd); m_Animate.Open(IDR_DOWNLOAD); m_ProgList.m_pAnimate = &m_Animate; m_ProgList.m_pProgControl = &m_ProgCtrl; m_ProgList.m_pProgressLabelCtrl = &m_ProgLableCtrl; m_ProgList.m_pInfoCtrl = &m_InfoCtrl; m_ProgList.m_pPostWnd = this; m_ProgList.m_bSetTitle = true; if (hWndExplorer) CenterWindow(CWnd::FromHandle(hWndExplorer)); EnableSaveRestore(_T("GITProgressDlg")); m_background_brush.CreateSolidBrush(GetSysColor(COLOR_WINDOW)); m_ProgList.Init(); return TRUE; }
HRESULT SetAppID(LPCTSTR appID) { HRESULT hRes = S_FALSE; typedef HRESULT STDAPICALLTYPE SetCurrentProcessExplicitAppUserModelIDFN(PCWSTR AppID); CAutoLibrary hShell = AtlLoadSystemLibraryUsingFullPath(_T("shell32.dll")); if (hShell) { SetCurrentProcessExplicitAppUserModelIDFN *pfnSetCurrentProcessExplicitAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDFN*)GetProcAddress(hShell, "SetCurrentProcessExplicitAppUserModelID"); if (pfnSetCurrentProcessExplicitAppUserModelID) hRes = pfnSetCurrentProcessExplicitAppUserModelID(appID); } return hRes; }
void SetTaskIDPerUUID() { typedef HRESULT STDAPICALLTYPE SetCurrentProcessExplicitAppUserModelIDFN(PCWSTR AppID); CAutoLibrary hShell = AtlLoadSystemLibraryUsingFullPath(_T("shell32.dll")); if (hShell) { SetCurrentProcessExplicitAppUserModelIDFN *pfnSetCurrentProcessExplicitAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDFN*)GetProcAddress(hShell, "SetCurrentProcessExplicitAppUserModelID"); if (pfnSetCurrentProcessExplicitAppUserModelID) { std::wstring id = GetTaskIDPerUUID(); pfnSetCurrentProcessExplicitAppUserModelID(id.c_str()); } } }
CGitStatusCache::CGitStatusCache(void) { #define forever DWORD(-1) AutoLocker lock(m_NoWatchPathCritSec); TCHAR path[MAX_PATH] = { 0 }; SHGetFolderPath(NULL, CSIDL_COOKIES, NULL, 0, path); m_NoWatchPaths[CTGitPath(CString(path))] = forever; SecureZeroMemory(path, sizeof(path)); SHGetFolderPath(NULL, CSIDL_HISTORY, NULL, 0, path); m_NoWatchPaths[CTGitPath(CString(path))] = forever; SecureZeroMemory(path, sizeof(path)); SHGetFolderPath(NULL, CSIDL_INTERNET_CACHE, NULL, 0, path); m_NoWatchPaths[CTGitPath(CString(path))] = forever; SecureZeroMemory(path, sizeof(path)); SHGetFolderPath(NULL, CSIDL_SYSTEM, NULL, 0, path); m_NoWatchPaths[CTGitPath(CString(path))] = forever; SecureZeroMemory(path, sizeof(path)); SHGetFolderPath(NULL, CSIDL_WINDOWS, NULL, 0, path); m_NoWatchPaths[CTGitPath(CString(path))] = forever; if (SysInfo::Instance().IsVistaOrLater()) { CAutoLibrary hShell = AtlLoadSystemLibraryUsingFullPath(_T("shell32.dll")); if (hShell) { typedef HRESULT STDAPICALLTYPE SHGetKnownFolderPathFN(__in REFKNOWNFOLDERID rfid, __in DWORD dwFlags, __in_opt HANDLE hToken, __deref_out PWSTR *ppszPath); SHGetKnownFolderPathFN *pfnSHGetKnownFolderPath = (SHGetKnownFolderPathFN*)GetProcAddress(hShell, "SHGetKnownFolderPath"); if (pfnSHGetKnownFolderPath) { KNOWNFOLDERID folderids[] = { FOLDERID_Cookies, FOLDERID_History, FOLDERID_InternetCache, FOLDERID_Windows, FOLDERID_CDBurning, FOLDERID_Fonts, FOLDERID_RecycleBinFolder }; //FOLDERID_SearchHistory for (KNOWNFOLDERID folderid : folderids) { PWSTR pszPath = NULL; if (pfnSHGetKnownFolderPath(folderid, KF_FLAG_CREATE, NULL, &pszPath) != S_OK) continue; m_NoWatchPaths[CTGitPath(CString(pszPath))] = forever; CoTaskMemFree(pszPath); } } } } m_bClearMemory = false; m_mostRecentExpiresAt = 0; }
void MarkWindowAsUnpinnable(HWND hWnd) { typedef HRESULT (WINAPI *SHGPSFW) (HWND hwnd,REFIID riid,void** ppv); HMODULE hShell = AtlLoadSystemLibraryUsingFullPath(_T("Shell32.dll")); if (hShell) { SHGPSFW pfnSHGPSFW = (SHGPSFW)::GetProcAddress(hShell, "SHGetPropertyStoreForWindow"); if (pfnSHGPSFW) { IPropertyStore *pps; HRESULT hr = pfnSHGPSFW(hWnd, IID_PPV_ARGS(&pps)); if (SUCCEEDED(hr)) { PROPVARIANT var; var.vt = VT_BOOL; var.boolVal = VARIANT_TRUE; pps->SetValue(PKEY_AppUserModel_PreventPinning, var); pps->Release(); } } FreeLibrary(hShell); } }
/** * Get the shell item that represents the library. * * \param pwszLibraryName * The name of the shell library * * \param ppShellItem * If the operation succeeds, ppShellItem outputs the IShellItem2 interface * that represents the library. The caller is responsible for calling * Release on the shell item. If the function fails, NULL is returned from * *ppShellItem. */ HRESULT GetShellLibraryItem(LPWSTR pwszLibraryName, IShellItem2** ppShellItem) { HRESULT hr = E_NOINTERFACE; *ppShellItem = NULL; // Create the real library file name WCHAR wszRealLibraryName[MAX_PATH]; swprintf_s(wszRealLibraryName, L"%s%s", pwszLibraryName, L".library-ms"); typedef HRESULT STDAPICALLTYPE SHCreateItemInKnownFolderFN(REFKNOWNFOLDERID kfid, DWORD dwKFFlags, __in_opt PCWSTR pszItem, REFIID riid, __deref_out void **ppv); CAutoLibrary hShell = AtlLoadSystemLibraryUsingFullPath(_T("shell32.dll")); if (hShell) { SHCreateItemInKnownFolderFN *pfnSHCreateItemInKnownFolder = (SHCreateItemInKnownFolderFN*)GetProcAddress(hShell, "SHCreateItemInKnownFolder"); if (pfnSHCreateItemInKnownFolder) { hr = pfnSHCreateItemInKnownFolder(FOLDERID_UsersLibraries, KF_FLAG_DEFAULT_PATH | KF_FLAG_NO_ALIAS, wszRealLibraryName, IID_PPV_ARGS(ppShellItem)); } } return hr; }
void CCommonAppUtils::MarkWindowAsUnpinnable( HWND hWnd ) { typedef HRESULT (WINAPI *SHGPSFW) (HWND hwnd,REFIID riid,void** ppv); CAutoLibrary hShell = AtlLoadSystemLibraryUsingFullPath(L"Shell32.dll"); if (!hShell.IsValid()) return; SHGPSFW pfnSHGPSFW = (SHGPSFW)::GetProcAddress(hShell, "SHGetPropertyStoreForWindow"); if (pfnSHGPSFW == 0) return; IPropertyStore *pps = 0; HRESULT hr = pfnSHGPSFW(hWnd, IID_PPV_ARGS(&pps)); if (SUCCEEDED(hr)) { PROPVARIANT var; var.vt = VT_BOOL; var.boolVal = VARIANT_TRUE; hr = pps->SetValue(PKEY_AppUserModel_PreventPinning, var); pps->Release(); } }
BOOL CProgressDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); // Let the TaskbarButtonCreated message through the UIPI filter. If we don't // do this, Explorer would be unable to send that message to our window if we // were running elevated. It's OK to make the call all the time, since if we're // not elevated, this is a no-op. CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) }; typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct); CAutoLibrary hUser = AtlLoadSystemLibraryUsingFullPath(_T("user32.dll")); if (hUser) { ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx"); if (pfnChangeWindowMessageFilterEx) { pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs); } } m_pTaskbarList.Release(); if (FAILED(m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList))) m_pTaskbarList = nullptr; AddAnchor(IDC_TITLE_ANIMATE, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_RUN_PROGRESS, TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_LOG, TOP_LEFT,BOTTOM_RIGHT); AddAnchor(IDOK,BOTTOM_RIGHT); AddAnchor(IDCANCEL,BOTTOM_RIGHT); AddAnchor(IDC_PROGRESS_BUTTON1,BOTTOM_LEFT); AddAnchor(IDC_CURRENT,TOP_LEFT); this->GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_HIDE); m_Animate.Open(IDR_DOWNLOAD); CFont m_logFont; CAppUtils::CreateFontForLogs(m_logFont); //GetDlgItem(IDC_CMD_LOG)->SetFont(&m_logFont); m_Log.SetFont(&m_logFont); CString InitialText; if ( !m_PreText.IsEmpty() ) { InitialText = m_PreText + _T("\r\n"); } #if 0 if (m_bShowCommand && (!m_GitCmd.IsEmpty() )) { InitialText += m_GitCmd+_T("\r\n\r\n"); } #endif m_Log.SetWindowTextW(InitialText); m_CurrentWork.SetWindowTextW(_T("")); if (!m_PreFailText.IsEmpty()) InsertColorText(this->m_Log, m_PreFailText, RGB(255, 0, 0)); EnableSaveRestore(_T("ProgressDlg")); m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED); if (!m_pThread) { CMessageBox::Show(this->m_hWnd, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR); DialogEnableWindow(IDCANCEL, TRUE); } else { m_pThread->m_bAutoDelete = FALSE; m_pThread->ResumeThread(); } CString sWindowTitle; GetWindowText(sWindowTitle); CAppUtils::SetWindowTitle(m_hWnd, m_Git->m_CurrentDir, sWindowTitle); // Make sure this dialog is shown in foreground (see issue #1536) SetForegroundWindow(); return TRUE; }
BOOL CSyncDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); // Let the TaskbarButtonCreated message through the UIPI filter. If we don't // do this, Explorer would be unable to send that message to our window if we // were running elevated. It's OK to make the call all the time, since if we're // not elevated, this is a no-op. CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) }; typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct); CAutoLibrary hUser = AtlLoadSystemLibraryUsingFullPath(_T("user32.dll")); if (hUser) { ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx"); if (pfnChangeWindowMessageFilterEx) { pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs); } } m_pTaskbarList.Release(); if (FAILED(m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList))) m_pTaskbarList = nullptr; this->GetDlgItem(IDC_CHECK_PUTTY_KEY)->EnableWindow(CAppUtils::IsSSHPutty()); /* this->m_ctrlAnimate.ShowWindow(SW_NORMAL); this->m_ctrlAnimate.Open(IDR_DOWNLOAD); this->m_ctrlAnimate.Play(0,-1,-1); */ // ------------------ Create Tabctrl ----------- CWnd *pwnd=this->GetDlgItem(IDC_BUTTON_TABCTRL); CRect rectDummy; pwnd->GetWindowRect(&rectDummy); this->ScreenToClient(rectDummy); if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_SYNC_TAB)) { TRACE0("Failed to create output tab window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO); // -------------Create Command Log Ctrl --------- DWORD dwStyle; dwStyle= ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL |WS_VSCROLL ; if( !m_ctrlCmdOut.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_CMD_LOG)) { TRACE0("Failed to create Log commits window\n"); return FALSE; // fail to create } // set the font to use in the log message view, configured in the settings dialog CFont m_logFont; CAppUtils::CreateFontForLogs(m_logFont); //GetDlgItem(IDC_CMD_LOG)->SetFont(&m_logFont); m_ctrlCmdOut.SetFont(&m_logFont); m_ctrlTabCtrl.InsertTab(&m_ctrlCmdOut, CString(MAKEINTRESOURCE(IDS_LOG)), -1); //m_ctrlCmdOut.ReplaceSel(_T("Hello")); //---------- Create in coming list ctrl ----------- dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;; if( !m_InLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_LOGLIST)) { TRACE0("Failed to create output commits window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.InsertTab(&m_InLogList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_INCOMMITS)), -1); m_InLogList.m_ColumnRegKey=_T("SyncIn"); m_InLogList.InsertGitColumn(); //----------- Create In Change file list ----------- dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE; if( !m_InChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_CHANGELIST)) { TRACE0("Failed to create output change files window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.InsertTab(&m_InChangeFileList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_INCHANGELIST)), -1); m_InChangeFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL , _T("InSyncDlg"), (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)| CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)), false, true, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL); //---------- Create Conflict List Ctrl ----------------- dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE; if( !m_ConflictFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_CONFLICT)) { TRACE0("Failed to create output change files window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.InsertTab(&m_ConflictFileList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_CONFLICTS)), -1); m_ConflictFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL , _T("ConflictSyncDlg"), (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)| CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)| GITSLC_POPCONFLICT|GITSLC_POPRESOLVE),false); //---------- Create Commit Out List Ctrl--------------- dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;; if( !m_OutLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_LOGLIST)) { TRACE0("Failed to create output commits window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.InsertTab(&m_OutLogList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_OUTCOMMITS)), -1); m_OutLogList.m_ColumnRegKey = _T("SyncOut"); m_OutLogList.InsertGitColumn(); //------------- Create Change File List Control ---------------- dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE; if( !m_OutChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_CHANGELIST)) { TRACE0("Failed to create output change files window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.InsertTab(&m_OutChangeFileList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_OUTCHANGELIST)), -1); m_OutChangeFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD | GITSLC_COLDEL, _T("OutSyncDlg"), (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)| CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)), false, true, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL); if (!m_GitProgressList.Create(dwStyle | LVS_OWNERDATA, rectDummy, &m_ctrlTabCtrl, IDC_CMD_GIT_PROG)) { TRACE0("Failed to create Git Progress List Window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.InsertTab(&m_GitProgressList, CString(MAKEINTRESOURCE(IDS_LOG)), -1); m_GitProgressList.m_pAnimate = &m_ctrlAnimate; m_GitProgressList.m_pPostWnd = this; m_GitProgressList.m_pProgressLabelCtrl = &m_ctrlProgLabel; m_GitProgressList.m_pProgControl = &m_ctrlProgress; m_GitProgressList.m_pTaskbarList = m_pTaskbarList; dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE; DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_FULLROWSELECT; m_refList.Create(dwStyle, rectDummy, &m_ctrlTabCtrl, IDC_REFLIST); m_refList.SetExtendedStyle(exStyle); m_refList.Init(); m_ctrlTabCtrl.InsertTab(&m_refList, CString(MAKEINTRESOURCE(IDS_REFLIST)), -1); this->m_tooltips.Create(this); AddAnchor(IDC_SYNC_TAB,TOP_LEFT,BOTTOM_RIGHT); AddAnchor(IDC_GROUP_INFO,TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_COMBOBOXEX_URL,TOP_LEFT,TOP_RIGHT); AddAnchor(IDC_BUTTON_MANAGE,TOP_RIGHT); AddAnchor(IDC_BUTTON_PULL,BOTTOM_LEFT); AddAnchor(IDC_BUTTON_PUSH,BOTTOM_LEFT); AddAnchor(IDC_BUTTON_SUBMODULE,BOTTOM_LEFT); AddAnchor(IDC_BUTTON_STASH,BOTTOM_LEFT); AddAnchor(IDC_BUTTON_APPLY,BOTTOM_RIGHT); AddAnchor(IDC_BUTTON_EMAIL,BOTTOM_RIGHT); AddAnchor(IDC_PROGRESS_SYNC,TOP_LEFT,TOP_RIGHT); AddAnchor(IDOK,BOTTOM_RIGHT); AddAnchor(IDHELP,BOTTOM_RIGHT); AddAnchor(IDC_STATIC_STATUS, BOTTOM_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_ANIMATE_SYNC,TOP_LEFT); AddAnchor(IDC_BUTTON_COMMIT,BOTTOM_LEFT); AddAnchor(IDC_LOG, BOTTOM_LEFT); // do not use BRANCH_COMBOX_ADD_ANCHOR here, we want to have different stylings AddAnchor(IDC_COMBOBOXEX_LOCAL_BRANCH, TOP_LEFT,TOP_CENTER); AddAnchor(IDC_COMBOBOXEX_REMOTE_BRANCH, TOP_CENTER, TOP_RIGHT); AddAnchor(IDC_BUTTON_LOCAL_BRANCH, TOP_CENTER); AddAnchor(IDC_BUTTON_REMOTE_BRANCH, TOP_RIGHT); AddAnchor(IDC_STATIC_REMOTE_BRANCH, TOP_CENTER); AddAnchor(IDC_PROG_LABEL, TOP_LEFT); AdjustControlSize(IDC_CHECK_PUTTY_KEY); AdjustControlSize(IDC_CHECK_FORCE); CString WorkingDir=g_Git.m_CurrentDir; WorkingDir.Replace(_T(':'),_T('_')); m_RegKeyRemoteBranch = CString(_T("Software\\TortoiseGit\\History\\SyncBranch\\"))+WorkingDir; this->AddOthersToAnchor(); this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSH))); this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSHTAGS))); this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSHNOTES))); this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PULL))); this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCH))); this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCHREBASE))); this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_REMOTEUPDATE))); this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_CLEANUPSTALEBRANCHES))); this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEUPDATE))); this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEINIT))); this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULESYNC))); this->m_ctrlStash.AddEntry(CString(MAKEINTRESOURCE(IDS_MENUSTASHSAVE))); this->m_ctrlStash.AddEntry(CString(MAKEINTRESOURCE(IDS_MENUSTASHPOP))); this->m_ctrlStash.AddEntry(CString(MAKEINTRESOURCE(IDS_MENUSTASHAPPLY))); WorkingDir.Replace(_T(':'),_T('_')); CString regkey ; regkey.Format(_T("Software\\TortoiseGit\\TortoiseProc\\Sync\\%s"),WorkingDir); this->m_regPullButton = CRegDWORD(regkey+_T("\\Pull"),0); this->m_regPushButton = CRegDWORD(regkey+_T("\\Push"),0); this->m_regSubmoduleButton = CRegDWORD(regkey+_T("\\Submodule")); this->m_regAutoLoadPutty = CRegDWORD(regkey + _T("\\AutoLoadPutty"), CAppUtils::IsSSHPutty()); this->UpdateData(); this->m_bAutoLoadPuttyKey = m_regAutoLoadPutty; if(!CAppUtils::IsSSHPutty()) m_bAutoLoadPuttyKey = false; this->UpdateData(FALSE); this->m_ctrlPull.SetCurrentEntry(this->m_regPullButton); this->m_ctrlPush.SetCurrentEntry(this->m_regPushButton); this->m_ctrlSubmodule.SetCurrentEntry(this->m_regSubmoduleButton); CString sWindowTitle; GetWindowText(sWindowTitle); CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle); EnableSaveRestore(_T("SyncDlg")); m_ctrlURL.SetCaseSensitive(TRUE); this->m_ctrlURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\SyncURL\\"))+WorkingDir, _T("url")); STRING_VECTOR list; if(!g_Git.GetRemoteList(list)) { for (unsigned int i = 0; i < list.size(); ++i) { m_ctrlURL.AddString(list[i]); } } m_ctrlURL.SetCurSel(0); m_ctrlRemoteBranch.SetCurSel(0); m_ctrlURL.SetURLHistory(true); this->LoadBranchInfo(); this->m_bInited=true; FetchOutList(); m_ctrlTabCtrl.ShowTab(IDC_CMD_LOG-1,false); m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false); m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false); m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false); m_ctrlTabCtrl.ShowTab(IDC_CMD_GIT_PROG-1, false); m_ctrlTabCtrl.ShowTab(IDC_REFLIST-1, false); m_ctrlRemoteBranch.m_bWantReturn = TRUE; m_ctrlURL.m_bWantReturn = TRUE; this->m_Gitverion = CAppUtils::GetMsysgitVersion(); if (m_seq > 0 && (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\SyncDialogRandomPos"))) { m_seq %= 5; RECT rect; GetWindowRect(&rect); rect.top -= m_seq * 30; rect.bottom -= m_seq * 30; if (rect.top < 0) { rect.top += 150; rect.bottom += 150; } MoveWindow(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
bool CPicture::Load(tstring sFilePathName) { bool bResult = false; bIsIcon = false; lpIcons = NULL; //CFile PictureFile; //CFileException e; FreePictureData(); // Important - Avoid Leaks... // No-op if no file specified if (sFilePathName.empty()) return true; // Load & initialize the GDI+ library if available HMODULE hGdiPlusLib = AtlLoadSystemLibraryUsingFullPath(_T("gdiplus.dll")); if (hGdiPlusLib && GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) == Ok) { bHaveGDIPlus = true; } // Since we loaded the gdiplus.dll only to check if it's available, we // can safely free the library here again - GdiplusStartup() loaded it too // and reference counting will make sure that it stays loaded until GdiplusShutdown() // is called. FreeLibrary(hGdiPlusLib); // Attempt to load using GDI+ if available if (bHaveGDIPlus) { pBitmap = new Bitmap(sFilePathName.c_str(), FALSE); GUID guid; pBitmap->GetRawFormat(&guid); if (pBitmap->GetLastStatus() != Ok) { delete pBitmap; pBitmap = NULL; } // gdiplus only loads the first icon found in an icon file // so we have to handle icon files ourselves :( // Even though gdiplus can load icons, it can't load the new // icons from Vista - in Vista, the icon format changed slightly. // But the LoadIcon/LoadImage API still can load those icons, // at least those dimensions which are also used on pre-Vista // systems. // For that reason, we don't rely on gdiplus telling us if // the image format is "icon" or not, we also check the // file extension for ".ico". std::transform(sFilePathName.begin(), sFilePathName.end(), sFilePathName.begin(), ::tolower); bIsIcon = (guid == ImageFormatIcon) || (wcsstr(sFilePathName.c_str(), L".ico") != NULL) || (wcsstr(sFilePathName.c_str(), L".cur") != NULL); bIsTiff = (guid == ImageFormatTIFF) || (_tcsstr(sFilePathName.c_str(), _T(".tiff")) != NULL); m_Name = sFilePathName; if (bIsIcon) { // Icon file, get special treatment... if (pBitmap) { // Cleanup first... delete (pBitmap); pBitmap = NULL; bIsIcon = true; } CAutoFile hFile = CreateFile(sFilePathName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile) { BY_HANDLE_FILE_INFORMATION fileinfo; if (GetFileInformationByHandle(hFile, &fileinfo)) { lpIcons = new BYTE[fileinfo.nFileSizeLow]; DWORD readbytes; if (ReadFile(hFile, lpIcons, fileinfo.nFileSizeLow, &readbytes, NULL)) { // we have the icon. Now gather the information we need later if (readbytes >= sizeof(ICONDIR)) { // we are going to open same file second time so we have to close the file now hFile.CloseHandle(); LPICONDIR lpIconDir = (LPICONDIR)lpIcons; if ((lpIconDir->idCount) && ((lpIconDir->idCount * sizeof(ICONDIR)) <= fileinfo.nFileSizeLow)) { try { bResult = false; nCurrentIcon = 0; hIcons = new HICON[lpIconDir->idCount]; // check that the pointers point to data that we just loaded if (((BYTE*)lpIconDir->idEntries > (BYTE*)lpIconDir) && (((BYTE*)lpIconDir->idEntries) + (lpIconDir->idCount * sizeof(ICONDIRENTRY)) < ((BYTE*)lpIconDir) + fileinfo.nFileSizeLow)) { m_Width = lpIconDir->idEntries[0].bWidth; m_Height = lpIconDir->idEntries[0].bHeight; bResult = true; for (int i=0; i<lpIconDir->idCount; ++i) { hIcons[i] = (HICON)LoadImage(NULL, sFilePathName.c_str(), IMAGE_ICON, lpIconDir->idEntries[i].bWidth, lpIconDir->idEntries[i].bHeight, LR_LOADFROMFILE); if (hIcons[i] == NULL) { // if the icon couldn't be loaded, the data is most likely corrupt delete [] lpIcons; lpIcons = NULL; bResult = false; break; } } } } catch (...) { delete [] lpIcons; lpIcons = NULL; bResult = false; } } else { delete [] lpIcons; lpIcons = NULL; bResult = false; } } else { delete [] lpIcons; lpIcons = NULL; bResult = false; } } else { delete [] lpIcons; lpIcons = NULL; } } } } else if (pBitmap) // Image loaded successfully with GDI+ { m_Height = pBitmap->GetHeight(); m_Width = pBitmap->GetWidth(); bResult = true; } // If still failed to load the file... if (!bResult) { // Attempt to load the FreeImage library as an optional DLL to support additional formats // NOTE: Currently just loading via FreeImage & using GDI+ for drawing. // It might be nice to remove this dependency in the future. HMODULE hFreeImageLib = LoadLibrary(_T("FreeImage.dll")); // FreeImage DLL functions typedef const char* (__stdcall *FreeImage_GetVersion_t)(void); typedef int (__stdcall *FreeImage_GetFileType_t)(const TCHAR *filename, int size); typedef int (__stdcall *FreeImage_GetFIFFromFilename_t)(const TCHAR *filename); typedef void* (__stdcall *FreeImage_Load_t)(int format, const TCHAR *filename, int flags); typedef void (__stdcall *FreeImage_Unload_t)(void* dib); typedef int (__stdcall *FreeImage_GetColorType_t)(void* dib); typedef unsigned (__stdcall *FreeImage_GetWidth_t)(void* dib); typedef unsigned (__stdcall *FreeImage_GetHeight_t)(void* dib); typedef void (__stdcall *FreeImage_ConvertToRawBits_t)(BYTE *bits, void *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown); //FreeImage_GetVersion_t FreeImage_GetVersion = NULL; FreeImage_GetFileType_t FreeImage_GetFileType = NULL; FreeImage_GetFIFFromFilename_t FreeImage_GetFIFFromFilename = NULL; FreeImage_Load_t FreeImage_Load = NULL; FreeImage_Unload_t FreeImage_Unload = NULL; //FreeImage_GetColorType_t FreeImage_GetColorType = NULL; FreeImage_GetWidth_t FreeImage_GetWidth = NULL; FreeImage_GetHeight_t FreeImage_GetHeight = NULL; FreeImage_ConvertToRawBits_t FreeImage_ConvertToRawBits = NULL; if (hFreeImageLib) { bool exportsValid = true; //FreeImage_GetVersion = (FreeImage_GetVersion_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_GetVersion@0", valid); FreeImage_GetWidth = (FreeImage_GetWidth_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_GetWidth@4", exportsValid); FreeImage_GetHeight = (FreeImage_GetHeight_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_GetHeight@4", exportsValid); FreeImage_Unload = (FreeImage_Unload_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_Unload@4", exportsValid); FreeImage_ConvertToRawBits = (FreeImage_ConvertToRawBits_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_ConvertToRawBits@32", exportsValid); #ifdef UNICODE FreeImage_GetFileType = (FreeImage_GetFileType_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_GetFileTypeU@8", exportsValid); FreeImage_GetFIFFromFilename = (FreeImage_GetFIFFromFilename_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_GetFIFFromFilenameU@4", exportsValid); FreeImage_Load = (FreeImage_Load_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_LoadU@12", exportsValid); #else FreeImage_GetFileType = (FreeImage_GetFileType_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_GetFileType@8", exportsValid); FreeImage_GetFIFFromFilename = (FreeImage_GetFIFFromFilename_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_GetFIFFromFilename@4", exportsValid); FreeImage_Load = (FreeImage_Load_t)s_GetProcAddressEx(hFreeImageLib, "_FreeImage_Load@12", exportsValid); #endif //const char* version = FreeImage_GetVersion(); // Check the DLL is using compatible exports if (exportsValid) { // Derive file type from file header. int fileType = FreeImage_GetFileType(sFilePathName.c_str(), 0); if (fileType < 0) { // No file header available, attempt to parse file name for extension. fileType = FreeImage_GetFIFFromFilename(sFilePathName.c_str()); } // If we have a valid file type if (fileType >= 0) { void* dib = FreeImage_Load(fileType, sFilePathName.c_str(), 0); if (dib) { unsigned width = FreeImage_GetWidth(dib); unsigned height = FreeImage_GetHeight(dib); // Create a GDI+ bitmap to load into... pBitmap = new Bitmap(width, height, PixelFormat32bppARGB); if (pBitmap && pBitmap->GetLastStatus() == Ok) { // Write & convert the loaded data into the GDI+ Bitmap Rect rect(0, 0, width, height); BitmapData bitmapData; if (pBitmap->LockBits(&rect, ImageLockModeWrite, PixelFormat32bppARGB, &bitmapData) == Ok) { FreeImage_ConvertToRawBits((BYTE*)bitmapData.Scan0, dib, bitmapData.Stride, 32, 0xff << RED_SHIFT, 0xff << GREEN_SHIFT, 0xff << BLUE_SHIFT, FALSE); pBitmap->UnlockBits(&bitmapData); m_Width = width; m_Height = height; bResult = true; } else // Failed to lock the destination Bitmap { delete pBitmap; pBitmap = NULL; } } else // Bitmap allocation failed { delete pBitmap; pBitmap = NULL; } FreeImage_Unload(dib); dib = NULL; } } } FreeLibrary(hFreeImageLib); hFreeImageLib = NULL; } } }
CBrowseFolder::retVal CBrowseFolder::Show(HWND parent, CString& path, const CString& sDefaultPath /* = CString() */) { retVal ret = OK; //assume OK m_sDefaultPath = sDefaultPath; if (m_sDefaultPath.IsEmpty() && !path.IsEmpty()) { // if the result path already contains a path, use that as the default path m_sDefaultPath = path; } HRESULT hr; // Create a new common open file dialog IFileOpenDialog* pfd = NULL; hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd)); if (SUCCEEDED(hr)) { // Set the dialog as a folder picker DWORD dwOptions; if (SUCCEEDED(hr = pfd->GetOptions(&dwOptions))) { hr = pfd->SetOptions(dwOptions | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST); } // Set a title if (SUCCEEDED(hr)) { TCHAR * nl = _tcschr(m_title, '\n'); if (nl) *nl = 0; pfd->SetTitle(m_title); } // set the default folder if (SUCCEEDED(hr)) { typedef HRESULT (WINAPI *SHCIFPN)(PCWSTR pszPath, IBindCtx * pbc, REFIID riid, void ** ppv); CAutoLibrary hLib = AtlLoadSystemLibraryUsingFullPath(L"shell32.dll"); if (hLib) { SHCIFPN pSHCIFPN = (SHCIFPN)GetProcAddress(hLib, "SHCreateItemFromParsingName"); if (pSHCIFPN) { IShellItem *psiDefault = 0; hr = pSHCIFPN(m_sDefaultPath, NULL, IID_PPV_ARGS(&psiDefault)); if (SUCCEEDED(hr)) { hr = pfd->SetFolder(psiDefault); psiDefault->Release(); } } } } if (m_CheckText[0] != 0) { IFileDialogCustomize* pfdCustomize = 0; hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdCustomize)); if (SUCCEEDED(hr)) { pfdCustomize->StartVisualGroup(100, L""); pfdCustomize->AddCheckButton(101, m_CheckText, FALSE); if (m_CheckText2[0] != 0) { pfdCustomize->AddCheckButton(102, m_CheckText2, FALSE); } pfdCustomize->EndVisualGroup(); pfdCustomize->Release(); } } // Show the open file dialog if (SUCCEEDED(hr) && SUCCEEDED(hr = pfd->Show(parent))) { // Get the selection from the user IShellItem* psiResult = NULL; hr = pfd->GetResult(&psiResult); if (SUCCEEDED(hr)) { PWSTR pszPath = NULL; hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszPath); if (SUCCEEDED(hr)) { path = pszPath; CoTaskMemFree(pszPath); } psiResult->Release(); IFileDialogCustomize* pfdCustomize = 0; hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdCustomize)); if (SUCCEEDED(hr)) { pfdCustomize->GetCheckButtonState(101, &m_bCheck); pfdCustomize->GetCheckButtonState(102, &m_bCheck2); pfdCustomize->Release(); } } else ret = CANCEL; } else ret = CANCEL; pfd->Release(); } else { BROWSEINFO browseInfo = {}; browseInfo.hwndOwner = parent; browseInfo.pidlRoot = m_root; browseInfo.pszDisplayName = m_displayName; browseInfo.lpszTitle = m_title; browseInfo.ulFlags = m_style; browseInfo.lParam = (LPARAM)this; if ((_tcslen(m_CheckText) > 0)||(!m_sDefaultPath.IsEmpty())) { browseInfo.lpfn = BrowseCallBackProc; } PCIDLIST_ABSOLUTE itemIDList = SHBrowseForFolder(&browseInfo); //is the dialog canceled? if (!itemIDList) ret = CANCEL; if (ret != CANCEL) { if (!SHGetPathFromIDList(itemIDList, path.GetBuffer(MAX_PATH))) // MAX_PATH ok. Explorer can't handle paths longer than MAX_PATH. ret = NOPATH; path.ReleaseBuffer(); CoTaskMemFree((LPVOID)itemIDList); } } return ret; }
BOOL CImportPatchDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); CAppUtils::MarkWindowAsUnpinnable(m_hWnd); // Let the TaskbarButtonCreated message through the UIPI filter. If we don't // do this, Explorer would be unable to send that message to our window if we // were running elevated. It's OK to make the call all the time, since if we're // not elevated, this is a no-op. CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) }; typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct); CAutoLibrary hUser = AtlLoadSystemLibraryUsingFullPath(_T("user32.dll")); if (hUser) { ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx"); if (pfnChangeWindowMessageFilterEx) { pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs); } } m_pTaskbarList.Release(); if (FAILED(m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList))) m_pTaskbarList = nullptr; CRect rectDummy; GetClientRect(m_DlgOrigRect); m_cList.GetClientRect(m_PatchListOrigRect); CWnd *pwnd=this->GetDlgItem(IDC_AM_DUMY_TAB); pwnd->GetWindowRect(&rectDummy); this->ScreenToClient(rectDummy); if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_AM_TAB)) { TRACE0("Failed to create output tab window\n"); return FALSE; // fail to create } m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO); // Create output panes: //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE; if( ! this->m_PatchCtrl.Create(_T("Scintilla"),_T("source"),0,rectDummy,&m_ctrlTabCtrl,0,0) ) { TRACE0("Failed to create log message control"); return FALSE; } m_PatchCtrl.Init(0); m_PatchCtrl.Call(SCI_SETREADONLY, TRUE); m_PatchCtrl.SetUDiffStyle(); dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; if (!m_wndOutput.Create(_T("Scintilla"),_T("source"),0,rectDummy, &m_ctrlTabCtrl, 0,0) ) { TRACE0("Failed to create output windows\n"); return -1; // fail to create } m_wndOutput.Init(0); m_wndOutput.Call(SCI_SETREADONLY, TRUE); m_tooltips.Create(this); m_tooltips.AddTool(IDC_CHECK_3WAY,IDS_AM_3WAY_TT); m_tooltips.AddTool(IDC_CHECK_IGNORE_SPACE,IDS_AM_IGNORE_SPACE_TT); m_ctrlTabCtrl.AddTab(&m_PatchCtrl, CString(MAKEINTRESOURCE(IDS_PATCH)), 0); m_ctrlTabCtrl.AddTab(&m_wndOutput, CString(MAKEINTRESOURCE(IDS_LOG)), 1); AddAmAnchor(); AdjustControlSize(IDC_CHECK_3WAY); AdjustControlSize(IDC_CHECK_IGNORE_SPACE); AdjustControlSize(IDC_SIGN_OFF); AdjustControlSize(IDC_KEEP_CR); m_PathList.SortByPathname(true); m_cList.SetExtendedStyle( m_cList.GetExtendedStyle()| LVS_EX_CHECKBOXES ); for (int i = 0; i < m_PathList.GetCount(); ++i) { m_cList.InsertItem(0,m_PathList[i].GetWinPath()); m_cList.SetCheck(0,true); } DWORD yPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\AMDlgSizer")); RECT rcDlg, rcLogMsg, rcFileList; GetClientRect(&rcDlg); m_cList.GetWindowRect(&rcLogMsg); ScreenToClient(&rcLogMsg); this->m_ctrlTabCtrl.GetWindowRect(&rcFileList); ScreenToClient(&rcFileList); if (yPos) { RECT rectSplitter; m_wndSplitter.GetWindowRect(&rectSplitter); ScreenToClient(&rectSplitter); int delta = yPos - rectSplitter.top; if ((rcLogMsg.bottom + delta > rcLogMsg.top)&&(rcLogMsg.bottom + delta < rcFileList.bottom - 30)) { m_wndSplitter.SetWindowPos(NULL, 0, yPos, 0, 0, SWP_NOSIZE); DoSize(delta); } } CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), IDI_IMPORTPATHCES_BKG); CString sWindowTitle; GetWindowText(sWindowTitle); CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle); EnableSaveRestore(_T("ImportDlg")); SetSplitterRange(); return TRUE; }