bool wxFrame::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return false; SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); #if wxUSE_TASKBARBUTTON static bool s_taskbarButtonCreatedMsgRegistered = false; if ( !s_taskbarButtonCreatedMsgRegistered ) { s_taskbarButtonCreatedMsgRegistered = true; wxMsgTaskbarButtonCreated = ::RegisterWindowMessage(wxT("TaskbarButtonCreated")); // In case the application is run elevated, allow the // TaskbarButtonCreated and WM_COMMAND messages through. #if wxUSE_DYNLIB_CLASS typedef BOOL (WINAPI *ChangeWindowMessageFilter_t)(UINT message, DWORD dwFlag); wxDynamicLibrary dllUser32(wxT("user32.dll")); ChangeWindowMessageFilter_t pfnChangeWindowMessageFilter = NULL; wxDL_INIT_FUNC(pfn, ChangeWindowMessageFilter, dllUser32); if ( pfnChangeWindowMessageFilter ) { pfnChangeWindowMessageFilter(wxMsgTaskbarButtonCreated, wxMSGFLT_ADD); pfnChangeWindowMessageFilter(WM_COMMAND, wxMSGFLT_ADD); } #else ChangeWindowMessageFilter(wxMsgTaskbarButtonCreated, wxMSGFLT_ADD); ChangeWindowMessageFilter(WM_COMMAND, wxMSGFLT_ADD); #endif // wxUSE_DYNLIB_CLASS } #endif // wxUSE_TASKBARBUTTON return true; }
bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) { #if wxUSE_DYNLIB_CLASS typedef DWORD (WINAPI *PSETLAYEREDWINDOWATTR)(HWND, DWORD, BYTE, DWORD); static PSETLAYEREDWINDOWATTR pSetLayeredWindowAttributes = (PSETLAYEREDWINDOWATTR)-1; if ( pSetLayeredWindowAttributes == (PSETLAYEREDWINDOWATTR)-1 ) { wxDynamicLibrary dllUser32(wxT("user32.dll")); // use RawGetSymbol() and not GetSymbol() to avoid error messages under // Windows 95: there is nothing the user can do about this anyhow pSetLayeredWindowAttributes = (PSETLAYEREDWINDOWATTR) dllUser32.RawGetSymbol(wxT("SetLayeredWindowAttributes")); // it's ok to destroy dllUser32 here, we link statically to user32.dll // anyhow so it won't be unloaded } if ( !pSetLayeredWindowAttributes ) return false; #endif // wxUSE_DYNLIB_CLASS LONG exstyle = GetWindowLong(GetHwnd(), GWL_EXSTYLE); // if setting alpha to fully opaque then turn off the layered style if (alpha == 255) { SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle & ~WS_EX_LAYERED); Refresh(); return true; } #if wxUSE_DYNLIB_CLASS // Otherwise, set the layered style if needed and set the alpha value if ((exstyle & WS_EX_LAYERED) == 0 ) SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyle | WS_EX_LAYERED); if ( pSetLayeredWindowAttributes(GetHwnd(), 0, (BYTE)alpha, LWA_ALPHA) ) return true; #endif // wxUSE_DYNLIB_CLASS return false; }
void wxTopLevelWindowMSW::RequestUserAttention(int flags) { #if defined(FLASHW_STOP) && wxUSE_DYNLIB_CLASS // available in the headers, check if it is supported by the system typedef BOOL (WINAPI *FlashWindowEx_t)(FLASHWINFO *pfwi); static FlashWindowEx_t s_pfnFlashWindowEx = NULL; if ( !s_pfnFlashWindowEx ) { wxDynamicLibrary dllUser32(wxT("user32.dll")); s_pfnFlashWindowEx = (FlashWindowEx_t) dllUser32.GetSymbol(wxT("FlashWindowEx")); // we can safely unload user32.dll here, it's going to remain loaded as // long as the program is running anyhow } if ( s_pfnFlashWindowEx ) { WinStruct<FLASHWINFO> fwi; fwi.hwnd = GetHwnd(); fwi.dwFlags = FLASHW_ALL; if ( flags & wxUSER_ATTENTION_INFO ) { // just flash a few times fwi.uCount = 3; } else // wxUSER_ATTENTION_ERROR { // flash until the user notices it fwi.dwFlags |= FLASHW_TIMERNOFG; } s_pfnFlashWindowEx(&fwi); } else // FlashWindowEx() not available #endif // FlashWindowEx() defined { wxUnusedVar(flags); #ifndef __WXWINCE__ ::FlashWindow(GetHwnd(), TRUE); #endif // __WXWINCE__ } }
bool wxChoice::MSWGetComboBoxInfo(tagCOMBOBOXINFO* info) const { // TODO-Win9x: Get rid of this once we officially drop support for Win9x // and just call the function directly. #if wxUSE_DYNLIB_CLASS typedef BOOL (WINAPI *GetComboBoxInfo_t)(HWND, tagCOMBOBOXINFO*); static GetComboBoxInfo_t s_pfnGetComboBoxInfo = NULL; static bool s_triedToLoad = false; if ( !s_triedToLoad ) { s_triedToLoad = true; wxLoadedDLL dllUser32("user32.dll"); wxDL_INIT_FUNC(s_pfn, GetComboBoxInfo, dllUser32); } if ( s_pfnGetComboBoxInfo ) return (*s_pfnGetComboBoxInfo)(GetHwnd(), info) != 0; #endif // wxUSE_DYNLIB_CLASS return false; }
WXHWND wxComboBox::GetEditHWNDIfAvailable() const { #if wxUSE_DYNLIB_CLASS #if defined(WINVER) && WINVER >= 0x0500 typedef BOOL (WINAPI *GetComboBoxInfo_t)(HWND, COMBOBOXINFO*); static GetComboBoxInfo_t s_pfnGetComboBoxInfo = NULL; static bool s_triedToLoad = false; if ( !s_triedToLoad ) { s_triedToLoad = true; wxLoadedDLL dllUser32("user32.dll"); wxDL_INIT_FUNC(s_pfn, GetComboBoxInfo, dllUser32); } if ( s_pfnGetComboBoxInfo ) { WinStruct<COMBOBOXINFO> info; (*s_pfnGetComboBoxInfo)(GetHwnd(), &info); return info.hwndItem; } #endif // WINVER >= 0x0500 #endif // wxUSE_DYNLIB_CLASS if (HasFlag(wxCB_SIMPLE)) { POINT pt; pt.x = pt.y = 4; return (WXHWND) ::ChildWindowFromPoint(GetHwnd(), pt); } // notice that a slightly safer alternative could be to use FindWindowEx() // but it's not available under WinCE so just take the first child for now // to keep one version of the code for all platforms and fix it later if // problems are discovered // we assume that the only child of the combobox is the edit window return (WXHWND)::GetWindow(GetHwnd(), GW_CHILD); }