void CMainWindow::ShowTrayIcon() { // since our main window is hidden most of the time // we have to add an auxiliary window to the system tray SecureZeroMemory(&niData,sizeof(NOTIFYICONDATA)); ULONGLONG ullVersion = GetDllVersion(_T("Shell32.dll")); if (ullVersion >= MAKEDLLVERULL(6,0,0,0)) niData.cbSize = sizeof(NOTIFYICONDATA); else if(ullVersion >= MAKEDLLVERULL(5,0,0,0)) niData.cbSize = NOTIFYICONDATA_V2_SIZE; else niData.cbSize = NOTIFYICONDATA_V1_SIZE; niData.uID = IDI_AACLR; niData.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP|NIF_INFO; niData.hIcon = (HICON)LoadImage(hResource, MAKEINTRESOURCE(IDI_AACLR), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); niData.hWnd = *this; niData.uCallbackMessage = TRAY_WM_MESSAGE; niData.uVersion = 6; Shell_NotifyIcon(NIM_DELETE,&niData); Shell_NotifyIcon(NIM_ADD,&niData); Shell_NotifyIcon(NIM_SETVERSION,&niData); DestroyIcon(niData.hIcon); }
static void AddTaskbarIcon() { ZeroMemory(&niData, sizeof(NOTIFYICONDATA)); ULONGLONG dllVersion = GetDllVersion(_T("shell32.dll")); if (dllVersion >= MAKEDLLVERULL(5, 0, 0, 0)) niData.cbSize = sizeof(NOTIFYICONDATA); else niData.cbSize = NOTIFYICONDATA_V2_SIZE; // the ID number can be anything you choose niData.uID = TRAYICONID; // state which structure members are valid niData.uFlags = NIF_ICON | NIF_MESSAGE; // load the icon niData.hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); // the window to send messages to and the message to send // note: the message value should be in the // range of WM_APP through 0xBFFF niData.hWnd = hWnd; niData.uCallbackMessage = SWM_TRAYMSG; Shell_NotifyIcon(NIM_ADD, &niData); // free icon handle if (niData.hIcon && DestroyIcon(niData.hIcon)) niData.hIcon = NULL; }
BOOL CToolTipCtrlX::OnTTShow(NMHDR *pNMHDR, LRESULT *pResult) { //DebugLog(_T("OnTTShow: rcScreen: %d,%d-%d,%d: styles=%08x exStyles=%08x"), m_rcScreen, GetStyle(), GetWindowLong(m_hWnd, GWL_EXSTYLE)); // Win98/Win2000: The only chance to resize a tooltip window is to do it within the TTN_SHOW notification. if (theApp.m_ullComCtrlVer <= MAKEDLLVERULL(5,81,0,0)) { NMTTCUSTOMDRAW nmttcd = {0}; nmttcd.uDrawFlags = DT_NOPREFIX | DT_CALCRECT | DT_EXTERNALLEADING | DT_EXPANDTABS | DT_WORDBREAK; nmttcd.nmcd.hdr = *pNMHDR; nmttcd.nmcd.dwDrawStage = CDDS_PREPAINT; nmttcd.nmcd.hdc = ::GetDC(pNMHDR->hwndFrom); CustomPaint(&nmttcd); ::ReleaseDC(pNMHDR->hwndFrom, nmttcd.nmcd.hdc); CRect rcWnd(nmttcd.nmcd.rc); AdjustRect(&rcWnd); // Win98/Win2000: We have to explicitly ensure that the tooltip window remains within the visible desktop window. EnsureWindowVisible(m_rcScreen, rcWnd); // Win98/Win2000: The only chance to resize a tooltip window is to do it within the TTN_SHOW notification. // Win98/Win2000: Must *not* specify 'SWP_NOZORDER' - some of the tooltip windows may get drawn behind(!) the application window! ::SetWindowPos(pNMHDR->hwndFrom, NULL, rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(), SWP_NOACTIVATE /*| SWP_NOZORDER*/); *pResult = TRUE; // Windows API: Suppress default positioning return TRUE; // MFC API: Suppress further routing of this message } // If the TTN_SHOW notification is not sent to the subclassed tooltip control, we would loose the // exact positioning of in-place tooltips which is performed by the tooltip control by default. // Thus it is important that we tell MFC (not the Windows API in that case) to further route this message. *pResult = FALSE; // Windows API: Perform default positioning return FALSE; // MFC API. Perform further routing of this message (to the subclassed tooltip control) }
/*********************************************************************** * DllGetVersion [SHLWAPI.@] * * Retrieve "shlwapi.dll" version information. * * PARAMS * pdvi [O] pointer to version information structure. * * RETURNS * Success: S_OK. pdvi is updated with the version information * Failure: E_INVALIDARG, if pdvi->cbSize is not set correctly. * * NOTES * You may pass either a DLLVERSIONINFO of DLLVERSIONINFO2 structure * as pdvi, provided that the size is set correctly. * Returns version as shlwapi.dll from IE5.01. */ HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi) { DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2*)pdvi; TRACE("(%p)\n",pdvi); if (!pdvi) return E_INVALIDARG; switch (pdvi2->info1.cbSize) { case sizeof(DLLVERSIONINFO2): pdvi2->dwFlags = 0; pdvi2->ullVersion = MAKEDLLVERULL(6, 0, 2800, 1612); /* Fall through */ case sizeof(DLLVERSIONINFO): pdvi2->info1.dwMajorVersion = 6; pdvi2->info1.dwMinorVersion = 0; pdvi2->info1.dwBuildNumber = 2800; pdvi2->info1.dwPlatformID = DLLVER_PLATFORM_WINDOWS; return S_OK; } WARN("pdvi->cbSize = %d, unhandled\n", pdvi2->info1.cbSize); return E_INVALIDARG; }
/************************************************************************* * DllGetVersion (ExplorerFrame.@) */ HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info) { TRACE("%p\n", info); if(info->cbSize == sizeof(DLLVERSIONINFO) || info->cbSize == sizeof(DLLVERSIONINFO2)) { /* Windows 7 */ info->dwMajorVersion = 6; info->dwMinorVersion = 1; info->dwBuildNumber = 7600; info->dwPlatformID = DLLVER_PLATFORM_WINDOWS; if(info->cbSize == sizeof(DLLVERSIONINFO2)) { DLLVERSIONINFO2 *info2 = (DLLVERSIONINFO2*)info; info2->dwFlags = 0; info2->ullVersion = MAKEDLLVERULL(info->dwMajorVersion, info->dwMinorVersion, info->dwBuildNumber, 16385); /* "hotfix number" */ } return S_OK; } WARN("wrong DLLVERSIONINFO size from app.\n"); return E_INVALIDARG; }
void CToolTipCtrlX::OnNmCustomDraw(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTTCUSTOMDRAW pNMCD = reinterpret_cast<LPNMTTCUSTOMDRAW>(pNMHDR); // For each tooltip which is to be shown Windows invokes the draw function at least 2 times. // 1st invokation: to get the drawing rectangle // 2nd invokation: to draw the actual tooltip window contents // // 'DrawText' flags for the 1st and 2nd/3rd call // --------------------------------------------- // NMTTCUSTOMDRAW 00000e50 DT_NOPREFIX | DT_CALCRECT | DT_EXTERNALLEADING | DT_EXPANDTABS | DT_WORDBREAK // TTN_SHOW // NMTTCUSTOMDRAW 00000a50 DT_NOPREFIX | DT_EXTERNALLEADING | DT_EXPANDTABS | DT_WORDBREAK // --an additional NMTTCUSTOMDRAW may follow which is identical to the 2nd-- // NMTTCUSTOMDRAW 00000a50 DT_NOPREFIX | DT_EXTERNALLEADING | DT_EXPANDTABS | DT_WORDBREAK //if (pNMCD->nmcd.dwDrawStage == CDDS_PREPAINT && pNMCD->uDrawFlags & DT_CALCRECT) // DebugLog(_T("")); //DebugLog(_T("OnNmCustomDraw: DrawFlags=%08x DrawStage=%08x ItemSpec=%08x ItemState=%08x ItemlParam=%08x rc=%4d,%4d,(%4dx%4d), styles=%08x exStyles=%08x"), pNMCD->uDrawFlags, pNMCD->nmcd.dwDrawStage, pNMCD->nmcd.dwItemSpec, pNMCD->nmcd.uItemState, pNMCD->nmcd.lItemlParam, pNMCD->nmcd.rc.left, pNMCD->nmcd.rc.top, pNMCD->nmcd.rc.right - pNMCD->nmcd.rc.left, pNMCD->nmcd.rc.bottom - pNMCD->nmcd.rc.top, GetStyle(), GetWindowLong(m_hWnd, GWL_EXSTYLE)); if (theApp.m_ullComCtrlVer <= MAKEDLLVERULL(5,81,0,0)) { // Win98/Win2000: Resize and position the tooltip window in TTN_SHOW. // Win98/Win2000: Customize the tooltip window in CDDS_POSTPAINT. if (pNMCD->nmcd.dwDrawStage == CDDS_PREPAINT) { // PROBLEM: Windows will draw the default tooltip during the non-DT_CALCRECT cycle, // and if the system is very slow (or when using remote desktop), the default tooltip // may be visible for a second. However, we need to draw the customized tooltip after // CDDS_POSTPAINT otherwise it won't be visible at all. // Cheap solution: Let windows draw the text with the background color, so the glitch // is not that much visible. SetTextColor(pNMCD->nmcd.hdc, m_crTooltipBkColor); *pResult = CDRF_NOTIFYPOSTPAINT; return; } else if (pNMCD->nmcd.dwDrawStage == CDDS_POSTPAINT) { CustomPaint(pNMCD); *pResult = CDRF_SKIPDEFAULT; return; } } else { // XP/Vista: Resize, position and customize the tooltip window all in 'CDDS_PREPAINT'. if (pNMCD->nmcd.dwDrawStage == CDDS_PREPAINT) { CustomPaint(pNMCD); *pResult = CDRF_SKIPDEFAULT; return; } } *pResult = CDRF_DODEFAULT; }
HRESULT DllGetVersion (DLLVERSIONINFO2 *pdvi) { if ( !pdvi || (pdvi->info1.cbSize != sizeof (*pdvi)) ) return (E_INVALIDARG); pdvi->info1.dwMajorVersion = 1; pdvi->info1.dwMinorVersion = 0; pdvi->info1.dwBuildNumber = 3; pdvi->info1.dwPlatformID = DLLVER_PLATFORM_WINDOWS; if (pdvi->info1.cbSize == sizeof (DLLVERSIONINFO2)) pdvi->ullVersion = MAKEDLLVERULL (1, 0, 3, 1928); return S_OK; }
TrayIcon::TrayIcon(HWND hwnd, UINT id, HICON icon, bool isBalooned, TCHAR *toolTip, TCHAR *toolTipTitle) { this->hwnd = hwnd; oldIconData = Shell32Version < MAKEDLLVERULL(5, 0, 0, 0); if (Shell32Version >= MAKEDLLVERULL(6, 0, 0, 0)) { iconDataSize = sizeof(NOTIFYICONDATA); this->isBalooned = isBalooned; } else if (Shell32Version >= MAKEDLLVERULL(5, 0, 0, 0)) { iconDataSize = NOTIFYICONDATA_V2_SIZE; this->isBalooned = isBalooned; } else { iconDataSize = NOTIFYICONDATA_V1_SIZE; this->isBalooned = false; } ZeroMemory(&nid, iconDataSize); nid.cbSize = iconDataSize; nid.uID = id; nid.hWnd = hwnd; nid.hIcon = icon; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; if (this->isBalooned) { nid.uFlags |= NIF_INFO; _tcsncpy(nid.szInfoTitle, toolTipTitle, 63); nid.szInfoTitle[64] = NULL; } nid.uCallbackMessage = WM_TRAYICON; visible = false; SetTooltip(toolTip); }
HRESULT DllGetVersion (DLLVERSIONINFO2* pdvi) { if (!pdvi || (sizeof(*pdvi) != pdvi->info1.cbSize)) return (E_INVALIDARG); pdvi->info1.dwMajorVersion = 2; pdvi->info1.dwMinorVersion = 2; pdvi->info1.dwBuildNumber = 1; pdvi->info1.dwPlatformID = DLLVER_PLATFORM_WINDOWS; if (sizeof(DLLVERSIONINFO2) == pdvi->info1.cbSize) pdvi->ullVersion = MAKEDLLVERULL(2, 2, 1, 0); return S_OK; }
EXTERN_C HRESULT WINAPI GdippDllGetVersion(DLLVERSIONINFO* pdvi) { if (!pdvi || pdvi->cbSize < sizeof(DLLVERSIONINFO)) { return E_INVALIDARG; } const UINT cbSize = pdvi->cbSize; ZeroMemory(pdvi, cbSize); pdvi->cbSize = cbSize; HRSRC hRsrc = FindResource(GetDLLInstance(), MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); if (!hRsrc) { return E_FAIL; } HGLOBAL hGlobal = LoadResource(GetDLLInstance(), hRsrc); if (!hGlobal) { return E_FAIL; } const WORD* lpwPtr = (const WORD*)LockResource(hGlobal); if (lpwPtr[1] != sizeof(VS_FIXEDFILEINFO)) { return E_FAIL; } const VS_FIXEDFILEINFO* pvffi = (const VS_FIXEDFILEINFO*)(lpwPtr + 20); if (pvffi->dwSignature != VS_FFI_SIGNATURE || pvffi->dwStrucVersion != VS_FFI_STRUCVERSION) { return E_FAIL; } //8.0.2006.1027 // -> Major: 8, Minor: 2006, Build: 1027 pdvi->dwMajorVersion = HIWORD(pvffi->dwFileVersionMS); pdvi->dwMinorVersion = LOWORD(pvffi->dwFileVersionMS) * 10 + HIWORD(pvffi->dwFileVersionLS); pdvi->dwBuildNumber = LOWORD(pvffi->dwFileVersionLS); pdvi->dwPlatformID = DLLVER_PLATFORM_NT; if (pdvi->cbSize < sizeof(DLLVERSIONINFO2)) { return S_OK; } DLLVERSIONINFO2* pdvi2 = (DLLVERSIONINFO2*)pdvi; pdvi2->ullVersion = MAKEDLLVERULL(pdvi->dwMajorVersion, pdvi->dwMinorVersion, pdvi->dwBuildNumber, 2); return S_OK; }
void MainDialog::initNotifyIcon() { // Fill the NOTIFYICONDATA structure and call Shell_NotifyIcon // zero the structure - note: Some Windows funtions require this but // I can't be bothered which ones do and // which ones don't. ZeroMemory(&niData,sizeof(NOTIFYICONDATA)); // get Shell32 version number and set the size of the structure // note: the MSDN documentation about this is a little // dubious and I'm not at all sure if the method // bellow is correct ULONGLONG ullVersion = GetDllVersion("Shell32.dll"); if(ullVersion >= MAKEDLLVERULL(5, 0,0,0)) niData.cbSize = sizeof(NOTIFYICONDATA); else niData.cbSize = NOTIFYICONDATA_V2_SIZE; // the ID number can be anything you choose niData.uID = TRAYICONID; // state which structure members are valid niData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; // load the icon niData.hIcon = (HICON)LoadImage(_hInstance,MAKEINTRESOURCE(IDI_STEALTHDLG), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); // the window to send messages to and the message to send // note: the message value should be in the // range of WM_APP through 0xBFFF niData.hWnd = _hWnd; niData.uCallbackMessage = SWM_TRAYMSG; // tooltip message lstrcpyn(niData.szTip, "Time flies like an arrow but\n fruit flies like a banana!", sizeof(niData.szTip)/sizeof(TCHAR)); Shell_NotifyIcon(NIM_ADD,&niData); // free icon handle if(niData.hIcon && DestroyIcon(niData.hIcon)) niData.hIcon = NULL; // call ShowWindow here to make the dialog initially visible }
BOOL CMuleToolbarCtrl::GetMaxSize(LPSIZE pSize) const { BOOL bResult = CToolBarCtrl::GetMaxSize(pSize); if (theApp.m_ullComCtrlVer <= MAKEDLLVERULL(5,81,0,0)) { int iWidth = 0; int iButtons = GetButtonCount(); for (int i = 0; i < iButtons; i++) { CRect rcButton; if (GetItemRect(i, &rcButton)) iWidth += rcButton.Width(); } if (iWidth > pSize->cx) pSize->cx = iWidth; } return bResult; }
// Initialize the window and tray icon static BOOL InitInstance(HINSTANCE hInstance, int /* nCmdShow */) { // prepare for XP style controls InitCommonControls(); HWND hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC) MainDlgProc); if (!hWnd) return FALSE; ZeroMemory(&niData, sizeof(NOTIFYICONDATA)); ULONGLONG ullVersion = GetDllVersion(_T("shell32.dll")); if (ullVersion >= MAKEDLLVERULL(5, 0, 0, 0)) niData.cbSize = sizeof(NOTIFYICONDATA); else niData.cbSize = NOTIFYICONDATA_V2_SIZE; // the ID number can be anything you choose niData.uID = TRAYICONID; // state which structure members are valid niData.uFlags = NIF_ICON | NIF_MESSAGE; // load the icon niData.hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); // the window to send messages to and the message to send // note: the message value should be in the // range of WM_APP through 0xBFFF niData.hWnd = hWnd; niData.uCallbackMessage = SWM_TRAYMSG; Shell_NotifyIcon(NIM_ADD, &niData); // free icon handle if (niData.hIcon && DestroyIcon(niData.hIcon)) niData.hIcon = NULL; // call ShowWindow here to make the dialog initially visible return TRUE; }
// Get dll version number static ULONGLONG GetDllVersion(LPCTSTR lpszDllName) { DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(GetModuleHandle(lpszDllName), "DllGetVersion"); if (!pDllGetVersion) return 0; DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion) (&dvi); if (SUCCEEDED(hr)) return MAKEDLLVERULL(dvi.dwMajorVersion, dvi.dwMinorVersion, 0, 0); return 0; }
STDAPI DllGetVersion(DLLVERSIONINFO2* pdvi) { if (pdvi == 0) return E_POINTER; DLLVERSIONINFO2& dvi2 = *pdvi; DLLVERSIONINFO& dvi1 = dvi2.info1; if (dvi1.cbSize < sizeof(DLLVERSIONINFO)) return E_INVALIDARG; std::wstring filename_; const HRESULT hr = ComReg::ComRegGetModuleFileName(g_hModule, filename_); if (FAILED(hr)) return hr; if (filename_.empty()) return E_FAIL; const wchar_t* const filename = filename_.c_str(); WORD a, b, c, d; VersionHandling::GetVersion(filename, a, b, c, d); dvi1.dwMajorVersion = a; dvi1.dwMinorVersion = b; dvi1.dwBuildNumber = c; dvi1.dwPlatformID = /* DLLVER_PLATFORM_NT */ d; if (dvi1.cbSize < sizeof(DLLVERSIONINFO2)) return S_OK; dvi2.dwFlags = 0; dvi2.ullVersion = MAKEDLLVERULL(a, b, c, /* 0 */ d); return S_OK; }
void CMuleToolbarCtrl::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) { CToolBarCtrl::OnSettingChange(uFlags, lpszSection); // Vista: There are certain situations where the toolbar control does not redraw/resize // correctly under Vista. Unfortunately Vista just sends a WM_SETTINGCHANGE when certain // system settings have changed. Furthermore Vista sends that particular message way // more often than WinXP. // Whenever the toolbar control receives a WM_SETTINGCHANGE, it tries to resize itself // (most likely because it thinks that some system font settings have changed). However, // that resizing does fail when the toolbar control has certain non-standard metrics // applied (see the table below). // // Toolbar configuration Redraw due to WM_SETTINGCHANGE // ---------------------------------------------------------- // Large Icons + No Text Fail // Small Icons + No Text Fail // // Large Icons + Text on Right Ok // Small Icons + Text on Right Fail // // Large Icons + Text on Bottom Ok // Small Icons + Text on Bottom Ok // // The problem with this kind of 'correction' is that the WM_SETTINGCHANGE message is // sometimes sent very often and we need to try to invoke our 'correction' code as seldom // as possible to avoid too much window flickering. // // The toolbar control seems to *not* evaluate the "lpszSection" parameter of the WM_SETTINGCHANGE // message to determine if it really needs to resize itself, it seems to just resize itself // whenever a WM_SETTINGCHANGE is received, regardless the value of that parameter. Thus, we can // not use the value of that parameter to limit the invokation of our correction code. // if ( theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6,16,0,0) && (m_eLabelType == NoLabels || (m_eLabelType == LabelsRight && m_sizBtnBmp.cx == 16))) { ChangeToolbarBitmap(thePrefs.GetToolbarBitmapSettings(), true); } }
ULONGLONG GetDllVersion(TCHAR* lpszDllName) { HINSTANCE hinstDll; ULONGLONG dwVersion = 0; /* For security purposes, LoadLibrary should be provided with a fully-qualified path to the DLL. The lpszDllName variable should be tested to ensure that it is a fully qualified path before it is used. */ hinstDll = LoadLibrary(lpszDllName); if(hinstDll) { DLLGETVERSIONPROC pDllGetVersion; pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); /* Because some DLLs might not implement this function, you must test for it explicitly. Depending on the particular DLL, the lack of a DllGetVersion function can be a useful indicator of the version. */ if(pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if(SUCCEEDED(hr)) dwVersion = MAKEDLLVERULL(dvi.dwMajorVersion, dvi.dwMinorVersion, dvi.dwBuildNumber, 0); } FreeLibrary(hinstDll); } return dwVersion; }
// Get dll version number static ULONGLONG GetDllVersion(LPCTSTR lpszDllName) { ULONGLONG ullVersion = 0; HINSTANCE hinstDll; hinstDll = LoadLibraryA(lpszDllName); if(hinstDll) { DLLGETVERSIONPROC pDllGetVersion; pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); if(pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if(SUCCEEDED(hr)) ullVersion = MAKEDLLVERULL(dvi.dwMajorVersion, dvi.dwMinorVersion,0,0); } FreeLibrary(hinstDll); } return ullVersion; }
void CToolTipCtrlX::CustomPaint(LPNMTTCUSTOMDRAW pNMCD) { CWnd* pwnd = CWnd::FromHandle(pNMCD->nmcd.hdr.hwndFrom); CDC* pdc = CDC::FromHandle(pNMCD->nmcd.hdc); // Windows Vista (General) // ----------------------- // *Need* to use (some aspects) of the 'TOOLTIP' theme to get typical Vista tooltips. // // Windows Vista *without* SP1 // --------------------------- // The Vista 'TOOLTIP' theme offers a bold version of the standard tooltip font via // the TTP_STANDARDTITLE part id. Furthermore TTP_STANDARDTITLE is the same font as // the standard tooltip font (TTP_STANDARD). So, the 'TOOLTIP' theme can get used // thoroughly. // // Windows Vista *with* SP1 // ------------------------ // The Vista SP1(!) 'TOOLTIP' theme does though *not* offer a bold font. Keep // in mind that TTP_STANDARDTITLE does not return a bold font. Keep also in mind // that TTP_STANDARDTITLE is even a *different* font than TTP_STANDARD! // Which means, that TTP_STANDARDTITLE should *not* be used within the same line // as TTP_STANDARD. It just looks weird. TTP_STANDARDTITLE could be used for a // single line (the title line), but it would though not give us a bold font. // So, actually we can use the Vista 'TOOLTIP' theme only for getting the proper // tooltip background. // // Windows XP // ---------- // Can *not* use the 'TOOLTIP' theme at all because it would give us only a (non-bold) // black font on a white tooltip window background. Seems that the 'TOOLTIP' theme under // WinXP is just using the default Window values (black+white) and does not // use any of the tooltip specific Window metrics... // bool bUseEmbeddedThemeFonts = false; HTHEME hTheme = NULL; if (theApp.IsVistaThemeActive()) { hTheme = OpenThemeData(*pwnd, L"TOOLTIP"); // Using the theme's fonts works only under Vista without SP1. When SP1 // is installed the fonts which are used for TTP_STANDARDTITLE and TTP_STANDARD // do no longer match (should not get displayed within the same text line). if (hTheme) bUseEmbeddedThemeFonts = true; } CString strText; pwnd->GetWindowText(strText); CRect rcWnd; pwnd->GetWindowRect(&rcWnd); CFont* pOldDCFont = NULL; if (hTheme == NULL || !bUseEmbeddedThemeFonts) { // If we have a theme, we try to query the correct fonts from it if (m_fontNormal.m_hObject == NULL && hTheme) { // Windows Vista Ultimate, 6.0.6001 SP1 Build 6001, English with German Language Pack // ---------------------------------------------------------------------------------- // TTP_STANDARD, TTSS_NORMAL // Height -12 // Weight 400 // CharSet 1 // Quality 5 // FaceName "Segoe UI" // // TTP_STANDARDTITLE, TTSS_NORMAL // Height -12 // Weight 400 // CharSet 1 // Quality 5 // FaceName "Segoe UI Fett" (!!!) Note: "Fett" (that is German !?) // // That font name ("Segoe UI *Fett*") looks quite suspicious. I would not be surprised // if that eventually leads to a problem within the font mapper which may not be capable // of finding the (english) version of that font and thus falls back to the standard // system font. At least this would explain why the TTP_STANDARD and TTP_STANDARDTITLE // fonts are *different* on that particular Windows Vista system. LOGFONT lf = {0}; if (GetThemeFont(hTheme, pdc->m_hDC, TTP_STANDARD, TTSS_NORMAL, TMT_FONT, &lf) == S_OK) { VERIFY( m_fontNormal.CreateFontIndirect(&lf) ); if (m_bCol1Bold && m_fontBold.m_hObject == NULL) { memset(&lf, 0, sizeof(lf)); if (GetThemeFont(hTheme, pdc->m_hDC, TTP_STANDARDTITLE, TTSS_NORMAL, TMT_FONT, &lf) == S_OK) VERIFY( m_fontBold.CreateFontIndirect(&lf) ); } // Get the tooltip font color COLORREF crText; if (GetThemeColor(hTheme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &crText) == S_OK) m_crTooltipTextColor = crText; } } // If needed, create the standard tooltip font which was queried from the system metrics if (m_fontNormal.m_hObject == NULL && m_lfNormal.lfHeight != 0) VERIFY( m_fontNormal.CreateFontIndirect(&m_lfNormal) ); // Select the tooltip font if (m_fontNormal.m_hObject != NULL) { pOldDCFont = pdc->SelectObject(&m_fontNormal); // If needed, create the bold version of the tooltip font by deriving it from the standard font if (m_bCol1Bold && m_fontBold.m_hObject == NULL) { LOGFONT lf; m_fontNormal.GetLogFont(&lf); lf.lfWeight = FW_BOLD; VERIFY( m_fontBold.CreateFontIndirect(&lf) ); } } // Set the font color (queried from system metrics or queried from theme) pdc->SetTextColor(m_crTooltipTextColor); } // Auto-format the text only if explicitly requested. Otherwise we would also format // single line tooltips for regular list items, and if those list items contain ':' // characters they would be shown partially in bold. For performance reasons, the // auto-format is to be requested by appending the TOOLTIP_AUTOFORMAT_SUFFIX_CH // character. Appending, because we can remove that character efficiently without // re-allocating the entire string. bool bAutoFormatText = strText.GetLength() > 0 && strText[strText.GetLength() - 1] == TOOLTIP_AUTOFORMAT_SUFFIX_CH; if (bAutoFormatText) strText.Truncate(strText.GetLength() - 1); // truncate the TOOLTIP_AUTOFORMAT_SUFFIX_CH char by setting it to NUL bool bShowFileIcon = m_bShowFileIcon && bAutoFormatText; if (bShowFileIcon) { int iPosNL = strText.Find(_T('\n')); if (iPosNL > 0) { int iPosColon = strText.Find(_T(':')); if (iPosColon < iPosNL) bShowFileIcon = false; // 1st line does not contain a filename } } int iTextHeight = 0; int iMaxCol1Width = 0; int iMaxCol2Width = 0; int iMaxSingleLineWidth = 0; CSize sizText(0); int iPos = 0; int iCaptionHeight = 0; const int iCaptionEnd = bShowFileIcon ? max(strText.Find(_T("\n<br_head>\n")), 0) : 0; // special tooltip with file icon const int iLineHeightOff = 1; const int iIconMinYBorder = bShowFileIcon ? 3 : 0; const int iIconWidth = bShowFileIcon ? theApp.GetBigSytemIconSize().cx : 0; const int iIconHeight = bShowFileIcon ? theApp.GetBigSytemIconSize().cy : 0; const int iIconDrawingWidth = bShowFileIcon ? (iIconWidth + 9) : 0; while (iPos != -1) { CString strLine = GetNextString(strText, _T('\n'), iPos); int iColon = bAutoFormatText ? strLine.Find(_T(':')) : -1; if (iColon != -1) { CSize siz; if (hTheme && bUseEmbeddedThemeFonts) { CRect rcExtent; CRect rcBounding(0, 0, 32767, 32767); GetThemeTextExtent(hTheme, *pdc, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, iColon + 1, m_dwCol1DrawTextFlags, &rcBounding, &rcExtent); siz.cx = rcExtent.Width(); siz.cy = rcExtent.Height(); } else { CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL; siz = pdc->GetTextExtent(strLine, iColon + 1); if (pOldFont) pdc->SelectObject(pOldFont); } iMaxCol1Width = max<int>(iMaxCol1Width, siz.cx + ((bShowFileIcon && iPos <= iCaptionEnd + strLine.GetLength()) ? iIconDrawingWidth : 0)); iTextHeight = siz.cy + iLineHeightOff; // update height with 'col1' string, because 'col2' string might be empty and therefore has no height if (iPos <= iCaptionEnd) iCaptionHeight += siz.cy + iLineHeightOff; else sizText.cy += siz.cy + iLineHeightOff; LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1; while (_istspace((_TUCHAR)*pszCol2)) pszCol2++; if (*pszCol2 != _T('\0')) { if (hTheme && bUseEmbeddedThemeFonts) { CRect rcExtent; CRect rcBounding(0, 0, 32767, 32767); GetThemeTextExtent(hTheme, *pdc, TTP_STANDARD, TTSS_NORMAL, pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, m_dwCol2DrawTextFlags, &rcBounding, &rcExtent); siz.cx = rcExtent.Width(); siz.cy = rcExtent.Height(); } else { siz = pdc->GetTextExtent(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2); } iMaxCol2Width = max<int>(iMaxCol2Width, siz.cx); } } else if (bShowFileIcon && iPos <= iCaptionEnd && iPos == strLine.GetLength() + 1){ // file name, printed bold on top without any tabbing or desc CSize siz; if (hTheme && bUseEmbeddedThemeFonts) { CRect rcExtent; CRect rcBounding(0, 0, 32767, 32767); GetThemeTextExtent(hTheme, *pdc, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol1DrawTextFlags, &rcBounding, &rcExtent); siz.cx = rcExtent.Width(); siz.cy = rcExtent.Height(); } else { CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL; siz = pdc->GetTextExtent(strLine); if (pOldFont) pdc->SelectObject(pOldFont); } iMaxSingleLineWidth = max<int>(iMaxSingleLineWidth, siz.cx + iIconDrawingWidth); iCaptionHeight += siz.cy + iLineHeightOff; } else if (!strLine.IsEmpty() && strLine.Compare(_T("<br>")) != 0 && strLine.Compare(_T("<br_head>")) != 0) { CSize siz; if (hTheme && bUseEmbeddedThemeFonts) { CRect rcExtent; CRect rcBounding(0, 0, 32767, 32767); GetThemeTextExtent(hTheme, *pdc, TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol2DrawTextFlags, &rcBounding, &rcExtent); siz.cx = rcExtent.Width(); siz.cy = rcExtent.Height(); } else { siz = pdc->GetTextExtent(strLine); } iMaxSingleLineWidth = max<int>(iMaxSingleLineWidth, siz.cx + ((bShowFileIcon && iPos <= iCaptionEnd) ? iIconDrawingWidth : 0)); if (bShowFileIcon && iPos <= iCaptionEnd + strLine.GetLength()) iCaptionHeight += siz.cy + iLineHeightOff; else sizText.cy += siz.cy + iLineHeightOff; } else{ CSize siz; if (hTheme && bUseEmbeddedThemeFonts) { CRect rcExtent; CRect rcBounding(0, 0, 32767, 32767); GetThemeTextExtent(hTheme, *pdc, TTP_STANDARD, TTSS_NORMAL, _T(" "), 1, m_dwCol2DrawTextFlags, &rcBounding, &rcExtent); siz.cx = rcExtent.Width(); siz.cy = rcExtent.Height(); } else { // TODO: Would need to use 'GetTabbedTextExtent' here, but do we actually use 'tabbed' text here at all ?? siz = pdc->GetTextExtent(_T(" "), 1); } sizText.cy += siz.cy + iLineHeightOff; } } if (bShowFileIcon && iCaptionEnd > 0) iCaptionHeight = max<int>(iCaptionHeight, theApp.GetBigSytemIconSize().cy + (2*iIconMinYBorder)); sizText.cy += iCaptionHeight; if (hTheme && theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6,16,0,0)) sizText.cy += 2; // extra bottom margin for Vista/Theme iMaxCol1Width = min(m_iScreenWidth4, iMaxCol1Width); iMaxCol2Width = min(m_iScreenWidth4*2, iMaxCol2Width); const int iMiddleMargin = 6; iMaxSingleLineWidth = max(iMaxSingleLineWidth, iMaxCol1Width + iMiddleMargin + iMaxCol2Width); if (iMaxSingleLineWidth > m_iScreenWidth4*3) iMaxSingleLineWidth = m_iScreenWidth4*3; sizText.cx = iMaxSingleLineWidth; if (pNMCD->uDrawFlags & DT_CALCRECT) { pNMCD->nmcd.rc.left = rcWnd.left; pNMCD->nmcd.rc.top = rcWnd.top; pNMCD->nmcd.rc.right = rcWnd.left + sizText.cx; pNMCD->nmcd.rc.bottom = rcWnd.top + sizText.cy; } else { pwnd->ScreenToClient(&rcWnd); int iOldBkColor = -1; if (hTheme) { int iPartId = TTP_STANDARD; int iStateId = TTSS_NORMAL; if (IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId)) DrawThemeParentBackground(m_hWnd, pdc->m_hDC, &rcWnd); DrawThemeBackground(hTheme, pdc->m_hDC, iPartId, iStateId, &rcWnd, NULL); } else { ::FillRect(*pdc, &rcWnd, GetSysColorBrush(COLOR_INFOBK)); iOldBkColor = pdc->SetBkColor(m_crTooltipBkColor); // Vista: Need to draw the window border explicitly !? if (theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6,16,0,0)) { CPen pen; pen.CreatePen(0, 1, m_crTooltipTextColor); CPen *pOP = pdc->SelectObject(&pen); pdc->MoveTo(rcWnd.left, rcWnd.top); pdc->LineTo(rcWnd.right - 1, rcWnd.top); pdc->LineTo(rcWnd.right - 1, rcWnd.bottom - 1); pdc->LineTo(rcWnd.left, rcWnd.bottom - 1); pdc->LineTo(rcWnd.left, rcWnd.top); pdc->SelectObject(pOP); pen.DeleteObject(); } } int iOldBkMode = 0; if ((hTheme && !bUseEmbeddedThemeFonts) || (hTheme == NULL && iOldBkColor != -1)) iOldBkMode = pdc->SetBkMode(TRANSPARENT); CPoint ptText(pNMCD->nmcd.rc.left, pNMCD->nmcd.rc.top); iPos = 0; while (iPos != -1) { CString strLine = GetNextString(strText, _T('\n'), iPos); int iColon = bAutoFormatText ? strLine.Find(_T(':')) : -1; CRect rcDT; if (!bShowFileIcon || (unsigned)iPos > (unsigned)iCaptionEnd + strLine.GetLength()) rcDT.SetRect(ptText.x, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight); else rcDT.SetRect(ptText.x + iIconDrawingWidth, ptText.y, ptText.x + iMaxCol1Width, ptText.y + iTextHeight); if (iColon != -1) { // don't draw empty <col1> strings (they are still handy to use for skipping the <col1> space) if (iColon > 0) { if (hTheme && bUseEmbeddedThemeFonts) DrawThemeText(hTheme, pdc->m_hDC, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, iColon + 1, m_dwCol1DrawTextFlags, 0, &rcDT); else { CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL; pdc->DrawText(strLine, iColon + 1, &rcDT, m_dwCol1DrawTextFlags); if (pOldFont) pdc->SelectObject(pOldFont); } } LPCTSTR pszCol2 = (LPCTSTR)strLine + iColon + 1; while (_istspace((_TUCHAR)*pszCol2)) pszCol2++; if (*pszCol2 != _T('\0')) { rcDT.left = ptText.x + iMaxCol1Width + iMiddleMargin; rcDT.right = rcDT.left + iMaxCol2Width; if (hTheme && bUseEmbeddedThemeFonts) DrawThemeText(hTheme, pdc->m_hDC, TTP_STANDARD, TTSS_NORMAL, pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, m_dwCol2DrawTextFlags, 0, &rcDT); else pdc->DrawText(pszCol2, ((LPCTSTR)strLine + strLine.GetLength()) - pszCol2, &rcDT, m_dwCol2DrawTextFlags); } ptText.y += iTextHeight; } else if (bShowFileIcon && iPos <= iCaptionEnd && iPos == strLine.GetLength() + 1){ // first line on special fileicon tab - draw icon and bold filename if (hTheme && bUseEmbeddedThemeFonts) DrawThemeText(hTheme, pdc->m_hDC, m_bCol1Bold ? TTP_STANDARDTITLE : TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), m_dwCol1DrawTextFlags, 0, &CRect(ptText.x + iIconDrawingWidth, ptText.y, ptText.x + iMaxSingleLineWidth, ptText.y + iTextHeight)); else { CFont* pOldFont = m_bCol1Bold ? pdc->SelectObject(&m_fontBold) : NULL; pdc->DrawText(strLine, CRect(ptText.x + iIconDrawingWidth, ptText.y, ptText.x + iMaxSingleLineWidth, ptText.y + iTextHeight), m_dwCol1DrawTextFlags); if (pOldFont) pdc->SelectObject(pOldFont); } ptText.y += iTextHeight; int iImage = (int) theApp.GetFileTypeSystemImageIdx(strLine, -1, true); if (theApp.GetBigSystemImageList() != NULL) { int iPosY = rcDT.top; if (iCaptionHeight > iIconHeight) iPosY += (iCaptionHeight - iIconHeight) / 2; ::ImageList_Draw(theApp.GetBigSystemImageList(), iImage, pdc->GetSafeHdc(), ptText.x, iPosY, ILD_TRANSPARENT); } } else { bool bIsBrHeadLine = false; if (bAutoFormatText && (strLine.Compare(_T("<br>")) == 0 || (bIsBrHeadLine = strLine.Compare(_T("<br_head>")) == 0) == true)){ CPen pen; pen.CreatePen(0, 1, m_crTooltipTextColor); CPen *pOP = pdc->SelectObject(&pen); if (bIsBrHeadLine) ptText.y = iCaptionHeight; pdc->MoveTo(ptText.x, ptText.y + ((iTextHeight - 2) / 2)); pdc->LineTo(ptText.x + iMaxSingleLineWidth, ptText.y + ((iTextHeight - 2) / 2)); ptText.y += iTextHeight; pdc->SelectObject(pOP); pen.DeleteObject(); } else{ if (hTheme && bUseEmbeddedThemeFonts) { CRect rcLine(ptText.x, ptText.y, 32767, 32767); DrawThemeText(hTheme, pdc->m_hDC, TTP_STANDARD, TTSS_NORMAL, strLine, strLine.GetLength(), DT_EXPANDTABS | m_dwCol2DrawTextFlags, 0, &rcLine); ptText.y += iTextHeight; } else { // Text is written in the currently selected font. If 'nTabPositions' is 0 and 'lpnTabStopPositions' is NULL, // tabs are expanded to eight times the average character width. CSize siz; if (strLine.IsEmpty()) // Win98: To draw an empty line we need to output at least a space. siz = pdc->TabbedTextOut(ptText.x, ptText.y, _T(" "), 1, NULL, 0); else siz = pdc->TabbedTextOut(ptText.x, ptText.y, strLine, strLine.GetLength(), NULL, 0); ptText.y += siz.cy + iLineHeightOff; } } } } if (iOldBkColor != -1) pdc->SetBkColor(iOldBkColor); if (hTheme && !bUseEmbeddedThemeFonts) pdc->SetBkMode(iOldBkMode); } if (pOldDCFont) pdc->SelectObject(pOldDCFont); if (hTheme) CloseThemeData(hTheme); }
BOOL CKademliaWnd::OnInitDialog() { CResizableDialog::OnInitDialog(); InitWindowStyles(this); m_contactListCtrl->Init(); m_kadLookupGraph->Init(); searchList->Init(); // Initalize Toolbar CRect rcBtn1; rcBtn1.top = 5; rcBtn1.left = WND1_BUTTON_XOFF; rcBtn1.right = rcBtn1.left + WND1_BUTTON_WIDTH + WND1_NUM_BUTTONS*DFLT_TOOLBAR_BTN_WIDTH; rcBtn1.bottom = rcBtn1.top + WND1_BUTTON_HEIGHT; m_pbtnWnd->Init(false); m_pbtnWnd->MoveWindow(&rcBtn1); SetAllIcons(); // Vista: Remove the TBSTYLE_TRANSPARENT to avoid flickering (can be done only after the toolbar was initially created with TBSTYLE_TRANSPARENT !?) m_pbtnWnd->ModifyStyle((theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6, 16, 0, 0)) ? TBSTYLE_TRANSPARENT : 0, TBSTYLE_TOOLTIPS); m_pbtnWnd->SetExtendedStyle(m_pbtnWnd->GetExtendedStyle() | TBSTYLE_EX_MIXEDBUTTONS); TBBUTTON atb1[1+WND1_NUM_BUTTONS] = {0}; atb1[0].iBitmap = 0; atb1[0].idCommand = IDC_KADICO1; atb1[0].fsState = TBSTATE_ENABLED; atb1[0].fsStyle = BTNS_BUTTON | BTNS_SHOWTEXT; atb1[0].iString = -1; atb1[1].iBitmap = 0; atb1[1].idCommand = MP_VIEW_KADCONTACTS; atb1[1].fsState = TBSTATE_ENABLED; atb1[1].fsStyle = BTNS_BUTTON | BTNS_CHECKGROUP | BTNS_AUTOSIZE; atb1[1].iString = -1; atb1[2].iBitmap = 1; atb1[2].idCommand = MP_VIEW_KADLOOKUP; atb1[2].fsState = TBSTATE_ENABLED; atb1[2].fsStyle = BTNS_BUTTON | BTNS_CHECKGROUP | BTNS_AUTOSIZE; atb1[2].iString = -1; m_pbtnWnd->AddButtons(_countof(atb1), atb1); TBBUTTONINFO tbbi = {0}; tbbi.cbSize = sizeof tbbi; tbbi.dwMask = TBIF_SIZE | TBIF_BYINDEX; tbbi.cx = WND1_BUTTON_WIDTH; m_pbtnWnd->SetButtonInfo(0, &tbbi); // 'GetMaxSize' does not work properly under: // - Win98SE with COMCTL32 v5.80 // - Win2000 with COMCTL32 v5.81 // The value returned by 'GetMaxSize' is just couple of pixels too small so that the // last toolbar button is nearly not visible at all. // So, to circumvent such problems, the toolbar control should be created right with // the needed size so that we do not really need to call the 'GetMaxSize' function. // Although it would be better to call it to adapt for system metrics basically. if (theApp.m_ullComCtrlVer > MAKEDLLVERULL(5,81,0,0)) { CSize size; m_pbtnWnd->GetMaxSize(&size); CRect rc; m_pbtnWnd->GetWindowRect(&rc); ScreenToClient(&rc); // the with of the toolbar should already match the needed size (see comment above) ASSERT( size.cx == rc.Width() ); m_pbtnWnd->MoveWindow(rc.left, rc.top, size.cx, rc.Height()); } Localize(); AddAnchor(IDC_KADICO1, TOP_LEFT); AddAnchor(IDC_CONTACTLIST, TOP_LEFT, MIDDLE_RIGHT); AddAnchor(IDC_KAD_LOOKUPGRAPH, TOP_LEFT, MIDDLE_RIGHT); AddAnchor(IDC_KAD_HISTOGRAM, TOP_RIGHT, MIDDLE_RIGHT); AddAnchor(IDC_KADICO2, MIDDLE_LEFT); AddAnchor(IDC_SEARCHLIST, MIDDLE_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_FIREWALLCHECKBUTTON, TOP_RIGHT); AddAnchor(IDC_KADCONNECT, TOP_RIGHT); AddAnchor(IDC_KADSEARCHLAB, MIDDLE_LEFT); AddAnchor(IDC_BSSTATIC, TOP_RIGHT); AddAnchor(IDC_BOOTSTRAPBUTTON, TOP_RIGHT); AddAnchor(IDC_BOOTSTRAPPORT, TOP_RIGHT); AddAnchor(IDC_BOOTSTRAPIP, TOP_RIGHT); AddAnchor(IDC_BOOTSTRAPURL, TOP_RIGHT); AddAnchor(IDC_SSTATIC4, TOP_RIGHT); AddAnchor(IDC_SSTATIC7, TOP_RIGHT); AddAnchor(IDC_NODESDATLABEL, TOP_RIGHT); AddAnchor(IDC_RADCLIENTS, TOP_RIGHT); AddAnchor(IDC_RADIP, TOP_RIGHT); AddAnchor(IDC_RADNODESURL, TOP_RIGHT); searchList->UpdateKadSearchCount(); m_contactListCtrl->UpdateKadContactCount(); if (thePrefs.GetUseAutocompletion()){ m_pacONBSIPs = new CCustomAutoComplete(); m_pacONBSIPs->AddRef(); if (m_pacONBSIPs->Bind(::GetDlgItem(m_hWnd, IDC_BOOTSTRAPIP), ACO_UPDOWNKEYDROPSLIST | ACO_AUTOSUGGEST | ACO_FILTERPREFIXES )) m_pacONBSIPs->LoadList(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + ONBOOTSTRAP_STRINGS_PROFILE); } CheckDlgButton(IDC_RADCLIENTS,1); ShowLookupGraph(false); return true; }
LRESULT CToolbarWnd::OnInitDialog(WPARAM /*wParam*/, LPARAM /*lParam*/) { Default(); InitWindowStyles(this); //(void)m_sizeDefault; // not yet set CRect sizeDefault; GetWindowRect(&sizeDefault); CRect rcBorders(4, 4, 4, 4); SetBorders(&rcBorders); m_szFloat.cx = sizeDefault.Width() + rcBorders.left + rcBorders.right + GetSystemMetrics(SM_CXEDGE) * 2; m_szFloat.cy = sizeDefault.Height() + rcBorders.top + rcBorders.bottom + GetSystemMetrics(SM_CYEDGE) * 2; m_szMRU = m_szFloat; UpdateData(FALSE); // Initalize the toolbar CImageList iml; int nFlags= theApp.m_iDfltImageListColorFlags; // older Windows versions imageslists cannot create monochrome (disabled) icons which have alpha support // so we have to take care of this ourself bool bNeedMonoIcons = thePrefs.GetWindowsVersion() < _WINVER_VISTA_ && nFlags != ILC_COLOR4; nFlags |= ILC_MASK; iml.Create(16, 16, nFlags, 1, 1); iml.Add(CTempIconLoader(_T("FILEPRIORITY"))); iml.Add(CTempIconLoader(_T("PAUSE"))); iml.Add(CTempIconLoader(_T("STOP"))); iml.Add(CTempIconLoader(_T("RESUME"))); iml.Add(CTempIconLoader(_T("DELETE"))); iml.Add(CTempIconLoader(_T("OPENFILE"))); iml.Add(CTempIconLoader(_T("PREVIEW"))); iml.Add(CTempIconLoader(_T("FILEINFO"))); iml.Add(CTempIconLoader(_T("FILECOMMENTS"))); iml.Add(CTempIconLoader(_T("ED2KLINK"))); iml.Add(CTempIconLoader(_T("CATEGORY"))); iml.Add(CTempIconLoader(_T("CLEARCOMPLETE"))); iml.Add(CTempIconLoader(_T("KadFileSearch"))); iml.Add(CTempIconLoader(_T("Search"))); if (bNeedMonoIcons) { CImageList iml2; iml2.Create(16, 16, nFlags, 1, 1); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("FILEPRIORITY")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("PAUSE")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("STOP")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("RESUME")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("DELETE")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("OPENFILE")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("PREVIEW")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("FILEINFO")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("FILECOMMENTS")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("ED2KLINK")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("CATEGORY")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("CLEARCOMPLETE")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("KadFileSearch")))); VERIFY(AddIconGrayscaledToImageList(iml2, CTempIconLoader(_T("Search")))); CImageList* pImlOld = m_btnBar->SetDisabledImageList(&iml2); iml2.Detach(); if (pImlOld) pImlOld->DeleteImageList(); } CImageList* pImlOld = m_btnBar->SetImageList(&iml); iml.Detach(); if (pImlOld) pImlOld->DeleteImageList(); m_btnBar->ModifyStyle((theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6, 16, 0, 0)) ? TBSTYLE_TRANSPARENT : 0, 0); m_btnBar->SetMaxTextRows(0); FillToolbar(); return TRUE; }
HRESULT STDAPICALLTYPE DllGetVersion( IN HMODULE hModule, OUT DLLVERSIONINFO* lpDVI ) { if( hModule == NULL || ::IsBadReadPtr( lpDVI, sizeof( DLLVERSIONINFO* ) ) ) { ASSERT_RETURN( S_FALSE ); } CONST DWORD cbSize = lpDVI->cbSize; if( #ifdef DLLVERSIONINFO2 ( #endif cbSize != sizeof( DLLVERSIONINFO ) #ifdef DLLVERSIONINFO2 && cbSize != sizeof( DLLVERSIONINFO2 ) ) #endif || ::IsBadWritePtr( lpDVI, cbSize ) ) { ASSERT_RETURN( S_FALSE ); } ::ZeroMemory( lpDVI, cbSize ); lpDVI->cbSize = cbSize; CFileVersionInfo fvi; if( fvi.Open( hModule ) ) { VS_FIXEDFILEINFO vsffi = fvi.GetVSFFI(); if( vsffi.dwFileType == VFT_DLL || vsffi.dwFileType == VFT_STATIC_LIB ) { switch( vsffi.dwFileOS ) { case VOS__WINDOWS32: case VOS_NT_WINDOWS32: lpDVI->dwPlatformID = DLLVER_PLATFORM_WINDOWS; break; case VOS_NT: lpDVI->dwPlatformID = DLLVER_PLATFORM_NT; break; default: return ( S_FALSE ); } lpDVI->dwMajorVersion = HIWORD( vsffi.dwFileVersionMS ); lpDVI->dwMinorVersion = LOWORD( vsffi.dwFileVersionMS ); lpDVI->dwBuildNumber = HIWORD( vsffi.dwFileVersionLS ); #ifdef DLLVERSIONINFO2 if( cbSize == sizeof( DLLVERSIONINFO2 ) ) { DLLVERSIONINFO2* lpDVI2 = (DLLVERSIONINFO2*)lpDVI; lpDVI2->ullVersion = MAKEDLLVERULL( lpDVI->dwMajorVersion, lpDVI->dwMinorVersion, lpDVI->dwBuildNumber , LOWORD( vsffi.dwFileVersionLS ) ); } #endif return ( S_OK ); } #ifdef _DEBUG else ASSERT( 0 ); #endif fvi.Close(); } return ( S_FALSE ); }
BOOL CIrcWnd::OnInitDialog() { CResizableDialog::OnInitDialog(); m_bConnected = false; m_bLoggedIn = false; m_pIrcMain = new CIrcMain(); m_pIrcMain->SetIRCWnd(this); UpdateFonts(&theApp.m_fontHyperText); InitWindowStyles(this); SetAllIcons(); m_wndInput.SetLimitText(MAX_IRC_MSG_LEN); if (theApp.m_fontChatEdit.m_hObject) { m_wndInput.SendMessage(WM_SETFONT, (WPARAM)theApp.m_fontChatEdit.m_hObject, FALSE); CRect rcEdit; m_wndInput.GetWindowRect(&rcEdit); ScreenToClient(&rcEdit); rcEdit.top -= 2; rcEdit.bottom += 2; m_wndInput.MoveWindow(&rcEdit, FALSE); } CRect rcSpl; m_wndNicks.GetWindowRect(rcSpl); ScreenToClient(rcSpl); rcSpl.left = rcSpl.right + SPLITTER_HORZ_MARGIN; rcSpl.right = rcSpl.left + SPLITTER_HORZ_WIDTH; m_wndSplitterHorz.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_IRC); AddAnchor(IDC_BN_IRCCONNECT, BOTTOM_LEFT); AddAnchor(IDC_CLOSECHAT, BOTTOM_LEFT); AddAnchor(IDC_CHATSEND, BOTTOM_RIGHT); AddAnchor(m_wndFormat, BOTTOM_LEFT); AddAnchor(m_wndInput, BOTTOM_LEFT, BOTTOM_RIGHT); AddAnchor(m_wndNicks, TOP_LEFT, BOTTOM_LEFT); AddAnchor(m_wndChanList, TOP_LEFT, BOTTOM_RIGHT); AddAnchor(m_wndChanSel, TOP_LEFT, TOP_RIGHT); AddAnchor(m_wndSplitterHorz, TOP_LEFT, BOTTOM_LEFT); // Vista: Remove the TBSTYLE_TRANSPARENT to avoid flickering (can be done only after the toolbar was initially created with TBSTYLE_TRANSPARENT !?) m_wndFormat.ModifyStyle((theApp.m_ullComCtrlVer >= MAKEDLLVERULL(6, 16, 0, 0)) ? TBSTYLE_TRANSPARENT : 0, TBSTYLE_TOOLTIPS); m_wndFormat.SetExtendedStyle(m_wndFormat.GetExtendedStyle() | TBSTYLE_EX_MIXEDBUTTONS); TBBUTTON atb[5] = {0}; atb[0].iBitmap = 0; atb[0].idCommand = IDC_SMILEY; atb[0].fsState = TBSTATE_ENABLED; atb[0].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; atb[0].iString = -1; atb[1].iBitmap = 1; atb[1].idCommand = IDC_BOLD; atb[1].fsState = TBSTATE_ENABLED; atb[1].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; atb[1].iString = -1; atb[2].iBitmap = 2; atb[2].idCommand = IDC_UNDERLINE; atb[2].fsState = TBSTATE_ENABLED; atb[2].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; atb[2].iString = -1; atb[3].iBitmap = 3; atb[3].idCommand = IDC_COLOUR; atb[3].fsState = TBSTATE_ENABLED; atb[3].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; atb[3].iString = -1; atb[4].iBitmap = 4; atb[4].idCommand = IDC_RESET; atb[4].fsState = TBSTATE_ENABLED; atb[4].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE; atb[4].iString = -1; m_wndFormat.AddButtons(_countof(atb), atb); CSize size; m_wndFormat.GetMaxSize(&size); ::SetWindowPos(m_wndFormat, NULL, 0, 0, size.cx, size.cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); int iPosStatInit = rcSpl.left; int iPosStatNew = thePrefs.GetSplitterbarPositionIRC(); if (iPosStatNew > SPLITTER_HORZ_RANGE_MAX) iPosStatNew = SPLITTER_HORZ_RANGE_MAX; else if (iPosStatNew < SPLITTER_HORZ_RANGE_MIN) iPosStatNew = SPLITTER_HORZ_RANGE_MIN; rcSpl.left = iPosStatNew; rcSpl.right = iPosStatNew + SPLITTER_HORZ_WIDTH; if (iPosStatNew != iPosStatInit) { m_wndSplitterHorz.MoveWindow(rcSpl); DoResize(iPosStatNew - iPosStatInit); } Localize(); m_wndChanList.Init(); m_wndNicks.Init(); m_wndNicks.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER); m_wndChanSel.Init(); OnBackcolor(); // Design Settings [eWombat/Stulle] - Max OnChatTextChange(); return true; }
void CMuleToolbarCtrl::SetAllButtonsWidth() { if (GetButtonCount() == 0) return; if (m_eLabelType == LabelsBelow) { CDC *pDC = GetDC(); CFont *pFnt = GetFont(); CFont *pOldFnt = pDC->SelectObject(pFnt); CRect r(0,0,0,0); // calculate the max. possible button-size int iCalcSize = 0; for (int i = 0; i < m_buttoncount ; i++) { if (!IsButtonHidden(IDC_TOOLBARBUTTON + i)) { pDC->DrawText(TBStrings[i], -1, r, DT_SINGLELINE | DT_CALCRECT); if (r.Width() > iCalcSize) iCalcSize = r.Width(); } } iCalcSize += 10; pDC->SelectObject(pOldFnt); ReleaseDC(pDC); if (!thePrefs.GetUseReBarToolbar()) { GetClientRect(&r); int bc = GetButtonCount(); if (bc == 0) bc = 1; int iMaxPossible = r.Width() / bc; // if the buttons are to big, reduze their size if (iCalcSize > iMaxPossible) iCalcSize = iMaxPossible; } else { if (iCalcSize < 56) iCalcSize = 56; else if (iCalcSize > 72) iCalcSize = 72; } SetButtonWidth(iCalcSize, iCalcSize); } else { int iSmallIconsButtonHeight; if (theApp.m_ullComCtrlVer < MAKEDLLVERULL(6, 0, 0, 0)) { // Win98,WinME,Win2000: Comtrl32 prior to 6.0 cannot make a toolbar smaller than 22 pixels // in height and if it gets larger than 22 pixels the icons do not get centered vertically. iSmallIconsButtonHeight = 22; } else iSmallIconsButtonHeight = GetSystemMetrics(SM_CYSCREEN) <= 600 ? 16 : 28; if (m_eLabelType == NoLabels) { DWORD dwSize = GetButtonSize(); int iFixedButtonWidth; int iFixedButtonHeight = HIWORD(dwSize); if (m_sizBtnBmp.cx == 16) { iFixedButtonWidth = 28; iFixedButtonHeight = iSmallIconsButtonHeight; } else { iFixedButtonWidth = 56; } // it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize' SetButtonWidth(iFixedButtonWidth, iFixedButtonWidth); SetButtonSize(CSize(iFixedButtonWidth, iFixedButtonHeight)); } else { int iFixedButtonHeight = 0; if (m_sizBtnBmp.cx == 16) iFixedButtonHeight = iSmallIconsButtonHeight; // it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize' SetButtonWidth(0, 0); SetButtonSize(CSize(0, iFixedButtonHeight)); } } }