LRESULT CALLBACK Window::WndProc(HWND _hWnd, UINT message, WPARAM wParam, LPARAM lParam) { enum { #ifndef _WIN32_WCE WM_VERY_FIRST = WM_NCCREATE, #else WM_VERY_FIRST = WM_CREATE, #endif }; AssertNoneLocked(); if (message == WM_GETMINMAXINFO) /* WM_GETMINMAXINFO is called before WM_CREATE, and we havn't set a Window pointer yet - let DefWindowProc() handle it */ return ::DefWindowProc(_hWnd, message, wParam, lParam); Window *window; if (message == WM_VERY_FIRST) { LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam; window = (Window *)cs->lpCreateParams; window->Created(_hWnd); window->SetUserData(window); } else { window = GetUnchecked(_hWnd); } LRESULT result = window->OnMessage(_hWnd, message, wParam, lParam); AssertNoneLocked(); return result; }
void EventLoop::Dispatch(const Event &event) { AssertNoneLocked(); ::TranslateMessage(&event.msg); ::DispatchMessage(&event.msg); AssertNoneLocked(); }
void SetText(tstring::const_pointer _text) { AssertNoneLocked(); AssertThread(); text = _text; Invalidate(); }
void LargeTextWindow::SetText(const TCHAR *text) { AssertNoneLocked(); // Replace \n by \r\r\n to enable usage of line-breaks in edit control unsigned size = _tcslen(text); TCHAR buffer[size * sizeof(TCHAR) * 3]; const TCHAR* p2 = text; TCHAR* p3 = buffer; for (; *p2 != _T('\0'); p2++) { if (*p2 == _T('\n')) { *p3 = _T('\r'); p3++; *p3 = _T('\r'); p3++; *p3 = _T('\n'); } else if (*p2 == _T('\r')) { continue; } else { *p3 = *p2; } p3++; } *p3 = _T('\0'); ::SetWindowText(hWnd, buffer); }
void SetFont(const Font &_font) { AssertNoneLocked(); AssertThread(); font = &_font; Invalidate(); }
void set_text(const TCHAR *_text) { AssertNoneLocked(); AssertThread(); text = _text; Invalidate(); }
bool EventLoop::Get(Event &event) { AssertNoneLocked(); return queue.Wait(event); }
void ButtonWindow::SetText(const TCHAR *_text) { AssertNoneLocked(); AssertThread(); if (GetCustomPainting() || _tcschr(_text, _T('&')) == NULL) { ::SetWindowText(hWnd, _text); return; } TCHAR buffer[256]; /* should be large enough for buttons */ static unsigned const int buffer_size = ARRAY_SIZE(buffer); TCHAR const *s=_text; TCHAR *d=buffer; // Workaround WIN32 special use of '&' (replace every '&' with "&&") // Note: Terminates loop two chars before the buffer_size. This might prevent // potential char copies but assures that there is always room for // two '&'s and the 0-terminator. while (*s && d < buffer + buffer_size - 2) { if (*s == _T('&')) *d++ = *s; *d++ = *s++; } *d=0; ::SetWindowText(hWnd, buffer); }
void ProgressWindow::SetMessage(const TCHAR *text) { AssertNoneLocked(); AssertThread(); message.set_text(text); }
void BringToBottom() { AssertNoneLocked(); AssertThread(); ::SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE| SWP_NOACTIVATE|SWP_NOOWNERZORDER); }
void Window::BringToBottom() { AssertNoneLocked(); AssertThread(); parent->BringChildToBottom(*this); }
void Close() { AssertNoneLocked(); #ifndef USE_GDI OnClose(); #else ::SendMessage(hWnd, WM_CLOSE, 0, 0); #endif }
void Window::SetFont(const Font &_font) { AssertNoneLocked(); AssertThread(); ::SendMessage(hWnd, WM_SETFONT, (WPARAM)_font.Native(), MAKELPARAM(TRUE, 0)); }
void DialogEventLoop::Dispatch(Event &event) { AssertNoneLocked(); if (::IsDialogMessage(dialog, &event.msg)) return; EventLoop::Dispatch(event); }
void BringToTop() { AssertNoneLocked(); AssertThread(); /* not using BringWindowToTop() because it activates the winddow */ ::SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE| SWP_NOACTIVATE|SWP_NOOWNERZORDER); }
void LargeTextWindow::SetText(const TCHAR *text) { AssertNoneLocked(); if (text != nullptr) value = text; else value.clear(); Invalidate(); }
void Window::ReleaseCapture() { AssertNoneLocked(); AssertThread(); capture = false; if (parent != NULL) parent->ReleaseChildCapture(this); }
void Window::SetCapture() { AssertNoneLocked(); AssertThread(); if (parent != NULL) parent->SetChildCapture(this); capture = true; }
const tstring ButtonWindow::GetText() const { AssertNoneLocked(); AssertThread(); TCHAR buffer[256]; /* should be large enough for buttons */ int length = GetWindowText(hWnd, buffer, ARRAY_SIZE(buffer)); return tstring(buffer, length); }
void SetFont(const Font &_font) { AssertNoneLocked(); AssertThread(); #ifndef USE_GDI font = &_font; Invalidate(); #else ::SendMessage(hWnd, WM_SETFONT, (WPARAM)_font.Native(), MAKELPARAM(TRUE,0)); #endif }
void ProgressWindow::SetValue(unsigned value) { AssertNoneLocked(); AssertThread(); if (value == position) return; position = value; progress_bar.SetValue(value); }
void ShowOnTop() { AssertNoneLocked(); AssertThread(); #ifndef USE_GDI BringToTop(); Show(); #else ::SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE| SWP_NOACTIVATE|SWP_NOOWNERZORDER); #endif }
void ProgressBar::Step() { AssertNoneLocked(); AssertThread(); #ifndef USE_GDI value += step_size; Expose(); #else ::SendMessage(hWnd, PBM_STEPIT, (WPARAM)0, (LPARAM)0); #endif }
/** * Like move(), but does not trigger a synchronous redraw. The * caller is responsible for redrawing. */ void FastMove(PixelScalar left, PixelScalar top, UPixelScalar width, UPixelScalar height) { AssertNoneLocked(); AssertThread(); #ifndef USE_GDI Move(left, top, width, height); #else /* USE_GDI */ ::SetWindowPos(hWnd, NULL, left, top, width, height, SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_DEFERERASE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); #endif }
void ProgressBar::SetValue(unsigned value) { AssertNoneLocked(); AssertThread(); #ifndef USE_GDI this->value = value; Expose(); #else ::SendMessage(hWnd, PBM_SETPOS, value, 0); #endif }
void ProgressBar::SetStep(unsigned size) { AssertNoneLocked(); AssertThread(); #ifndef USE_GDI step_size = size; Expose(); #else ::SendMessage(hWnd, PBM_SETSTEP, (WPARAM)size, (LPARAM)0); #endif }
void Move(PixelScalar left, PixelScalar top) { AssertNoneLocked(); AssertThread(); #ifndef USE_GDI position = { left, top }; Invalidate(); #else ::SetWindowPos(hWnd, nullptr, left, top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); #endif }
void Window::SetCapture() { AssertNoneLocked(); AssertThread(); if (parent != nullptr) parent->SetChildCapture(this); else EnableCapture(); capture = true; }
void Window::ReleaseCapture() { AssertNoneLocked(); AssertThread(); capture = false; if (parent != nullptr) parent->ReleaseChildCapture(this); else DisableCapture(); }
/** * Move the Window to the specified position within the parent * ContainerWindow and make it visible. */ void MoveAndShow(const PixelRect rc) { AssertNoneLocked(); AssertThread(); #ifdef USE_GDI ::SetWindowPos(hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER); #else Move(rc); Show(); #endif }