HRESULT DrawThemesPart(HDC hDC, int iPartId, int iStateId, LPCSTR uiPartNameID, LPRECT prcBox) { if(!IsWinXP()) return E_FAIL; HINSTANCE hDll=LoadLibrary(CString((LPCTSTR)IDS_UTIL_UXTHEME)); // 'UxTheme.dll' if(!hDll) return E_FAIL; BOOL (PASCAL* pfnIsThemeActive)(); UINT hTheme=0; (FARPROC&)pfnIsThemeActive=GetProcAddress(hDll,IDS_UTIL_THEMEACT); // 'IsThemeActive' HRESULT hResult=E_FAIL; if(pfnIsThemeActive && pfnIsThemeActive()) { CString sPartName((LPCTSTR)uiPartNameID); if(sPartName.GetLength()>0) { WCHAR swPartName[WPART_NAME_SZ]; #if !defined(UNICODE) && !defined(_UNICODE) MultiByteToWideChar(CP_ACP,0,(LPCSTR)sPartName,-1,swPartName,sizeof(swPartName)/sizeof(WCHAR)); #else _tcscpy(swPartName, sPartName.GetBuffer()); #endif UINT (PASCAL* pfnOpenThemeData)(HWND hwnd, LPCWSTR pszClassList); (FARPROC&)pfnOpenThemeData=GetProcAddress(hDll,IDS_UTIL_THEMEOPN);// 'OpenThemeData' if(pfnOpenThemeData && (hTheme=pfnOpenThemeData(NULL, swPartName))!=0) { UINT (PASCAL* pfnDrawThemeBackground)(UINT htheme,HDC hdc,int iPartID,int iStateID,const RECT* prcBx,const RECT* prcClip); (FARPROC&)pfnDrawThemeBackground=GetProcAddress(hDll,IDS_UTIL_THEMEBCKG); // 'DrawThemeBackground' if(pfnDrawThemeBackground) hResult=pfnDrawThemeBackground(hTheme, hDC, iPartId, iStateId, prcBox, NULL); } } } FreeLibrary(hDll); return hResult; }
// Fix to avoid black corners temorarily artifact void Ctrl::Create0(Ctrl::CreateBox *cr) { GuiLock __; ASSERT(IsMainThread()); LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << BeginIndent); ASSERT(!IsChild() && !IsOpen()); Rect r = GetRect(); AdjustWindowRectEx(r, cr->style, FALSE, cr->exstyle); isopen = true; top = new Top; ASSERT(!cr->parent || IsWindow(cr->parent)); cr->style &= ~WS_VISIBLE; if(!IsWinXP()) cr->dropshadow = false; #ifdef PLATFORM_WINCE if(parent) top->hwnd = CreateWindowExW(cr->exstyle, cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : cr->dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", cr->style, 0, 0, 0, 0, cr->parent, NULL, hInstance, this); else top->hwnd = CreateWindowW(L"UPP-CLASS-W", L"", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, cr->parent, NULL, hInstance, this); #else if(IsWinNT() && (!cr->parent || IsWindowUnicode(cr->parent))) top->hwnd = CreateWindowExW(cr->exstyle, cr->savebits ? cr->dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : cr->dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", cr->style, 0, 0, 0, 0, cr->parent, NULL, hInstance, this); else top->hwnd = CreateWindowEx(cr->exstyle, cr->savebits ? cr->dropshadow ? "UPP-CLASS-SB-DS-A" : "UPP-CLASS-SB-A" : cr->dropshadow ? "UPP-CLASS-DS-A" : "UPP-CLASS-A", "", cr->style, 0, 0, 0, 0, cr->parent, NULL, hInstance, this); #endif inloop = false; ASSERT(top->hwnd); ::MoveWindow(top->hwnd, r.left, r.top, r.Width(), r.Height(), false); // To avoid "black corners" artifact effect ::ShowWindow(top->hwnd, visible ? cr->show : SW_HIDE); // ::UpdateWindow(hwnd); StateH(OPEN); LLOG(EndIndent << "//Ctrl::Create in " <<UPP::Name(this)); RegisterDragDrop(top->hwnd, (LPDROPTARGET) (top->dndtgt = NewUDropTarget(this))); CancelMode(); RefreshLayoutDeep(); }
void Ctrl::Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow) { GuiLock __; ASSERT_(IsMainThread(), "Window creation can only happen in the main thread"); LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <<UPP::Name(this) << LOG_BEGIN); ASSERT(!IsChild() && !IsOpen()); Rect r = GetRect(); AdjustWindowRectEx(r, style, FALSE, exstyle); isopen = true; top = new Top; ASSERT(!parent || IsWindow(parent)); style &= ~WS_VISIBLE; if(!IsWinXP()) dropshadow = false; #ifdef PLATFORM_WINCE if(parent) top->hwnd = CreateWindowExW(exstyle, savebits ? dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", style, 0, 0, 0, 0, parent, NULL, hInstance, this); else top->hwnd = CreateWindowW(L"UPP-CLASS-W", L"", WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, hInstance, this); #else if(IsWinNT() && (!parent || IsWindowUnicode(parent))) top->hwnd = CreateWindowExW(exstyle, savebits ? dropshadow ? L"UPP-CLASS-SB-DS-W" : L"UPP-CLASS-SB-W" : dropshadow ? L"UPP-CLASS-DS-W" : L"UPP-CLASS-W", L"", style, 0, 0, 0, 0, parent, NULL, hInstance, this); else top->hwnd = CreateWindowEx(exstyle, savebits ? dropshadow ? "UPP-CLASS-SB-DS-A" : "UPP-CLASS-SB-A" : dropshadow ? "UPP-CLASS-DS-A" : "UPP-CLASS-A", "", style, 0, 0, 0, 0, parent, NULL, hInstance, this); #endif inloop = false; ASSERT(top->hwnd); ::MoveWindow(top->hwnd, r.left, r.top, r.Width(), r.Height(), false); // To avoid "black corners" artifact effect ::ShowWindow(top->hwnd, visible ? show : SW_HIDE); // ::UpdateWindow(hwnd); StateH(OPEN); LLOG(LOG_END << "//Ctrl::Create in " <<UPP::Name(this)); RegisterDragDrop(top->hwnd, (LPDROPTARGET) (top->dndtgt = NewUDropTarget(this))); CancelMode(); RefreshLayoutDeep(); }
void CWinAppEx::UpdateSystemParameters() { m_info.cbSize = sizeof( NONCLIENTMETRICS ); VERIFY( ::SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( m_info ), &m_info, 0 ) ); if ( IsWin50() ) { VERIFY( ::SystemParametersInfo( SPI_GETMENUANIMATION, 0, &m_bMenuAnimation, 0 ) ); if ( IsWin2K() ) { VERIFY( ::SystemParametersInfo( SPI_GETMENUUNDERLINES, 0, &m_bMenuUnderlines, 0 ) ); VERIFY( ::SystemParametersInfo( SPI_GETUIEFFECTS, 0, &m_bUIEffects, 0 ) ); VERIFY( ::SystemParametersInfo( SPI_GETMENUFADE, 0, &m_bMenuFade, 0 ) ); if ( IsWinXP() ) { VERIFY( ::SystemParametersInfo( SPI_GETFLATMENU, 0, &m_bFlatMenu, 0 ) ); } } } }
BOOL TShellExtDlg::EvCommand(WORD wNotifyCode, WORD wID, LPARAM hWndCtl) { switch (wID) { case IDSHELLEXT_OK: case IDSHELLEXT_CANCEL: if (IsWinXP() && !::IsUserAnAdmin()) { TMsgBox(this).Exec(GetLoadStr(IDS_REQUIRE_ADMIN)); return TRUE; } if (RegisterShellExt(wID == IDSHELLEXT_OK ? TRUE : FALSE) == FALSE) { TMsgBox(this).Exec("ShellExt Error"); } ReflectStatus(); if (wID == IDSHELLEXT_OK) EndDialog(wID); return TRUE; case IDOK: case IDCANCEL: EndDialog(wID); return TRUE; } return FALSE; }
void Ctrl::InitWin32(HINSTANCE hInstance) { GuiLock __; LLOG("InitWin32"); InstallPanicMessageBox(&Win32PanicMessageBox); // RLOGBLOCK("Ctrl::InitWin32"); sMainThreadId = GetCurrentThreadId(); #define ILOG(x) // RLOG(x) Ctrl::hInstance = hInstance; ILOG("RegisterClassW"); #ifndef PLATFORM_WINCE if(IsWinNT()) #endif { WNDCLASSW wc; Zero(wc); wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL; wc.lpszClassName = L"UPP-CLASS-W"; RegisterClassW(&wc); wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L"UPP-CLASS-DS-W"; RegisterClassW(&wc); wc.style = CS_SAVEBITS|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L"UPP-CLASS-SB-W"; RegisterClassW(&wc); wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS; wc.lpszClassName = L"UPP-CLASS-SB-DS-W"; RegisterClassW(&wc); } ILOG("RegisterClassA"); WNDCLASS wc; Zero(wc); wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL; wc.lpszClassName = L_("UPP-CLASS-A"); RegisterClass(&wc); if(IsWinXP()) { wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L_("UPP-CLASS-DS-A"); RegisterClass(&wc); } wc.style = CS_SAVEBITS|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW; wc.lpszClassName = L_("UPP-CLASS-SB-A"); RegisterClass(&wc); if(IsWinXP()) { wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS; wc.lpszClassName = L_("UPP-CLASS-SB-DS-A"); RegisterClass(&wc); } wc.style = 0; wc.lpszClassName = L_("UPP-TIMER"); wc.hCursor = NULL; wc.lpfnWndProc = &Ctrl::UtilityProc; RegisterClass(&wc); ILOG("InitTimer"); InitTimer(); ILOG("SetTimer"); utilityHWND = CreateWindow(L_("UPP-TIMER"), L_(""), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); SetTimer(utilityHWND, 1, 10, NULL); ILOG("Windows"); Windows(); //?? TRC: what's the use of this? ReSkin(); OleInitialize(NULL); /* TRC 05/11/14: moved to GuiSleep to avoid thread creation in OCX DllMain DWORD dummy; OverwatchThread = CreateThread(NULL, 0x100000, Win32OverwatchThread, NULL, 0, &dummy); ExitLoopEvent().Wait(); */ // TRC 05/11/18: pSetLayeredWindowAttributes moved to GLOBAL_VAR (see below) to make OCX initialization simpler Csizeinit(); #undef ILOG if(IsWin7()) GlobalBackPaint(); }
bool CWinAppEx::GetFlatMenu() const { ASSERT( IsWinXP() ); return ( m_bUIEffects && m_bFlatMenu ); }
//---------------------------------------------------------------------------------------------------------- BOOL IsThemeActiveXP() { return (IsWinXP() && IsThemeActiveEx())?TRUE:FALSE; }
BOOL CPPageVideo::OnInitDialog() { __super::OnInitDialog(); SetHandCursor(m_hWnd, IDC_AUDRND_COMBO); SetHandCursor(m_hWnd, IDC_BUTTON1); AppSettings& s = AfxGetAppSettings(); CRenderersSettings& renderersSettings = s.m_RenderersSettings; m_iDSVideoRendererType = s.iDSVideoRendererType; m_iRMVideoRendererType = s.iRMVideoRendererType; m_iQTVideoRendererType = s.iQTVideoRendererType; m_iAPSurfaceUsage = renderersSettings.iAPSurfaceUsage; m_iDX9Resizer = renderersSettings.iDX9Resizer; m_fVMRMixerMode = renderersSettings.fVMRMixerMode; m_fVMRMixerYUV = renderersSettings.fVMRMixerYUV; m_fVMR9AlterativeVSync = renderersSettings.m_AdvRendSets.fVMR9AlterativeVSync; m_fD3DFullscreen = s.fD3DFullscreen; m_iEvrBuffers.Format(L"%d", renderersSettings.iEvrBuffers); m_fResetDevice = s.m_RenderersSettings.fResetDevice; IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION); if (pD3D) { TCHAR strGUID[50] = {0}; CString cstrGUID; CString d3ddevice_str; CStringArray adapterList; D3DADAPTER_IDENTIFIER9 adapterIdentifier; for (UINT adp = 0; adp < pD3D->GetAdapterCount(); ++adp) { if (SUCCEEDED(pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier))) { d3ddevice_str = adapterIdentifier.Description; d3ddevice_str += _T(" - "); d3ddevice_str += adapterIdentifier.DeviceName; cstrGUID.Empty(); if (::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) { cstrGUID = strGUID; } if (cstrGUID.GetLength() > 0) { boolean m_find = false; for (INT_PTR i = 0; (!m_find) && (i < m_D3D9GUIDNames.GetCount()); i++) { if (m_D3D9GUIDNames.GetAt(i) == cstrGUID) { m_find = true; } } if (!m_find) { m_iD3D9RenderDeviceCtrl.AddString(d3ddevice_str); m_D3D9GUIDNames.Add(cstrGUID); if (renderersSettings.D3D9RenderDevice == cstrGUID) { m_iD3D9RenderDevice = m_iD3D9RenderDeviceCtrl.GetCount() - 1; } } } } } pD3D->Release(); } CorrectComboListWidth(m_iD3D9RenderDeviceCtrl); auto addRenderer = [&](int nID) { CString sName; switch (nID) { case VIDRNDT_DS_DEFAULT: sName = ResStr(IDS_PPAGE_OUTPUT_SYS_DEF); break; case VIDRNDT_DS_OVERLAYMIXER: if (!IsWinXP()) { return; } sName = ResStr(IDS_PPAGE_OUTPUT_OVERLAYMIXER); break; case VIDRNDT_DS_VMR7WINDOWED: sName = ResStr(IDS_PPAGE_OUTPUT_VMR7WINDOWED); break; case VIDRNDT_DS_VMR9WINDOWED: sName = ResStr(IDS_PPAGE_OUTPUT_VMR9WINDOWED); break; case VIDRNDT_DS_VMR7RENDERLESS: sName = ResStr(IDS_PPAGE_OUTPUT_VMR7RENDERLESS); break; case VIDRNDT_DS_VMR9RENDERLESS: sName = ResStr(IDS_PPAGE_OUTPUT_VMR9RENDERLESS); break; case VIDRNDT_DS_DXR: sName = ResStr(IDS_PPAGE_OUTPUT_DXR); break; case VIDRNDT_DS_NULL_COMP: sName = ResStr(IDS_PPAGE_OUTPUT_NULL_COMP); break; case VIDRNDT_DS_NULL_UNCOMP: sName = ResStr(IDS_PPAGE_OUTPUT_NULL_UNCOMP); break; case VIDRNDT_DS_EVR: sName = ResStr(IDS_PPAGE_OUTPUT_EVR); break; case VIDRNDT_DS_EVR_CUSTOM: sName = ResStr(IDS_PPAGE_OUTPUT_EVR_CUSTOM); break; case VIDRNDT_DS_MADVR: sName = ResStr(IDS_PPAGE_OUTPUT_MADVR); break; case VIDRNDT_DS_SYNC: sName = ResStr(IDS_PPAGE_OUTPUT_SYNC); break; default: ASSERT(FALSE); return; } if (!IsRenderTypeAvailable(nID)) { sName.AppendFormat(L" %s", ResStr(IDS_PPAGE_OUTPUT_UNAVAILABLE)); } m_iDSVideoRendererTypeCtrl.SetItemData(m_iDSVideoRendererTypeCtrl.AddString(sName), nID); }; CComboBox& m_iDSVRTC = m_iDSVideoRendererTypeCtrl; m_iDSVRTC.SetRedraw(FALSE); addRenderer(VIDRNDT_DS_DEFAULT); addRenderer(VIDRNDT_DS_OVERLAYMIXER); addRenderer(VIDRNDT_DS_VMR7WINDOWED); addRenderer(VIDRNDT_DS_VMR9WINDOWED); addRenderer(VIDRNDT_DS_VMR7RENDERLESS); addRenderer(VIDRNDT_DS_VMR9RENDERLESS); addRenderer(VIDRNDT_DS_EVR); addRenderer(VIDRNDT_DS_EVR_CUSTOM); addRenderer(VIDRNDT_DS_SYNC); addRenderer(VIDRNDT_DS_DXR); addRenderer(VIDRNDT_DS_MADVR); addRenderer(VIDRNDT_DS_NULL_COMP); addRenderer(VIDRNDT_DS_NULL_UNCOMP); for (int i = 0; i < m_iDSVRTC.GetCount(); ++i) { if (m_iDSVideoRendererType == m_iDSVRTC.GetItemData(i)) { if (IsRenderTypeAvailable(m_iDSVideoRendererType)) { m_iDSVRTC.SetCurSel(i); m_iDSVideoRendererType_store = m_iDSVideoRendererType; } else { m_iDSVRTC.SetCurSel(0); } break; } } m_iDSVRTC.SetRedraw(TRUE); m_iDSVRTC.Invalidate(); m_iDSVRTC.UpdateWindow(); CComboBox& m_iQTVRTC = m_iQTVideoRendererTypeCtrl; m_iQTVRTC.SetItemData(m_iQTVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_SYS_DEF)), VIDRNDT_QT_DEFAULT); m_iQTVRTC.SetItemData(m_iQTVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR7RENDERLESS)), VIDRNDT_QT_DX7); m_iQTVRTC.SetItemData(m_iQTVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR9RENDERLESS)), VIDRNDT_QT_DX9); m_iQTVRTC.SetCurSel(m_iQTVideoRendererType); CorrectComboListWidth(m_iQTVRTC); CComboBox& m_iRMVRTC = m_iRMVideoRendererTypeCtrl; m_iRMVideoRendererTypeCtrl.SetItemData(m_iRMVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_SYS_DEF)), VIDRNDT_RM_DEFAULT); m_iRMVRTC.SetItemData(m_iRMVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR7RENDERLESS)), VIDRNDT_RM_DX7); m_iRMVRTC.SetItemData(m_iRMVRTC.AddString(ResStr(IDS_PPAGE_OUTPUT_VMR9RENDERLESS)), VIDRNDT_RM_DX9); m_iRMVRTC.SetCurSel(m_iRMVideoRendererType); CorrectComboListWidth(m_iRMVRTC); UpdateData(FALSE); CreateToolTip(); m_wndToolTip.AddTool(GetDlgItem(IDC_VIDRND_COMBO), L""); m_wndToolTip.AddTool(GetDlgItem(IDC_RMRND_COMBO), L""); m_wndToolTip.AddTool(GetDlgItem(IDC_QTRND_COMBO), L""); m_wndToolTip.AddTool(GetDlgItem(IDC_DX_SURFACE), L""); OnDSRendererChange(); OnRMRendererChange(); OnQTRendererChange(); OnSurfaceChange(); CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED); GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE); switch (m_iDSVideoRendererType) { case VIDRNDT_DS_VMR9RENDERLESS: case VIDRNDT_DS_EVR_CUSTOM: if (m_iD3D9RenderDeviceCtrl.GetCount() > 1) { GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE); CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED); if (m_iD3D9RenderDevice != -1) { CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE); } } break; default: GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE); GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE); } UpdateData(TRUE); return TRUE; // return TRUE unless you set the focus to a control }