| 216 | } |
| 217 | |
| 218 | STDMETHODIMP CProgressBarControl::CreateControlWindow(HWND hParent, const RECT *pRect) { |
| 219 | m_width = pRect->right - pRect->left; |
| 220 | m_height = pRect->bottom - pRect->top; |
| 221 | |
| 222 | if (m_innerHwnd) { |
| 223 | if (m_hwnd == hParent) { |
| 224 | // Just update the position |
| 225 | SetWindowPos( |
| 226 | m_innerHwnd, NULL, |
| 227 | pRect->left, pRect->top, |
| 228 | m_width, m_height, |
| 229 | SWP_NOZORDER | SWP_NOACTIVATE |
| 230 | ); |
| 231 | return S_OK; |
| 232 | } else { |
| 233 | // Parent changed, start over |
| 234 | DestroyControlWindow(); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | m_hwnd = hParent; |
| 239 | |
| 240 | // Bind to our manifest to ensure we get visual styles and marquee |
| 241 | ULONG_PTR cookie; |
| 242 | IsolationAwareStart(&cookie); |
| 243 | |
| 244 | // Load and init comctl (hopefully 6.0) |
| 245 | LoadLibrary(L"comctl32.dll"); |
| 246 | |
| 247 | INITCOMMONCONTROLSEX initComctl = {0}; |
| 248 | initComctl.dwSize = sizeof(initComctl); |
| 249 | initComctl.dwICC = ICC_PROGRESS_CLASS; |
| 250 | InitCommonControlsEx(&initComctl); |
| 251 | |
| 252 | // Create progress bar window |
| 253 | m_innerHwnd = CreateWindowEx( |
| 254 | WS_EX_CLIENTEDGE, |
| 255 | PROGRESS_CLASS, |
| 256 | NULL, |
| 257 | WS_CHILD | WS_VISIBLE, |
| 258 | 0, 0, |
| 259 | m_width, m_height, |
| 260 | m_hwnd, |
| 261 | NULL, |
| 262 | OWN_MODULE, |
| 263 | NULL |
| 264 | ); |
| 265 | IsolationAwareEnd(&cookie); |
| 266 | if (!m_innerHwnd) { |
| 267 | return E_FAIL; |
| 268 | } |
| 269 | |
| 270 | return put_Value(-1); |
| 271 | } |
| 272 | |
| 273 | STDMETHODIMP CProgressBarControl::DestroyControlWindow(void) { |
| 274 | if (m_innerHwnd) { |
no test coverage detected