MCPcopy Create free account
hub / github.com/Aleksoid1978/VideoRenderer / SetWindowPosition

Method SetWindowPosition

Source/VideoRenderer.cpp:1141–1215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1139}
1140
1141STDMETHODIMP CMpcVideoRenderer::SetWindowPosition(long Left, long Top, long Width, long Height)
1142{
1143 const CRect windowRect(Left, Top, Left + Width, Top + Height);
1144 if (windowRect == m_windowRect) {
1145 return S_OK;
1146 }
1147
1148 m_windowRect = windowRect;
1149
1150 CAutoLock cRendererLock(&m_RendererLock);
1151
1152 std::optional<bool> bFullScreenOpt;
1153
1154 if (!m_bIsD3DFullscreen) {
1155 auto hMon = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
1156 MONITORINFO mi = { mi.cbSize = sizeof(mi) };
1157 ::GetMonitorInfoW(hMon, &mi);
1158 const CRect rcMonitor(mi.rcMonitor);
1159 auto fullScreen = (m_windowRect.Width() == rcMonitor.Width() && m_windowRect.Height() == rcMonitor.Height());
1160 if (m_Sets.bExclusiveFS || m_bExclusiveScreen) {
1161 auto SwitchExclusiveScreen = [this] (bool set) {
1162 DLog(L"CMpcVideoRenderer::SetWindowPosition() : Switch {} Exclusive screen", set ? L"to" : L"from");
1163 m_bExclusiveScreen = set;
1164
1165 if (m_hWnd) {
1166 Init(m_VideoProcessor->Type() == VP_DX9 ? false : true);
1167 Redraw();
1168
1169 if (m_hWndParentMain) {
1170 PostMessageW(m_hWndParentMain, WM_SWITCH_FULLSCREEN, static_cast<WPARAM>(set), 0);
1171 }
1172 }
1173 };
1174
1175 if (!m_bExclusiveScreen && fullScreen) {
1176 SwitchExclusiveScreen(true);
1177 } else if (m_bExclusiveScreen && !fullScreen) {
1178 SwitchExclusiveScreen(false);
1179 }
1180 } else {
1181 if (!m_bFullScreen && fullScreen) {
1182 bFullScreenOpt = true;
1183 } else if (m_bFullScreen && !fullScreen) {
1184 bFullScreenOpt = false;
1185 }
1186 }
1187 }
1188
1189 if (m_hWndWindow && !m_bExclusiveScreen) {
1190 SetWindowPos(m_hWndWindow, nullptr, Left, Top, Width, Height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
1191 if (Left < 0) {
1192 m_windowRect.OffsetRect(-Left, 0);
1193 }
1194 if (Top < 0) {
1195 m_windowRect.OffsetRect(0, -Top);
1196 }
1197 }
1198

Callers

nothing calls this directly

Calls 4

DLogFunction · 0.85
SwitchFullScreenMethod · 0.80
TypeMethod · 0.45
SetWindowRectMethod · 0.45

Tested by

no test coverage detected