void DragOff(DOCKPANEL *dpp) { if(dpp->fUndockNextMsg) { POINT pt; dpp->fDragging = TRUE; dpp->fUndockNextMsg = FALSE; GetCursorPos(&pt); // position window so that the top/left of the *caption* // falls under the mouse pointer - this will ensure that the SC_MOVE // message makes the window move. (-20,-20) seems to do the trick dpp->xpos = pt.x - 20; dpp->ypos = pt.y - 20; if(dpp->fDocked) { // if the panel is docked... then undock it DockWindow(dpp); } else { // otherwise do nothing - it is already floating! SetWindowPos(dpp->hwndPanel, 0, dpp->xpos, dpp->ypos, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER); } dpp->fDragging = TRUE; DockPanel_SetKeyboardHook(dpp); SendMessage(dpp->hwndPanel, WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(dpp->xpos, dpp->ypos)); } }
void MainFrameBase::DockDockingWindow(DockingWindowBase& dockingWindow) { CSize dockSize = dockingWindow.GetDockingSize(); dockwins::CDockingSide dockSide = dockingWindow.GetPreferredDockingSide(); // TODO search proper bar to dock to int nBar = 0; DockWindow(dockingWindow, dockSide, nBar, float(0.0)/*fPctPos*/, dockSize.cx, dockSize.cy); }
LRESULT VirtualDimension::OnDisplayChange(HWND /*hWnd*/, UINT /*message*/, WPARAM /*wParam*/, LPARAM /*lParam*/) { RECT pos; GetWindowRect(m_hWnd, &pos); if (DockWindow(pos)) { if (!m_shrinked && m_autoHideDelay > 0) SetTimer(m_autoHideTimerId, m_autoHideDelay); //reset the timer, to avoid hiding the window during the resolution change, as it does not look very nice MoveWindow(m_hWnd, pos.left, pos.top, pos.right-pos.left, pos.bottom-pos.top, TRUE); } return 0; }
void CTabsDlg::HandleUndock() { TCITEM item; item.mask = TCIF_PARAM; int curSel = TabCtrl_GetCurSel(m_Tabs.GetSafeHwnd()); TabCtrl_GetItem(m_Tabs.GetSafeHwnd() , curSel , &item); DockedWindowInfo *info = (DockedWindowInfo *)item.lParam; ASSERT(info); DockWindow(info->m_ID , false); }
BOOL WINAPI DockWnd_Undock(HWND hwndMain, UINT uId) { DOCKWND *dwp; if((dwp = DOCKWNDFromId(hwndMain, uId)) != 0) { if(dwp->pDockPanel->fDocked == TRUE) { DockWindow(dwp->pDockPanel); } } return TRUE; }
void CTabsDlg::AddDockedWindow(CWnd *wnd , int ID , int imageID , const CString &title , bool dock , pfnOnDockEvent dockCallback) { DockedWindowInfo *info = NULL; m_Windows.Lookup((WORD)ID , (void* &)info); ASSERT(wnd); ASSERT(info == NULL); info = new DockedWindowInfo(wnd , ID , imageID , title , dockCallback); m_Windows.SetAt((WORD)ID , info); DockWindow(ID , dock); UpdateTabControlIndices(); }
/** Handle a dock event. */ void HandleDockEvent(const XClientMessageEvent *event) { Assert(event); switch(event->data.l[1]) { case SYSTEM_TRAY_REQUEST_DOCK: DockWindow(event->data.l[2]); break; case SYSTEM_TRAY_BEGIN_MESSAGE: break; case SYSTEM_TRAY_CANCEL_MESSAGE: break; default: Debug("invalid opcode in dock event"); break; } }
bool VirtualDimension::Start(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; RECT pos; Settings settings; HWND hwndPrev; DWORD dwStyle; // If a previous instance is running, activate // that instance and terminate this one. hwndPrev = FindWindow(); if (hwndPrev != NULL) { SetForegroundWindow (hwndPrev); return false; } m_hInstance = hInstance; InitHotkeyControl(); InitHyperLinkControl(); // Register the window class RegisterClass(); // Bind the message handlers SetCommandHandler(IDM_ABOUT, this, &VirtualDimension::OnCmdAbout); SetSysCommandHandler(IDM_ABOUT, this, &VirtualDimension::OnCmdAbout); SetCommandHandler(IDM_CONFIGURE, this, &VirtualDimension::OnCmdConfigure); SetSysCommandHandler(IDM_CONFIGURE, this, &VirtualDimension::OnCmdConfigure); SetCommandHandler(IDM_EXIT, this, &VirtualDimension::OnCmdExit); SetSysCommandHandler(SC_CLOSE, this, &VirtualDimension::OnCmdExit); SetCommandHandler(IDM_LOCKPREVIEWWND, this, &VirtualDimension::OnCmdLockPreviewWindow); SetSysCommandHandler(IDM_LOCKPREVIEWWND, this, &VirtualDimension::OnCmdLockPreviewWindow); SetCommandHandler(IDM_SHOWCAPTION, this, &VirtualDimension::OnCmdShowCaption); SetSysCommandHandler(IDM_SHOWCAPTION, this, &VirtualDimension::OnCmdShowCaption); SetMessageHandler(WM_DESTROY, this, &VirtualDimension::OnDestroy); SetMessageHandler(WM_ENDSESSION, this, &VirtualDimension::OnEndSession); SetMessageHandler(WM_MOVE, this, &VirtualDimension::OnMove); SetMessageHandler(WM_WINDOWPOSCHANGING, this, &VirtualDimension::OnWindowPosChanging); SetMessageHandler(WM_DISPLAYCHANGE, this, &VirtualDimension::OnDisplayChange); SetMessageHandler(WM_SHOWWINDOW, this, &VirtualDimension::OnShowWindow); SetMessageHandler(WM_LBUTTONDOWN, this, &VirtualDimension::OnLeftButtonDown); SetMessageHandler(WM_LBUTTONUP, this, &VirtualDimension::OnLeftButtonUp); SetMessageHandler(WM_LBUTTONDBLCLK, this, &VirtualDimension::OnLeftButtonDblClk); SetMessageHandler(WM_RBUTTONDOWN, this, &VirtualDimension::OnRightButtonDown); SetMessageHandler(WM_MEASUREITEM, this, &VirtualDimension::OnMeasureItem); SetMessageHandler(WM_DRAWITEM, this, &VirtualDimension::OnDrawItem); m_autoHideTimerId = CreateTimer(this, &VirtualDimension::OnTimer); SetMessageHandler(WM_ACTIVATEAPP, this, &VirtualDimension::OnActivateApp); SetMessageHandler(WM_MOUSEHOVER, this, &VirtualDimension::OnMouseHover); SetMessageHandler(WM_MOUSELEAVE, this, &VirtualDimension::OnMouseLeave); SetMessageHandler(WM_NCHITTEST, this, &VirtualDimension::OnNCHitTest); SetMessageHandler(WM_VD_HOOK_MENU_COMMAND, this, &VirtualDimension::OnHookMenuCommand); SetMessageHandler(WM_VD_PREPARE_HOOK_MENU, this, &VirtualDimension::OnPrepareHookMenu); SetMessageHandler(WM_VD_CHECK_MIN_TO_TRAY, this, &VirtualDimension::OnCheckMinToTray); // compare the window's style m_hasCaption = settings.LoadSetting(Settings::HasCaption); dwStyle = WS_POPUP | WS_SYSMENU | (m_hasCaption ? WS_CAPTION : WS_DLGFRAME); // Reload the window's position settings.LoadSetting(Settings::WindowPosition, &pos); AdjustWindowRectEx(&pos, dwStyle, FALSE, WS_EX_TOOLWINDOW); // Dock the window to the screen borders m_dockedBorders = settings.LoadSetting(Settings::DockedBorders); DockWindow(pos); // Create the main window Create( WS_EX_TOOLWINDOW, m_szWindowClass, m_szTitle, dwStyle, pos.left, pos.top, pos.right - pos.left, pos.bottom - pos.top, NULL, NULL, hInstance); if (!IsValid()) return false; hWnd = *this; // Load some settings m_snapSize = settings.LoadSetting(Settings::SnapSize); m_autoHideDelay = settings.LoadSetting(Settings::AutoHideDelay); m_shrinked = false; m_tracking = false; //Ensure the window gets docked if it is close enough to the borders SetWindowPos(hWnd, NULL, pos.left, pos.top, pos.right - pos.left, pos.bottom - pos.top, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOOWNERZORDER); // Setup the system menu m_pSysMenu = GetSystemMenu(hWnd, FALSE); if (m_pSysMenu != NULL) { RemoveMenu(m_pSysMenu, SC_RESTORE, MF_BYCOMMAND); RemoveMenu(m_pSysMenu, SC_MINIMIZE, MF_BYCOMMAND); RemoveMenu(m_pSysMenu, SC_MAXIMIZE, MF_BYCOMMAND); RemoveMenu(m_pSysMenu, SC_MOVE, MF_BYCOMMAND); RemoveMenu(m_pSysMenu, SC_SIZE, MF_BYCOMMAND); RemoveMenu(m_pSysMenu, 0, MF_BYCOMMAND); AppendMenu(m_pSysMenu, MF_SEPARATOR, 0, NULL); AppendMenu(m_pSysMenu, MF_STRING, IDM_CONFIGURE, Locale::GetInstance().GetString(IDS_CONFIGURE)); //"C&onfigure" AppendMenu(m_pSysMenu, MF_STRING, IDM_LOCKPREVIEWWND, Locale::GetInstance().GetString(IDS_LOCKPREVIEWWND)); //"&Lock the window" AppendMenu(m_pSysMenu, MF_STRING, IDM_SHOWCAPTION, Locale::GetInstance().GetString(IDS_SHOWCAPTION)); //"S&how the caption" if (CreateLangMenu()) AppendMenu(m_pSysMenu, MF_STRING|MF_POPUP, (UINT_PTR)m_pLangMenu, Locale::GetInstance().GetString(IDS_LANGUAGEMENU)); //"L&anguage" AppendMenu(m_pSysMenu, MF_STRING, IDM_ABOUT, Locale::GetInstance().GetString(IDS_ABOUT)); //"&About" CheckMenuItem(m_pSysMenu, IDM_SHOWCAPTION, m_hasCaption ? MF_CHECKED : MF_UNCHECKED ); } // Lock the preview window as appropriate LockPreviewWindow(settings.LoadSetting(Settings::LockPreviewWindow)); // Bind to explorer explorerWrapper = new ExplorerWrapper(this); // Initialize the tray icon manager trayManager = new TrayIconsManager(); // Initialize tray icon trayIcon = new TrayIcon(hWnd); // Initialize transparency (set value two times, to make a fade-in) transp = new Transparency(hWnd); transp->SetTransparencyLevel(0); transp->SetTransparencyLevel(settings.LoadSetting(Settings::TransparencyLevel), true); // Initialize always on top state ontop = new AlwaysOnTop(hWnd); ontop->SetAlwaysOnTop(settings.LoadSetting(Settings::AlwaysOnTop)); // Create the tooltip tooltip = new ToolTip(hWnd); // Create mouse warp mousewarp = new MouseWarp(); // Create the windows manager winMan = new WindowsManager; // Create the desk manager settings.LoadSetting(Settings::WindowPosition, &pos); //use client position deskMan = new DesktopManager(pos.right - pos.left, pos.bottom - pos.top); // Retrieve the initial list of windows winMan->PopulateInitialWindowsSet(); //Update tray icon tooltip trayIcon->Update(); //Bind some additional message handlers (which need the desktop manager) SetMessageHandler(WM_SIZE, this, &VirtualDimension::OnSize); SetMessageHandler(WM_PAINT, deskMan, &DesktopManager::OnPaint); // Show window if needed if (m_isWndVisible = (settings.LoadSetting(Settings::ShowWindow) || !trayIcon->HasIcon())) { ShowWindow(hWnd, nCmdShow); Refresh(); } return true; }
// // Called when the dockpanel has stopped being dragged around // need to decide whether to dock/undock/leave it as it is // LRESULT DockPanel_ExitSizeMove(DOCKPANEL *dpp) { extern HWND hwndTransPanel; DestroyWindow(hwndTransPanel); hwndTransPanel = 0; DockPanel_RemoveKeyboardHook(dpp); dpp->fUndockNextMsg = FALSE; if(dpp->fDragging) { DOCKSERVER *dsp = dpp->pDockServer; DOCKPANEL *dppUnder; RECT rectDrag; POINT pt; UINT area; HWND hwnd; DestroyWindow(hwndTransPanel); hwndTransPanel = 0; dpp->fDragging = FALSE; GetCursorPos(&pt); area = GetDockTarget(dpp->pDockServer, dpp, pt, &rectDrag, &dppUnder); // did we want to dock onto anything? if(area != 0)//dpp->fDragStatus || g_dppTargetDockPanel) { ShowWindow(dpp->hwndPanel, SW_HIDE); RemoveWindowTrans(dpp->hwndPanel); // docking onto an existing DOCKPANEL (i.e. not the main window, // but becoming a tab in another panel) if(area == TAB) { // move all DOCKWNDs in the current panel to the DOCKPANEL // that we are dragging on to DOCKWND *dwp, *next = 0; for(dwp = dpp->WndListHead->flink; dwp != dpp->WndListTail; dwp = next)//dwp->flink) { next = dwp->flink; SetDockPanel(dppUnder, dwp); DockWnd_Show(dpp->hwndMain, dwp->uWndId, TRUE); } UpdateDockTabView(dppUnder); // oof! RemoveObj(dpp); hwnd = dpp->hwndPanel; dpp->hwndPanel = 0; DestroyWindow(hwnd);//dpp->hwndPanel); } // otherwise dock with the main window else { // if docking on the inside, // move to end of dock-panel list if(dppUnder == (DOCKPANEL *)1) // NASTY HACK!! WHY!??? { RemoveObj(dpp); InsertBefore(dpp, dsp->PanelListTail); } // if docking else if(dppUnder) { if( area == TOP && (dppUnder->dwStyle & BOTTOM) || area == BOTTOM && (dppUnder->dwStyle & TOP) || area == LEFT && (dppUnder->dwStyle & RIGHT) || area == RIGHT && (dppUnder->dwStyle & LEFT)) { // inside of target panel RemoveObj(dpp); InsertBefore(dpp, dppUnder->flink); if(area == TOP) area = BOTTOM; else if(area == BOTTOM) area = TOP; else if(area == LEFT) area = RIGHT; else if(area == RIGHT) area = LEFT; } else if( area == TOP && (dppUnder->dwStyle & TOP) || area == BOTTOM && (dppUnder->dwStyle & BOTTOM) || area == LEFT && (dppUnder->dwStyle & LEFT) || area == RIGHT && (dppUnder->dwStyle & RIGHT)) { // outside of target panel RemoveObj(dpp); InsertBefore(dpp, dppUnder); } } // if docking against the outside edge else { RemoveObj(dpp); InsertBefore(dpp, dsp->PanelListHead->flink); } dpp->dwStyle = (dpp->dwStyle & ~DWS_DOCKED_MASK) | area; DockWindow(dpp); } ShowWindow(dpp->hwndPanel, SW_SHOW); } dpp->fDragging = FALSE; dpp->fDragStatus = 0; } // if the dock-panel is still floating, determine if it's edges // intersect the main window, and turn on the 'sticky' flag if(dpp->fDocked == FALSE) { RECT r1, r2, r3; GetWindowRect(dpp->hwndMain, &r2); GetWindowRect(dpp->hwndPanel, &r3); dpp->fSticky = IntersectRect(&r1, &r2, &r3); } return 0; }