void LocalUpdateHandler::updateVideoRegion() { ServerConfig *srvConf = Configurator::getInstance()->getServerConfig(); unsigned int interval = srvConf->getVideoRecognitionInterval(); DateTime curTime = DateTime::now(); if ((curTime - m_lastVidUpdTime).getTime() > interval) { m_lastVidUpdTime = DateTime::now(); m_vidRegion.clear(); AutoLock al(srvConf); StringVector *classNames = srvConf->getVideoClassNames(); std::vector<HWND> hwndVector; std::vector<HWND>::iterator hwndIter; WindowFinder::findWindowsByClass(classNames, &hwndVector); for (hwndIter = hwndVector.begin(); hwndIter != hwndVector.end(); hwndIter++) { HWND videoHWND = *hwndIter; if (videoHWND != 0) { WINDOWINFO wi; wi.cbSize = sizeof(WINDOWINFO); if (GetWindowInfo(videoHWND, &wi)) { Rect videoRect(wi.rcClient.left, wi.rcClient.top, wi.rcClient.right, wi.rcClient.bottom); videoRect.move(-GetSystemMetrics(SM_XVIRTUALSCREEN), -GetSystemMetrics(SM_YVIRTUALSCREEN)); m_vidRegion.addRect(&videoRect); } } } } }
static void winDialogGetWindowDecor(Ihandle* ih, int *border, int *caption, int menu) { WINDOWINFO wi; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(ih->handle, &wi); *border = wi.cxWindowBorders; if (wi.rcClient.bottom == wi.rcClient.top || wi.rcClient.top > wi.rcWindow.bottom || wi.rcClient.bottom > wi.rcWindow.bottom) { if (wi.dwStyle & WS_CAPTION) { if (wi.dwExStyle & WS_EX_TOOLWINDOW) *caption = GetSystemMetrics(SM_CYSMCAPTION); /* tool window */ else *caption = GetSystemMetrics(SM_CYCAPTION); /* normal window */ } else *caption = 0; } else { /* caption = window height - borders - client height - menu */ *caption = (wi.rcWindow.bottom-wi.rcWindow.top) - 2*wi.cyWindowBorders - (wi.rcClient.bottom-wi.rcClient.top) - menu; } }
static char* winDialogGetActiveWindowAttrib(Ihandle* ih) { WINDOWINFO wininfo; wininfo.cbSize = sizeof(WINDOWINFO); GetWindowInfo(ih->handle, &wininfo); return iupStrReturnBoolean (wininfo.dwWindowStatus & WS_ACTIVECAPTION); }
void Window::HandleSizeMessage() { WINDOWINFO info; GetWindowInfo(m_handle, &info); bool resized = false; if (GetRectWidth(info.rcClient) != GetRectWidth(m_clientRect)) resized = true; else if (GetRectHeight(info.rcClient) != GetRectHeight(m_clientRect)) resized = true; m_clientRect = info.rcClient; m_windowRect = info.rcWindow; if (resized) { unsigned int clientWidth = GetClientWidth(); unsigned int clientHeight = GetClientHeight(); unsigned int windowWidth = GetWindowWidth(); unsigned int windowHeight = GetWindowHeight(); for (size_t i = 0; i < m_eventListeners.size(); ++i) { m_eventListeners[i]->WindowResized(clientWidth, clientHeight, windowWidth, windowHeight); } } }
RKCaughtX11Window::RKCaughtX11Window (WId window_to_embed, int device_number) : RKMDIWindow (0, X11Window) { RK_TRACE (MISC); commonInit (device_number); embedded = window_to_embed; #ifdef Q_WS_WIN // unfortunately, trying to get KWindowInfo as below hangs on windows (KDElibs 4.2.3) WINDOWINFO wininfo; wininfo.cbSize = sizeof (WINDOWINFO); GetWindowInfo (embedded, &wininfo); // clip off the window frame and menubar xembed_container->setContentsMargins (wininfo.rcWindow.left - wininfo.rcClient.left, wininfo.rcWindow.top - wininfo.rcClient.top, wininfo.rcClient.right - wininfo.rcWindow.right, wininfo.rcClient.bottom - wininfo.rcWindow.bottom); // set a fixed size until the window is shown xembed_container->setFixedSize (wininfo.rcClient.right - wininfo.rcClient.left, wininfo.rcClient.bottom - wininfo.rcClient.top); setGeometry (wininfo.rcClient.left, wininfo.rcClient.right, wininfo.rcClient.top, wininfo.rcClient.bottom); // see comment in X11 section move (wininfo.rcClient.left, wininfo.rcClient.top); // else the window frame may be off scree on top/left. #elif defined Q_WS_X11 KWindowInfo wininfo = KWindowSystem::windowInfo (embedded, NET::WMName | NET::WMGeometry); RK_ASSERT (wininfo.valid ()); // set a fixed size until the window is shown xembed_container->setFixedSize (wininfo.geometry ().width (), wininfo.geometry ().height ()); setGeometry (wininfo.geometry ()); // it's important to set a size, even while not visible. Else DetachedWindowContainer will assign a default size of 640*480, and then size upwards, if necessary. setCaption (wininfo.name ()); #endif // somehow in Qt 4.4.3, when the RKCaughtWindow is reparented the first time, the QX11EmbedContainer may kill its client. Hence we delay the actual embedding until after the window was shown. // In some previous version of Qt, this was not an issue, but I did not track the versions. QTimer::singleShot (0, this, SLOT (doEmbed())); }
static int is_valid_window(HWND hwnd) { WINDOWINFO wi; wi.cbSize = sizeof(wi); GetWindowInfo(hwnd, &wi); return (wi.dwStyle & WS_VISIBLE) && !(wi.dwExStyle & WS_EX_TOOLWINDOW); }
static bool maybeAddWindow(HWND hwnd, std::vector<QRect> *windows) { WINDOWINFO wi; GetWindowInfo( hwnd, &wi ); RECT rect = wi.rcClient; #if 0 RECT rect; GetWindowRect( hwnd, &rect ); #endif int width = rect.right - rect.left; int height = rect.bottom - rect.top; // For some reason, rect.left and rect.top are shifted by cxWindowBorders and cyWindowBorders pixels respectively // in *every* case (for every window), but cxWindowBorders and cyWindowBorders are non-zero only in the // biggest-window case, therefore we need to save the biggest cxWindowBorders and cyWindowBorders to adjust the rect later cxWindowBorder = qMax(cxWindowBorder, wi.cxWindowBorders); cyWindowBorder = qMax(cyWindowBorder, wi.cyWindowBorders); if ( ( ( wi.dwStyle & WS_VISIBLE ) != 0 ) && (width >= minSize ) && (height >= minSize ) ) { //QRect r( rect.left + 4, rect.top + 4, width, height); // 4 = max(wi.cxWindowBorders) = max(wi.cyWindowBorders) QRect r(rect.left + cxWindowBorder, rect.top + cyWindowBorder, width, height); if ( std::find( windows->begin(), windows->end(), r ) == windows->end() ) { windows->push_back( r ); return true; } } return false; }
static void draw_hilight_box (HWND hWnd, HDC hdc, COOLBARITEMDATA* item) { int l,r,t,b; WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); DWORD color; DWORD mainc = GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY); l = item->RcTitle.left; t = item->RcTitle.top; r = item->RcTitle.right - 1; b = item->RcTitle.bottom - 1; color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l, t); LineTo (hdc, l, b); MoveTo (hdc, r - 1, t); LineTo (hdc, r - 1, b); color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l + 1, t); LineTo (hdc, l + 1, b); MoveTo (hdc, r, t); LineTo (hdc, r, b); }
// // ‘”Ќ ÷»я: InitInstance(HINSTANCE, int) // // Ќј«Ќј„≈Ќ»≈: сохран¤ет обработку экземпл¤ра и создает главное окно. // // ќћћ≈Ќ“ј–»»: // // ¬ данной функции дескриптор экземпл¤ра сохран¤етс¤ в глобальной переменной, а также // создаетс¤ и выводитс¤ на экран главное окно программы. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // —охранить дескриптор экземпл¤ра в глобальной переменной //Samsung Galaxy S+ Screen Resolution int WINDOW_WIDTH = 800; int WINDOW_HEIGHT = 480; hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT }; WINDOWINFO info; GetWindowInfo(hWnd, &info); AdjustWindowRectEx(&rect, info.dwStyle, GetMenu(hWnd) != NULL, info.dwExStyle); MoveWindow(hWnd, 0, 0, (rect.right - rect.left), (rect.bottom - rect.top), FALSE); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
void GetWindowInformation() { TCHAR buf[256]; GetCursorPos (&g_ptMouse); memset(&g_WinInfo, 0, sizeof(g_WinInfo)); g_WinInfo.hwnd = WindowFromPoint(g_ptMouse); RealGetWindowClass(g_WinInfo.hwnd , g_WinInfo.szWindowClass, sizeof(g_WinInfo.szWindowClass)); GetWindowInfo(g_WinInfo.hwnd , &g_WinInfo.wi ); int id = GetDlgCtrlID(g_WinInfo.hwnd ); HWND hwndEdit = GetDlgItem(g_hWndMain,ID_EDITCHILD); _stprintf_s(buf, _T("「WindowClass」=%s 「CtrlID」=0x%p 「Location」=%d,%d"), g_WinInfo.szWindowClass, id, g_WinInfo.wi.rcWindow.right - g_WinInfo.wi.rcWindow.left , g_WinInfo.wi.rcWindow.bottom - g_WinInfo.wi.rcWindow.top); // Add text to the window. //SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM) buf); InvalidateRect(g_hWndMain,NULL,FALSE); }
/*static*/ WindowInfo WindowInfo::about (int64_t wid){ HWND win = (HWND) (wid); WINDOWINFO info; GetWindowInfo(win, &info); bool isVisible = (info.dwStyle & WS_VISIBLE) != 0; if (isVisible) { char title [512] = ""; GetWindowText (win, title, (sizeof title) - 1); DWORD process; GetWindowThreadProcessId (win, &process); WindowInfo dst; dst.title = title; dst.id = (int64_t) win; // At least in Win7 Window Handles seem unique and could also be interpreted as IDs dst.pid = process; dst.area = dz::Rect(info.rcWindow.left, info.rcWindow.top, info.rcWindow.right - info.rcWindow.left, info.rcWindow.bottom - info.rcWindow.top); return dst; } else { // do not count invisible windows return WindowInfo (); } }
void _ecore_win32_event_handle_configure_notify(Ecore_Win32_Callback_Data *msg) { WINDOWINFO wi; Ecore_Win32_Event_Window_Configure *e; WINDOWPOS *window_pos; INF("window configure notify"); e = calloc(1, sizeof(Ecore_Win32_Event_Window_Configure)); if (!e) return; window_pos = (WINDOWPOS *)msg->data_param; wi.cbSize = sizeof(WINDOWINFO); if (!GetWindowInfo(window_pos->hwnd, &wi)) { free(e); return; } e->window = (void *)GetWindowLongPtr(msg->window, GWLP_USERDATA); e->abovewin = (void *)GetWindowLongPtr(window_pos->hwndInsertAfter, GWLP_USERDATA); e->x = wi.rcClient.left; e->y = wi.rcClient.top; e->width = wi.rcClient.right - wi.rcClient.left; e->height = wi.rcClient.bottom - wi.rcClient.top; e->timestamp = _ecore_win32_event_last_time; ecore_event_add(ECORE_WIN32_EVENT_WINDOW_CONFIGURE, e, NULL, NULL); }
static BOOL CALLBACK EnumWindowsProc (HWND win, LPARAM user){ EnumerateWindowSettings * settings = (EnumerateWindowSettings*) (user); DWORD process; GetWindowThreadProcessId (win, &process); if (settings->pid && settings->pid != process) { return TRUE; // skipping } WINDOWINFO info; GetWindowInfo(win, &info); char title [512] = ""; GetWindowText (win, title, (sizeof title) - 1); bool isVisible = (info.dwStyle & WS_VISIBLE) != 0; // bool isPopup = info.dwStyle & WS_POPUP; if (isVisible) { WindowInfo dst; dst.title = title; dst.id = (int64_t) win; // At least in Win7 Window Handles seem unique and could also be interpreted as IDs dst.pid = process; dst.area = dz::Rect(info.rcWindow.left, info.rcWindow.top, info.rcWindow.right - info.rcWindow.left, info.rcWindow.bottom - info.rcWindow.top); settings->destination->push_back (dst); } return TRUE; // continue enumeration }
bool IsTopLevelWindow(HWND hWnd) { WINDOWINFO wi = {0}; assert(GetWindowInfo(hWnd, &wi)); bool WS_VISIBLE_isSet = (wi.dwStyle & WS_VISIBLE) != 0; bool WS_EX_NOACTIVATE_isSet = (wi.dwExStyle & WS_EX_NOACTIVATE) != 0; bool WS_EX_TOOLWINDOW_isSet = (wi.dwExStyle & WS_EX_TOOLWINDOW) != 0; bool WS_EX_APPWINDOW_isSet = (wi.dwExStyle & WS_EX_APPWINDOW) != 0; bool WS_POPUP_isSet = (wi.dwStyle & WS_POPUP) != 0; bool WS_CHILD_isSet = (wi.dwStyle & WS_CHILD) != 0; if (!WS_VISIBLE_isSet || ((WS_EX_NOACTIVATE_isSet || WS_EX_TOOLWINDOW_isSet) && !WS_EX_APPWINDOW_isSet) || hWnd == 0 || WS_POPUP_isSet || WS_CHILD_isSet ) { return false; } else { return true; } }
/* * draw_scroll_button: * * This function draw scroll button of propsheet control . * * Author: Peng LIU * Date: 2007-12-05 */ static void draw_scroll_button (HWND hWnd, HDC hdc, RECT *title_rc, PPROPSHEETDATA propsheet, DWORD style) { RECT btn_rect = {0, 0, 0, 0}; WINDOWINFO *info; DWORD color; info = (WINDOWINFO*)GetWindowInfo (hWnd); color = GetWindowElementAttr (hWnd, WE_FGC_WINDOW); /* draw left arrow */ btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->top + 1 + 2 : title_rc->top + 1; btn_rect.right = get_metrics (MWM_SB_WIDTH); btn_rect.bottom = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->bottom + 2 - 2 : title_rc->bottom - 2 - 1; //SelectClipRect (hdc, &btn_rect); info->we_rdr->draw_arrow (hWnd, hdc, &btn_rect, color , LFRDR_ARROW_LEFT); /* draw right arrow */ btn_rect.left = propsheet->head_rc.right - get_metrics(MWM_SB_WIDTH); btn_rect.right = propsheet->head_rc.right; //SelectClipRect (hdc, &btn_rect); info->we_rdr->draw_arrow (hWnd, hdc, &btn_rect, color , LFRDR_ARROW_RIGHT); }
BOOL CPdd6410Uart::MapHardware() { if (m_pRegVirtualAddr !=NULL) { return TRUE; } // Get IO Window From Registry DDKWINDOWINFO dwi; if ( GetWindowInfo( &dwi)!=ERROR_SUCCESS || dwi.dwNumMemWindows < 1 || dwi.memWindows[0].dwBase == 0 || dwi.memWindows[0].dwLen < m_dwMemLen) { return FALSE; } DWORD dwInterfaceType; if (m_ActiveReg.IsKeyOpened() && m_ActiveReg.GetRegValue( DEVLOAD_INTERFACETYPE_VALNAME, (PBYTE)&dwInterfaceType,sizeof(DWORD))) { dwi.dwInterfaceType = dwInterfaceType; } // Translate to System Address. PHYSICAL_ADDRESS ioPhysicalBase = { dwi.memWindows[0].dwBase, 0}; ULONG inIoSpace = 0; if (TranslateBusAddr(m_hParent,(INTERFACE_TYPE)dwi.dwInterfaceType,dwi.dwBusNumber, ioPhysicalBase,&inIoSpace,&ioPhysicalBase)) { // Map it if it is Memeory Mapped IO. m_pRegVirtualAddr = MmMapIoSpace(ioPhysicalBase, dwi.memWindows[0].dwLen,FALSE); } return (m_pRegVirtualAddr!=NULL ); }
//Enumerates windows. BOOL CALLBACK enumWindowsProc(HWND hwnd, LPARAM lParam) { ZeroMemory(tbuffer, sizeof(wchar_t) * 2048); WINDOWINFO windowinfo; //Got a window by HWND: if (GetWindowTextW(hwnd, tbuffer, 2048) > 0) { if (GetWindowInfo(hwnd, &windowinfo)) { //Check if this is a "Window". if((windowinfo.dwStyle & WS_MINIMIZEBOX) && (windowinfo.dwStyle & WS_VISIBLE)) { if (wcsstr(tbuffer, L"CloseAllWindows.exe") == NULL) { wcout << "Got a window by HWND: " << hwnd << " " << tbuffer << "\n"; SendMessage(hwnd, WM_CLOSE, NULL, (LPARAM) 0); SendMessage(hwnd, WM_QUIT, NULL, (LPARAM) 0); SendMessage(hwnd, WM_DESTROY, NULL, (LPARAM) 0); } } } } return TRUE; }
static DWORD WINAPI drop_window_therad(void *arg) { struct DragParam *param = arg; WNDCLASSA cls; WINDOWINFO info; BOOL r; MSG msg; memset(&cls, 0, sizeof(cls)); cls.lpfnWndProc = drop_window_proc; cls.hInstance = GetModuleHandleA(NULL); cls.lpszClassName = "drop test"; RegisterClassA(&cls); param->hwnd = CreateWindowA("drop test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0); ok(param->hwnd != NULL, "CreateWindow failed: %d\n", GetLastError()); memset(&info, 0, sizeof(info)); info.cbSize = sizeof(info); r = GetWindowInfo(param->hwnd, &info); ok(r, "got %d\n", r); ok(!(info.dwExStyle & WS_EX_ACCEPTFILES), "got %08x\n", info.dwExStyle); DragAcceptFiles(param->hwnd, TRUE); memset(&info, 0, sizeof(info)); info.cbSize = sizeof(info); r = GetWindowInfo(param->hwnd, &info); ok(r, "got %d\n", r); ok((info.dwExStyle & WS_EX_ACCEPTFILES), "got %08x\n", info.dwExStyle); SetEvent(param->ready); while ((r = GetMessageA(&msg, NULL, 0, 0)) != 0) { if (r == (BOOL)-1) { ok(0, "unexpected return value, got %d\n", r); break; } DispatchMessageA(&msg); } DestroyWindow(param->hwnd); UnregisterClassA("drop test", GetModuleHandleA(NULL)); return 0; }
static void do_click(HWND window, DWORD down, DWORD up) { WINDOWINFO window_info; long x, y; SetForegroundWindow(GetParent(window)); window_info.cbSize=sizeof(window_info); GetWindowInfo(window, &window_info); /* The calculations below convert the coordinates so they are absolute * screen coordinates in 'Mickeys' as required by mouse_event. * In mickeys the screen size is always 65535x65535. */ x=window_info.rcWindow.left+g_x; if (x<window_info.rcWindow.left || x>=window_info.rcWindow.right) x=(window_info.rcWindow.right+window_info.rcWindow.left)/2; x=(x << 16)/GetSystemMetrics(SM_CXSCREEN); y=window_info.rcWindow.top+g_y; if (y<window_info.rcWindow.top || y>=window_info.rcWindow.bottom) y=(window_info.rcWindow.bottom+window_info.rcWindow.top)/2; y=(y << 16)/GetSystemMetrics(SM_CYSCREEN); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x, y, 0, 0); if (down) { mouse_event(MOUSEEVENTF_ABSOLUTE | down, x, y, 0, 0); if ((g_dragto_x > 0) && (g_dragto_y > 0)) { int i; long dx, dy; long step_per_x, step_per_y; long dragto_x, dragto_y; dragto_x=window_info.rcWindow.left+g_dragto_x; if (dragto_x<window_info.rcWindow.left || dragto_x>=window_info.rcWindow.right) dragto_x=(window_info.rcWindow.right+window_info.rcWindow.left)/2; dragto_x=(dragto_x << 16)/GetSystemMetrics(SM_CXSCREEN); dragto_y=window_info.rcWindow.top+g_dragto_y; if (dragto_y<window_info.rcWindow.top || dragto_y>=window_info.rcWindow.bottom) dragto_y=(window_info.rcWindow.bottom+window_info.rcWindow.top)/2; dragto_y=(dragto_y << 16)/GetSystemMetrics(SM_CYSCREEN); dx = g_dragto_x - g_x; dy = g_dragto_y - g_y; step_per_x = dx / 4; step_per_y = dy / 4; for (i = 0; i < 4; i++) { mouse_event(MOUSEEVENTF_MOVE, step_per_x, step_per_y, 0, 0); } x=dragto_x; y=dragto_y; } } if (up) mouse_event(MOUSEEVENTF_ABSOLUTE | up, x, y, 0, 0); }
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam) { WINDOWINFO windowinfo; GetWindowInfo(hwnd,&windowinfo); char buf[256]; buf[0]=buf[255]='\0'; GetClassName(hwnd,buf,255); fprintf(swfp,"'%s' %x %x\n",buf,hwnd,GetParent(hwnd)); return true; }
//---------------------------------------------------------------------------------------------- bool CWindow::IsMouseCursorInCurrentView() { if(GetFocus() != s_mCurrentViewWnd) return false; WINDOWINFO Wi; POINT CursorPos; GetCursorPos(&CursorPos); GetWindowInfo(s_mCurrentViewWnd, &Wi); return (CursorPos.x > Wi.rcClient.left) && (CursorPos.x < Wi.rcClient.right) && (CursorPos.y > Wi.rcClient.top) && (CursorPos.y < Wi.rcClient.bottom); }
static BOOL CALLBACK wnd_enum_proc(HWND curr_wnd, LPARAM unused(lp)) { if (curr_wnd != wnd && !IsIconic(curr_wnd)) { WINDOWINFO curr_wnd_info; curr_wnd_info.cbSize = sizeof(WINDOWINFO); GetWindowInfo(curr_wnd, &curr_wnd_info); if (class_atom == curr_wnd_info.atomWindowType) { first_wnd = first_wnd ?: curr_wnd; last_wnd = curr_wnd; }
static char* winDialogGetActiveWindowAttrib(Ihandle* ih) { WINDOWINFO wininfo; wininfo.cbSize = sizeof(WINDOWINFO); GetWindowInfo(ih->handle, &wininfo); if (wininfo.dwWindowStatus & WS_ACTIVECAPTION) return "Yes"; else return "No"; }
//---------------------------------------------------------------------------- // STDMETHODIMP CAnchoAddonService::updateWindow(INT aWindowId, LPDISPATCH aProperties) { if (!aProperties) { return E_INVALIDARG; } HWND hwnd = winIdToHWND(aWindowId); if (!isIEWindow(hwnd)) { return E_INVALIDARG; } CIDispatchHelper properties = aProperties; WINDOWINFO winInfo; winInfo.cbSize = sizeof(WINDOWINFO); BOOL res = GetWindowInfo(hwnd, &winInfo); int top = winInfo.rcWindow.top; int left = winInfo.rcWindow.left; int width = winInfo.rcWindow.right - winInfo.rcWindow.left; int height = winInfo.rcWindow.bottom - winInfo.rcWindow.top; bool shouldMove = SUCCEEDED((properties.Get<int, VT_I4>(L"top", top))); shouldMove = SUCCEEDED((properties.Get<int, VT_I4>(L"left", left))) || shouldMove; shouldMove = SUCCEEDED((properties.Get<int, VT_I4>(L"width", width))) || shouldMove; shouldMove = SUCCEEDED((properties.Get<int, VT_I4>(L"height", height))) || shouldMove; if (shouldMove) { ::MoveWindow(hwnd, left, top, width, height, TRUE); } bool focused = false; if (SUCCEEDED((properties.Get<bool, VT_BOOL, VARIANT_BOOL>(L"focused", focused)))) { if(focused) { ::SetForegroundWindow(hwnd); } else { //Bring to foreground next IE window HWND nextWin = hwnd; while (nextWin = GetNextWindow(nextWin, GW_HWNDNEXT)) { if (isIEWindow(hwnd)) { ::SetForegroundWindow(nextWin); break; } } } } std::wstring state; if ( SUCCEEDED((properties.Get<std::wstring, VT_BSTR, BSTR>(L"state", state)))) { if (state == L"maximized") { ::ShowWindow(hwnd, SW_MAXIMIZE); } else if (state == L"minimized") { ::ShowWindow(hwnd, SW_MINIMIZE); } else if (state == L"normal") { ::ShowWindow(hwnd, SW_NORMAL); } else if (state == L"fullscreen") { //TODO - fullscreen } } //TODO - drawAttention return S_OK; }
int MainWindow(HINSTANCE hInstance, int nCmdShow){ WNDCLASSEX ClassOfWindow; memset(&ClassOfWindow, 0, sizeof(WNDCLASSEX)); ClassOfWindow.cbSize = sizeof(WNDCLASSEX); ClassOfWindow.style = CS_VREDRAW | CS_HREDRAW; ClassOfWindow.lpfnWndProc = WinProcess; ClassOfWindow.hInstance = hInstance; ClassOfWindow.hIcon = (HICON)LoadImageA(NULL, "Icon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE); ClassOfWindow.hCursor = LoadCursor(NULL, IDC_ARROW); ClassOfWindow.hbrBackground = GetStockBrush(WHITE_BRUSH); ClassOfWindow.lpszClassName = TEXT("ClassOfWindow"); ClassOfWindow.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); if (!RegisterClassEx(&ClassOfWindow)) return MYERROR; glbHpenBomb = CreatePen(PS_SOLID, 2, RGB(0, 0, 0)); glbHpenGun = CreatePen(PS_SOLID, 2, RGB(0, 0, 0)); glbHpenGround = CreatePen(PS_SOLID, 2, RGB(0, 0, 0)); glbHbrushBomb = CreateSolidBrush(RGB(0xff, 0, 0)); glbHbrushStand = CreateSolidBrush(RGB(228, 228, 228)); glbHpenHoopVisible = CreatePen(PS_DASH, 2, RGB(0, 0, 0)); glbHpenHoopInvisible = CreatePen(PS_DASH, 2, RGB(228, 228, 228)); glbHbrushBackGround = CreateSolidBrush(RGB(228, 228, 228)); glbTotalEnd = FALSE; int xPosition = (GetSystemMetrics(SM_CXSCREEN) - WINDOW_WIDTH) / 2; HWND hwndMain = CreateWindow(ClassOfWindow.lpszClassName, TEXT("јЋЋј’ј Ѕј–"), WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, xPosition, 10, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL); if (!hwndMain) return MYERROR; _beginthread(UpdateImage, 0, &hwndMain); _beginthread(ChangeAngle, 0, &hwndMain); _beginthread(PhysicalProcesses, 0, &hwndMain); PWINDOWINFO pwi=malloc(sizeof(WINDOWINFO)); GetWindowInfo(hwndMain, pwi); pwi->rcClient; pwi->rcWindow; ShowWindow(hwndMain, nCmdShow); UpdateWindow(hwndMain); MSG message; // циклически обрабатываем сообщени¤ от окна while (TRUE) { if (glbTotalEnd == TRUE) return MYERROR; if (PeekMessage(&message, hwndMain, 0, 0, PM_REMOVE) != 0){ TranslateMessage(&message); DispatchMessage(&message); } } return 0; }
void WindowWin::WindowResize(unsigned int iWidth, unsigned int iHeight) { if(!m_bWndCreated) return; if(m_bFullscreen) return; ::RECT workArea; WINDOWINFO info; unsigned int iDescWidth; unsigned int iDescHeight; info.cbSize = sizeof(WINDOWINFO); GetWindowInfo(m_hWnd, &info); // Get work area (without taskbar and other toolbars) SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0); iDescWidth = workArea.right - workArea.left; iDescHeight = workArea.bottom - workArea.top; // compensate for window border if(info.cxWindowBorders && info.cyWindowBorders) { iWidth = iWidth + (info.rcClient.left - info.rcWindow.left) + (info.rcWindow.right - info.rcClient.right); iHeight = iHeight + (info.rcClient.top - info.rcWindow.top) + (info.rcWindow.bottom - info.rcClient.bottom); } // shift window if too large if(iWidth > iDescWidth) { info.rcWindow.left = workArea.left; iWidth = iDescWidth; } else if((info.rcWindow.left + iWidth) > iDescWidth) info.rcWindow.left -= ((iWidth + info.rcWindow.left) - iDescWidth); else if(info.rcWindow.left < workArea.left) info.rcWindow.left = workArea.left; if(iHeight > iDescHeight) { info.rcWindow.top = workArea.top; iHeight = iDescHeight; } else if((info.rcWindow.top + iHeight) > iDescHeight) info.rcWindow.top -= ((iHeight + info.rcWindow.top) - iDescHeight); else if(info.rcWindow.top < workArea.top) info.rcWindow.top = workArea.top; m_wndRect.x = info.rcWindow.left; m_wndRect.y = info.rcWindow.top; m_wndRect.width = iWidth; m_wndRect.height = iHeight; MoveWindow(m_hWnd, m_wndRect.x, m_wndRect.y, m_wndRect.width, m_wndRect.height, TRUE); }
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_CREATE: { WINDOWINFO wi; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(hwnd, &wi); RECT r; r = wi.rcClient; btn1 = CreateWindow(L"BUTTON", L"Refresh list", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 2, 2, r.right - r.left - 4, 24, hwnd, NULL, (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL); lb = CreateWindow(L"LISTBOX", NULL, WS_TABSTOP | WS_CHILD | WS_VISIBLE | LBS_STANDARD, 2, 28, r.right - r.left - 4, r.bottom - r.top - 44, hwnd, NULL, (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL); btn2 = CreateWindow(L"BUTTON", L"Make it borderless", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 2, r.bottom - r.top - 26, r.right - r.left - 4, 24, hwnd, NULL, (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL); SendMessage(lb, LB_RESETCONTENT, 0, 0); EnumWindows(EnumWindowsProc, 0); HFONT f; f = CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, L"Segoe UI"); SendMessage(hwnd, WM_SETFONT, (WPARAM) f, TRUE); SendMessage(btn1, WM_SETFONT, (WPARAM) f, TRUE); SendMessage(btn2, WM_SETFONT, (WPARAM) f, TRUE); f = CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, L"Courier New"); SendMessage(lb, WM_SETFONT, (WPARAM) f, TRUE); break; } case WM_COMMAND: if (HIWORD(wp) == BN_CLICKED) { if ((HWND) lp == btn1) { SendMessage(lb, LB_RESETCONTENT, 0, 0); EnumWindows(EnumWindowsProc, 0); } if ((HWND) lp == btn2) { UINT i = (UINT) SendMessage(lb, LB_GETCURSEL, 0, 0); LPWSTR x = (LPWSTR) LocalAlloc(LPTR, sizeof(WCHAR) * (UINT) SendMessage(lb, LB_GETTEXTLEN, i, 0)); SendMessage(lb, LB_GETTEXT, i, (LPARAM) x); Borderless(x); LocalFree(x); } } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); default: return DefWindowProc(hwnd, msg, wp, lp); } return 0; }
/* * * * ¨x¨x¨x¨x¨x¨x¨xtop_line(dark) * ---------top_line(light) * ¨† ¨‡ ¨‡¨† * left_line(dark+light) ¨† ¨‡ ¨‡¨†right_line(light+dark) * ¨† ¨‡ ¨‡¨† * base_line_left ¨{¨{¨{¨{¨{¨{¨{ ¨{¨{¨{¨{¨{¨{¨{ base_line_right */ static void draw_hilight_box (HWND hWnd, HDC hdc, COOL_INDICATOR_ITEMDATA* item) { int l,r,t,b; WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd); DWORD color; DWORD mainc = GetWindowElementAttr (hWnd, WE_FGC_THREED_BODY); //UI@hilight_box_color if(item == NULL) return; l = item->RcTitle.left; t = item->RcTitle.top + 2; r = item->RcTitle.right + 1; b = item->RcTitle.bottom + 1; color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l, t); LineTo (hdc, l, b); //left_line_dark MoveTo (hdc, r, t); LineTo (hdc, r, b); //right_line_dark MoveTo (hdc, l, t); LineTo (hdc, r, t); //top_line_dark color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTER); SetPenColor (hdc, RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), GetBValue (color), GetAValue (color))); MoveTo (hdc, l + 1, t); LineTo (hdc, l + 1, b); //left_line_light MoveTo (hdc, r - 1, t); LineTo (hdc, r - 1, b); //right_line_light MoveTo (hdc, l, t+1); LineTo (hdc, r, t+1); //top_line_light mainc = GetWindowElementPixelEx(hWnd, hdc, WE_FGC_THREED_BODY); //to avoid hdc use the color as ARGB SetBrushColor(hdc, mainc); //base line color RECT rP; GetWindowRect(GetParent(hWnd), &rP); int x, y, w, h; x = 0; y = item->RcTitle.bottom + 2; w = item->RcTitle.left + 2; h = 4; FillBox(hdc, x, y, w, h); //base_line_left x = item->RcTitle.right + 1; y = item->RcTitle.bottom + 2; w = RECTW(rP) - x; h = 4; FillBox(hdc, x, y, w, h); //base_line_right }
void Window::getClientRect(LPRECT rect) const { CHECK_INIT(); if(!rect) throw INVALID_ARGUMENT_EXCEPTION_1("rect"); WINDOWINFO wi; if(!GetWindowInfo(hwnd(), &wi)) throw WIN32EXCEPTION_1("GetWindowInfo"); memcpy(rect, &wi.rcClient, sizeof(RECT)); }
void taskbar::Flash() { WINDOWINFO WI={sizeof(WI)}; if (GetWindowInfo(Console().GetWindow(),&WI)) { if (WI.dwWindowStatus!=WS_ACTIVECAPTION) { FLASHWINFO FWI={sizeof(FWI),Console().GetWindow(),FLASHW_ALL|FLASHW_TIMERNOFG,5,0}; FlashWindowEx(&FWI); } } }