void CToolDlg::OnNcRButtonDown(UINT nHitTest, CPoint point) { SetActiveWindow(); // base class doesn't activate us, though it should UpdateWindow(); // else client area doesn't fully paint until button up if (m_IsNonBlocking) { // If you right-click in the caption bar, the message loop is blocked until // you release the mouse button. This is unacceptable in a timer-driven app. switch (nHitTest) { case HTCAPTION: break; // don't call base class, display context menu in OnNcRButtonUp default: CPersistDlg::OnNcRButtonDown(nHitTest, point); } } else // default behavior CPersistDlg::OnNcRButtonDown(nHitTest, point); }
void dd_Window::setPosition(int x, int y) { //SetWindowPos(hwnd,0,x,y,0,0,SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); HWND hw = GetActiveWindow(); WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hwnd,&wp); int w = wp.rcNormalPosition.right - wp.rcNormalPosition.left; int h = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; wp.rcNormalPosition.left = x; wp.rcNormalPosition.top = y; wp.rcNormalPosition.right = wp.rcNormalPosition.left + w; wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + h; SetWindowPlacement(hwnd,&wp); SetActiveWindow(hw); }
static void ShowProperties(HWND parent, Controller *ctrl, bool extended=false) { PropertiesLayout *layoutData = FindPropertyWindowByParent(parent); if (layoutData) { SetActiveWindow(layoutData->hwnd); return; } if (!ctrl) return; layoutData = new PropertiesLayout(); gPropertiesWindows.Append(layoutData); GetProps(ctrl, layoutData, extended); if (!CreatePropertiesWindow(parent, layoutData)) delete layoutData; }
void App::ShowProperties() { hInstance = GetInstance(); if (!hPropDialog) { hPropDialog = CreateDialogParam( GetInstance(), MAKEINTRESOURCE(IDD_SHOW_PROPERTIES), GetHWnd(), (DLGPROC)PropDlgProc, (LPARAM)this); } else { SetActiveWindow(hPropDialog); GetProperties(); } }
void WdeHandlePokedData( HDDEDATA hdata ) { HWND main; char *cmd; WdeResInfo *rinfo; if( hdata == (HDDEDATA)NULL ) { return; } cmd = (char *)WdeHData2Mem( hdata ); if( cmd == NULL ) { return; } main = WdeGetMainWindowHandle(); if( stricmp( cmd, "show" ) == 0 ) { ShowWindow( main, SW_RESTORE ); ShowWindow( main, SW_SHOWNA ); } else if( stricmp( cmd, "hide" ) == 0 ) { ShowWindow( main, SW_SHOWMINNOACTIVE ); ShowWindow( main, SW_HIDE ); } else if( stricmp( cmd, "endsession" ) == 0 ) { if( GotEndSession == FALSE ) { GotEndSession = TRUE; rinfo = WdeGetCurrentRes(); WdeDestroyResourceWindow( rinfo ); } } else if( stricmp( cmd, "bringtofront" ) == 0 ) { if( IsIconic( main ) ) { ShowWindow( main, SW_RESTORE ); } #ifdef __NT__ SetWindowPos( main, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetWindowPos( main, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetWindowPos( main, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetForegroundWindow( main ); #else SetActiveWindow( main ); SetWindowPos( main, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); #endif } WRMemFree( cmd ); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { static HBITMAP hBit; PAINTSTRUCT ps; HGDIOBJ hOld; HDC hMemDC; RECT rt; switch (iMsg) { case WM_CREATE: hBit = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(101)); ShowCursor(FALSE); SetFullScreen(hWnd); return 0; case WM_PAINT: BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rt); hMemDC = CreateCompatibleDC(ps.hdc); hOld = SelectObject(hMemDC, hBit); StretchBlt(ps.hdc, 0, 0, rt.right, rt.bottom, hMemDC, 0, 0, 640, 480, SRCCOPY); SelectObject(hMemDC, hOld); DeleteDC(hMemDC); EndPaint(hWnd, &ps); return 0; #ifdef TEST case WM_RBUTTONDOWN: DestroyWindow(hWnd); return 0; #endif case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_SYSCOMMAND: return 0; case WM_ACTIVATE: if (LOWORD(wParam) == WA_INACTIVE) SetActiveWindow(hWnd); return 0; case WM_DESTROY: DeleteObject(hBit); PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, iMsg, wParam, lParam); }
void clickChildButton (HWND dialog, const char *caption) { HWND dialogItem = NULL; while (1) { dialogItem = FindWindowEx(dialog, dialogItem, NULL, NULL); if (dialogItem == NULL) { break; } char windowText[255]; GetWindowText(dialogItem, windowText, 255); printf("found subitem: %s\n", windowText); if (strcmp(windowText, caption) == 0) { SetActiveWindow(dialog); SendMessage(dialogItem, BM_CLICK, NULL, NULL); break; } } }
void CDlgAddTask::PopupDlg(BOOL bBlank) { if (IsDlgPopedUp()) return; m_uAddState = 2; // Added by Soar Chin 09/06/2007 Create(CDlgAddTask::IDD); ShowWindow(SW_SHOW); SetForegroundWindow(); SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0,SWP_NOMOVE|SWP_NOSIZE); SetActiveWindow(); SetFocus(); if (!bBlank) GetDlgItem(IDOK)->SetFocus(); }
void RestoreWndFromTray(HWND hWnd) { if(IsWindowVisible(hWnd)) return; if(GetDoAnimateMinimize()) { RECT rcFrom,rcTo; GetTrayWndRect(&rcFrom); GetWindowRect(hWnd,&rcTo); DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); } ShowWindow(hWnd,SW_SHOW); SetActiveWindow(hWnd); SetForegroundWindow(hWnd); }
static void ShowProperties(HWND parent, Doc doc, DisplayModel *dm, bool extended=false) { PropertiesLayout *layoutData = FindPropertyWindowByParent(parent); if (layoutData) { SetActiveWindow(layoutData->hwnd); return; } if (!doc.IsEngine() && !doc.IsEbook()) return; layoutData = new PropertiesLayout(); gPropertiesWindows.Append(layoutData); GetProps(doc, layoutData, dm, extended); if (!CreatePropertiesWindow(parent, layoutData)) delete layoutData; }
void khm_activate_main_window(void) { if (!SetForegroundWindow(khm_hwnd_main)) { FLASHWINFO finfo; SetActiveWindow(khm_hwnd_main); ZeroMemory(&finfo, sizeof(finfo)); finfo.cbSize = sizeof(finfo); finfo.hwnd = khm_hwnd_main; finfo.dwFlags = FLASHW_ALL; finfo.uCount = 3; finfo.dwTimeout = 0; FlashWindowEx(&finfo); } }
void WinLuaOnStop() { HWND hDlg = hLuaDlg; //LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; HWND prevWindow = GetActiveWindow(); SetActiveWindow(hDlg); // bring to front among other script/secondary windows, since a stopped script will have some message for the user that would be easier to miss otherwise //if (prevWindow == AfxGetMainWnd()->GetSafeHwnd()) SetActiveWindow(prevWindow); //info.started = false; EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUABROWSE), true); EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUASTOP), false); SetWindowText(GetDlgItem(hDlg, IDC_BUTTON_LUARUN), "Run"); // if(statusOK) // Show_Genesis_Screen(MainWindow->getHWnd()); // otherwise we might never show the last thing the script draws //if(info.closeOnStop) // PostMessage(hDlg, WM_CLOSE, 0, 0); }
void PopupHistoryShow() { if (!PopupOptions.EnableHistory) { MessageBox(NULL, TranslateT("Popup History is disabled"), TranslateT("Popup History message"), MB_OK); return; } if (hwndHistory) { ShowWindow(hwndHistory, SW_SHOW); SetForegroundWindow(hwndHistory); SetFocus(hwndHistory); SetActiveWindow(hwndHistory); } else { hwndHistory = CreateDialog(hInst, MAKEINTRESOURCE(IDD_HISTORY), NULL, HistoryDlgProc); SetWindowText(hwndHistory, TranslateT("Popup History")); } }
LRESULT CALLBACK HelperProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_ACTIVATE: if (LOWORD(wParam) != WA_INACTIVE) // Helper window got activated SetActiveWindow(hMirandaWnd); break; case WM_DESTROY: if (hWnd == hHelperWnd) hHelperWnd = NULL; else hDummyWnd = NULL; break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void FCodecNotFoundDlg::OnCreated() { SetMinSize(640, 480); SetIcon(LoadIcon(_Module.get_m_hInst(), MAKEINTRESOURCE(IDI_MAIN))); FString Str; GetWindowText(Str); SetWindowText(LTV_APP_NAME": Codec not found"); if (FAILED(m_pW.Navigate(g_AppSettings.AppDir(Str)))) { MessageBox("Cannot load error file.", "Error loading dialog", MB_OK | MB_ICONERROR); DestroyWindow(); } SetFocus(); SetActiveWindow(); }
static int winPopupDialog(Ihandle* n, int x, int y) { HWND last_hwnd; HWND popup_hwnd; Ihandle* parent = IupGetAttributeHandle(n, IUP_PARENTDIALOG); if (parent && handle(parent)) last_hwnd = handle(parent); else last_hwnd = GetActiveWindow(); winShowXY(n, x, y); if (iupGetEnv(n, "_IUPWIN_POPUP")) return IUP_ERROR; popup_hwnd = (HWND)handle(n); /* disable all visible dialogs, and mark popup level */ /* will be enable by IupHide */ winDisableVisible(n); iupSetEnv(n, "_IUPWIN_POPUP", "1"); /* mark window as popup so IupHide can also detect it */ /* interrupt processing here */ IupMainLoop(); /* if window is still valid (IupDestroy not called) */ if (IsWindow(popup_hwnd)) { iupSetEnv(n, "_IUPWIN_POPUP", "2"); IupHide(n); /* hide the popup to update the disabled windows */ /* but do not call IupExitLoop again */ iupSetEnv(n, "_IUPWIN_POPUP", NULL); /* unmark the window */ } /* activate the previous active window */ if (last_hwnd) SetActiveWindow(last_hwnd); return IUP_NOERROR; }
void CMainFrame::OnDropFiles(HDROP hDropInfo) { SetActiveWindow(); // activate us first ! UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0); if (nFiles == 1) { //if only 1 file with .zpk extension, open it as a package TCHAR szFileName[_MAX_PATH]; ::DragQueryFile(hDropInfo, 0, szFileName, _MAX_PATH); zp::String filename = szFileName; size_t length = filename.length(); zp::String lowerExt; if (length >= 4) { zp::String temp = filename.substr(length - 4, 4); stringToLower(lowerExt, temp); } if (lowerExt == _T(".zpk")) { CWinApp* pApp = AfxGetApp(); pApp->OpenDocumentFile(szFileName); return; } } //more than 1 file, try to add to package std::vector<zp::String> filenames(nFiles); for (UINT i = 0; i < nFiles; i++) { TCHAR szFileName[_MAX_PATH]; ::DragQueryFile(hDropInfo, i, szFileName, _MAX_PATH); filenames[i] = szFileName; } CzpEditorDoc* doc = (CzpEditorDoc*)GetActiveDocument(); if (doc != NULL) { doc->addFilesToPackage(filenames); } ::DragFinish(hDropInfo); //CFrameWndEx::OnDropFiles(hDropInfo); }
/* * IEHandlePokedData */ static void IEHandlePokedData( HDDEDATA hdata ) { void *cmd; uint_32 size; if( hdata == (HDDEDATA)NULL ) { return; } cmd = NULL; if( !IEHData2Mem( hdata, &cmd, &size ) || cmd == NULL ) { return; } if( stricmp( cmd, "show" ) == 0 ) { ShowWindow( HMainWindow, SW_RESTORE ); ShowWindow( HMainWindow, SW_SHOWNA ); } else if( stricmp( cmd, "hide" ) == 0 ) { ShowWindow( HMainWindow, SW_SHOWMINNOACTIVE ); ShowWindow( HMainWindow, SW_HIDE ); } else if( stricmp( cmd, "endsession" ) == 0 ) { if( GotEndSession == FALSE ) { GotEndSession = TRUE; CloseAllImages(); } } else if( stricmp( cmd, "bringtofront" ) == 0 ) { if( IsIconic( HMainWindow ) ) { ShowWindow( HMainWindow, SW_RESTORE ); } #ifdef __NT__ SetWindowPos( HMainWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetWindowPos( HMainWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetWindowPos( HMainWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetForegroundWindow( HMainWindow ); #else SetActiveWindow( HMainWindow ); SetWindowPos( HMainWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); #endif } MemFree( cmd ); } /* IEHandlePokedData */
//热键消息 LRESULT CGameFrame::OnHotKeyMessage(WPARAM wParam, LPARAM lParam) { switch (wParam) { case IDI_HOT_KEY_BOSS: //老板热键 { //变量定义 bool bBossCome=(IsWindowVisible()==FALSE)?false:true; //隐藏窗口 if (bBossCome==false) { //还原窗口 ShowWindow(SW_RESTORE); ShowWindow(SW_SHOW); //置顶窗口 SetActiveWindow(); BringWindowToTop(); SetForegroundWindow(); } else { //隐藏窗口 ShowWindow(SW_MINIMIZE); ShowWindow(SW_HIDE); } //发送消息 for (INT_PTR i=0;i<MAX_SERVER;i++) { if (m_pRoomViewItem[i]!=NULL) { m_pRoomViewItem[i]->NotifyBossCome(bBossCome); } } return 0; } } return 0; }
/*********************************************************************** * IconTitleWndProc */ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { HWND owner = GetWindow( hWnd, GW_OWNER ); if (!IsWindow(hWnd)) return 0; switch( msg ) { case WM_CREATE: if (!hIconTitleFont) { LOGFONTA logFont; SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, &logFont, 0 ); SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &bMultiLineTitle, 0 ); hIconTitleFont = CreateFontIndirectA( &logFont ); } return (hIconTitleFont ? 0 : -1); case WM_NCHITTEST: return HTCAPTION; case WM_NCMOUSEMOVE: case WM_NCLBUTTONDBLCLK: return SendMessageW( owner, msg, wParam, lParam ); case WM_ACTIVATE: if( wParam ) SetActiveWindow( owner ); return 0; case WM_CLOSE: return 0; case WM_SHOWWINDOW: if (wParam) ICONTITLE_SetTitlePos( hWnd, owner ); return 0; case WM_ERASEBKGND: if( GetWindowLongPtrW( owner, GWL_STYLE ) & WS_CHILD ) lParam = SendMessageW( owner, WM_ISACTIVEICON, 0, 0 ); else lParam = (owner == GetActiveWindow()); if( ICONTITLE_Paint( hWnd, owner, (HDC)wParam, (BOOL)lParam ) ) ValidateRect( hWnd, NULL ); return 1; } return DefWindowProcW( hWnd, msg, wParam, lParam ); }
/* * Dialog-box function for the About box. */ static int CALLBACK AboutProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: /* * Centre the window. */ { /* centre the window */ RECT rs, rd; HWND hw; hw = GetDesktopWindow(); if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd)) MoveWindow(hwnd, (rs.right + rs.left + rd.left - rd.right) / 2, (rs.bottom + rs.top + rd.top - rd.bottom) / 2, rd.right - rd.left, rd.bottom - rd.top, TRUE); } SetDlgItemText(hwnd, 100, ver); return 1; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: EndDialog(hwnd, 1); return 0; case 101: EnableWindow(hwnd, 0); DialogBox(hinst, MAKEINTRESOURCE(214), hwnd, LicenceProc); EnableWindow(hwnd, 1); SetActiveWindow(hwnd); return 0; } return 0; case WM_CLOSE: EndDialog(hwnd, 1); return 0; } return 0; }
void LimitSliderDlg::internalShow( float minLimit, float maxLimit, float min, float max, unsigned int digits, LimitSlider* limitSlider ) { mDigits = digits; mLimitSlider = limitSlider; // If digits == 0, assume integer type if (digits == 0) { mMin.SetNumericType( controls::EditNumeric::ENT_INTEGER ); mMax.SetNumericType( controls::EditNumeric::ENT_INTEGER ); } else { mMin.SetNumericType( controls::EditNumeric::ENT_FLOAT ); mMax.SetNumericType( controls::EditNumeric::ENT_FLOAT ); } mMin.SetNumDecimals( digits ); mMax.SetNumDecimals( digits ); mMin.SetValue( min ); mMax.SetValue( max ); UpdateData( FALSE ); // mMinLimit.SetWindowText( formatValue( minLimit ) ); // mMaxLimit.SetWindowText( formatValue( maxLimit ) ); mSlider.setRange( minLimit, maxLimit, (int)mDigits ); mSlider.setThumbValues( min, max ); CPoint cursor; GetCursorPos( &cursor ); CRect client; GetWindowRect( &client ); MoveWindow( &getBestRect( client.Size(), cursor ) ); ShowWindow( SW_SHOW ); SetActiveWindow(); UpdateWindow(); }
void OnMenuAbout() { if (gHwndAbout) { SetActiveWindow(gHwndAbout); return; } if (!gAtomAbout) { WNDCLASSEX wcex; FillWndClassEx(wcex, ghinst, ABOUT_CLASS_NAME, WndProcAbout); wcex.hIcon = LoadIcon(ghinst, MAKEINTRESOURCE(IDI_SUMATRAPDF)); gAtomAbout = RegisterClassEx(&wcex); CrashIf(!gAtomAbout); } gHwndAbout = CreateWindow( ABOUT_CLASS_NAME, ABOUT_WIN_TITLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, ghinst, NULL); if (!gHwndAbout) return; // get the dimensions required for the about box's content RectI rc; PAINTSTRUCT ps; HDC hdc = BeginPaint(gHwndAbout, &ps); UpdateAboutLayoutInfo(gHwndAbout, hdc, &rc); EndPaint(gHwndAbout, &ps); rc.Inflate(ABOUT_RECT_PADDING, ABOUT_RECT_PADDING); // resize the new window to just match these dimensions WindowRect wRc(gHwndAbout); ClientRect cRc(gHwndAbout); wRc.dx += rc.dx - cRc.dx; wRc.dy += rc.dy - cRc.dy; MoveWindow(gHwndAbout, wRc.x, wRc.y, wRc.dx, wRc.dy, FALSE); ShowWindow(gHwndAbout, SW_SHOW); }
static void IECheckIfActiveWindow( void ) { HWND active; active = GetActiveWindow(); if( active != HMainWindow ) { if( IsIconic( HMainWindow ) ) { ShowWindow( HMainWindow, SW_RESTORE ); } #ifdef __NT__ SetWindowPos( HMainWindow, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE ); SetWindowPos( HMainWindow, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE ); SetWindowPos( HMainWindow, HWND_NOTOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE ); SetForegroundWindow( HMainWindow ); #else SetActiveWindow( HMainWindow ); SetWindowPos( HMainWindow, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE ); #endif } }
void CMainFrame::OnSize(UINT nType, int cx, int cy) { POINT pt; RECT rc2; u32 tool_h, slide_h, add_h, stat_h; if (m_bInitShow) { CFrameWnd::OnSize(nType, cx, cy); return; } m_wndToolBar.GetClientRect(&rc2); tool_h = rc2.bottom - rc2.top; m_Address.GetClientRect(&rc2); add_h = rc2.bottom - rc2.top; m_Sliders.GetClientRect(&rc2); slide_h = rc2.bottom - rc2.top; m_wndStatusBar.GetClientRect(&rc2); stat_h = rc2.bottom - rc2.top; if ((u32) cy <= tool_h+add_h+slide_h+stat_h) { OnSetSize(cx, 1); return; } CFrameWnd::OnSize(nType, cx, cy); cy -= tool_h + add_h + slide_h + stat_h; m_Address.SetWindowPos(this, 0, 0, cx, add_h, SWP_SHOWWINDOW | SWP_NOMOVE); /*and update pos (the view window is not a child one)*/ pt.x = 0; pt.y = add_h + tool_h + cy; ClientToScreen(&pt); m_Sliders.SetWindowPos(this, pt.x, pt.y, cx, slide_h, SWP_SHOWWINDOW); /*and set size through the terminal (this takes care of threading issues with opengl)*/ M4T_SetSize(GetApp()->m_term, cx, cy); SetActiveWindow(); SetFocus(); }
void cIMEWnd::SetDockingEx(cIMEex * box, BOOL bDock ) { if( bDock ) { m_pDockingEx = box; HWND curFocus = 0; curFocus = GetFocus(); if(curFocus != _g_hWnd) { SetFocus(_g_hWnd); SetActiveWindow(_g_hWnd); } } else { if( box == m_pDockingEx ) m_pDockingEx = NULL; } }
int CL_GUIComponent::exec() { CL_GUIComponent *owner_component = get_owner_component(); if (owner_component) owner_component->get_top_level_component()->set_enabled(false); get_gui_manager().exec(); if (owner_component) { // To do: Move this special modal dialog code to the window manager. // Important: Do not remove any of these calls even though they seem pointless, redundant or even wrong. // They workaround various bugs in the focus handling in Windows itself. #ifdef WIN32 set_visible(false, false); #endif owner_component->get_top_level_component()->set_enabled(true); #ifdef WIN32 SetActiveWindow(owner_component->get_top_level_component()->get_display_window().get_hwnd()); #endif } return get_gui_manager().get_exit_code(); }
LRESULT CFloatingWindow::OnHotKey(int HotKeyID, UINT flags, UINT vk) { if (HotKeyID < 0 || HotKeyID > int(m_hotkeys.size()) - 1) return 0; if (m_bIsUploading) return 0; if (m_hotkeys[HotKeyID].func == _T("windowscreenshot")) { pWizardDlg->executeFunc(_T("windowscreenshot,1")); } else { m_bFromHotkey = true; SetActiveWindow(); SetForegroundWindow(m_hWnd); SendMessage(WM_COMMAND, MAKEWPARAM(m_hotkeys[HotKeyID].commandId, 0)); m_bFromHotkey = false; } return 0; }
void ProgressWindow::init() { initialized = true; progress = 0; lastProgress = 0; time = 0; lastTime = 0; speed = 0; RECT rc; GetClientRect(hWnd, &rc); hWnd=CreateWindowEx(WS_EX_TOPMOST, "STATIC", "", WS_VISIBLE|WS_CHILD, (rc.right-p_width)/2, rc.bottom/2, p_width, p_height+1, hWnd, NULL, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL); ShowWindow(hWnd, SW_SHOW); SetWindowPos(hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); SetActiveWindow(hWnd); UpdateWindow(hWnd); InitializeCriticalSection(&syncObj); thread = (HANDLE)_beginthread(start_progress_thread, 0, this); }
bool IsOnlyInstance(LPCTSTR title) { //find the window. if active, set and return false //only one game instance may have this mutex at a time HANDLE handle = CreateMutex(NULL, TRUE, title); if(GetLastError() != ERROR_SUCCESS) { HWND hwnd = FindWindow(title, NULL); if(hwnd) { //an instance is already running ShowWindow(hwnd, SW_SHOWNORMAL); SetFocus(hwnd); SetForegroundWindow(hwnd); SetActiveWindow(hwnd); return false; } } return true; }