Example #1
0
BOOL EnsureWindowVisible(CRect *pcrRect)
{
	int nMonitor = GetMonitorFromRect(pcrRect);
	if(nMonitor < 0)
	{
		GetMonitorRect(0, pcrRect);
		pcrRect->right = pcrRect->left + 300;
		pcrRect->bottom = pcrRect->top + 300;

		return TRUE;
	}

	CRect crMonitor;
	GetMonitorRect(nMonitor, crMonitor);

	//Validate the left
	long lDiff = pcrRect->left - crMonitor.left;
	if(lDiff < 0)
	{
		pcrRect->left += abs(lDiff);
		pcrRect->right += abs(lDiff);
	}

	//Right side
	lDiff = pcrRect->right - crMonitor.right;
	if(lDiff > 0)
	{
		pcrRect->left -= abs(lDiff);
		pcrRect->right -= abs(lDiff);
	}

	//Top
	lDiff = pcrRect->top - crMonitor.top;
	if(lDiff < 0)
	{
		pcrRect->top += abs(lDiff);
		pcrRect->bottom += abs(lDiff);
	}

	//Bottom
	lDiff = pcrRect->bottom - crMonitor.bottom;
	if(lDiff > 0)
	{
		pcrRect->top -= abs(lDiff);
		pcrRect->bottom -= abs(lDiff);
	}

	return TRUE;
}
Example #2
0
bool BBP_read_window_modes(struct plugin_info *PI, const char *rcfile)
{
    if (0 == PI->rcpath[0])
        BBP_get_rcpath(PI->rcpath, PI->hInstance, rcfile);

    PI->xpos = BBP_read_int(PI,  "position.x", 20);
    PI->ypos = BBP_read_int(PI,  "position.y", 20);

    const char *place_string = BBP_read_string(PI, NULL, "placement", NULL);
    if (place_string)
        PI->place = BBP_get_placement(place_string);

    PI->hMon = GetMonitorRect(&PI->xpos, &PI->mon_rect, GETMON_FROM_POINT);
    set_place(PI);

    PI->useSlit         = BBP_read_bool(PI, "useSlit", false);
    PI->alwaysOnTop     = BBP_read_bool(PI, "alwaysOnTop", false);
    PI->autoHide        = BBP_read_bool(PI, "autoHide", false);
    PI->snapWindow      = BBP_read_int(PI, "snapWindow", 20);
    PI->pluginToggle    = BBP_read_bool(PI, "pluginToggle", true);
    PI->clickRaise      = BBP_read_bool(PI, "clickRaise", true);
	PI->transparent     = BBP_read_bool(PI, "transparent", false);
    PI->alphaValue      = (BYTE)eightScale_up(BBP_read_int(PI,  "alpha.value",  *(int *)GetSettingPtr(SN_MENUALPHA)));
    PI->orient_vertical = PI->is_bar || 0 == stricmp("vertical", BBP_read_string(PI, NULL, "orientation", "vertical"));
	if (false == PI->no_icons)
	{
		PI->saturation		= eightScale_up(BBP_read_int(PI,  "icon.saturation", 3));
		PI->hue				= eightScale_up(BBP_read_int(PI,  "icon.hue", 2));
	}
    if (NULL == place_string) {
        BBP_write_window_modes(PI);
        return false;
    }
    return true;
}
Example #3
0
void setup_ratio(Desk *f, HWND hwnd, int width, int height)
{
    f->mon = GetMonitorRect(hwnd, &f->mon_rect, GETMON_FROM_WINDOW);
    f->v_rect.left = f->v_rect.top = 0;
    f->v_rect.right  = imax(1, width - 2*f->v_rect.left);
    f->v_rect.bottom = imax(1, height - 2*f->v_rect.top);
}
Example #4
0
//
// these methods return true if any part of the item intersects the monitor rect
BOOL CMonitor::IsOnMonitor(const POINT& pt) const
{
    CRect rect;
    GetMonitorRect(rect);

    return rect.PtInRect(pt);
}
Example #5
0
BOOL CMonitor::IsOnMonitor(const LPRECT lprc) const
{
    CRect rect;
    GetMonitorRect(rect);

    return rect.IntersectRect(rect, lprc);
}
Example #6
0
void BBP_reconfigure(plugin_info *PI)
{
    if (false == PI->inSlit)
        GetMonitorRect(PI->hMon, &PI->mon_rect, GETMON_FROM_MONITOR);

    InvalidateRect(PI->hwnd, NULL, FALSE);
    BBP_set_window_modes(PI);
}
Example #7
0
int  CMonitor::GetWorkArea(CRect *rc)
{
	int nWinVersion;
	char chOsName[128];

	nWinVersion = GetOSVersionInfo(chOsName);
	
	CPoint pt;
    GetCursorPos(&pt);

	if (nWinVersion == OS_WIN2000 || nWinVersion == OS_WINXP || nWinVersion >= OS_VISTA)
	{
		int nCount = GetMonitorCount();

		if (nCount > 1)//bIsMultiMax)
		{
			CRect			rcMon;

			rc->SetRectEmpty();

			for(int i = 0; i < nCount; i++)
			{
				rcMon = GetMonitorRect(i);
				
				rc->left = __min(rc->left, rcMon.left);
				rc->top = __min(rc->top, rcMon.top);
				rc->right = __max(rc->right, rcMon.right);
				rc->bottom = __min(rc->bottom, rcMon.bottom);
				if(rc->bottom <= 100)
					rc->bottom = __max(rc->bottom, rcMon.bottom);
			}
		}
		else
		{
			MONITORINFO		mtCursor, mtMenu;

			mtCursor.cbSize = sizeof(mtCursor);
			mtMenu.cbSize   = sizeof(mtMenu);

			HMONITOR hmtCursor = ::MonitorFromPoint (pt, MONITOR_DEFAULTTOPRIMARY);

			if (GetMonitorInfo (hmtCursor, &mtCursor))
			{
				*rc = mtCursor.rcWork;
			}
			else
			{
				SystemParametersInfo (SPI_GETWORKAREA, 0, rc, 0);
			}
		}
	}
	else
	{
		SystemParametersInfo (SPI_GETWORKAREA, 0, rc, 0);
	}

	return 1;
}
Example #8
0
//===========================================================================
// Function: EditBox
// Purpose: Display a single line editcontrol
// In:
// Out:
//===========================================================================
BOOL CALLBACK dlgproc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static char *buffer;
	switch ( msg )
	{
	case WM_INITDIALOG:
		SetWindowText (hDlg, ((char**)lParam)[0]);
		SetDlgItemText(hDlg, 401, ((char**)lParam)[1]);
		SetDlgItemText(hDlg, 402, ((char**)lParam)[2]);
		buffer = ((char**)lParam)[3];
		MakeSticky(hDlg);
		{
			POINT p;
			GetCursorPos(&p);
			RECT m;
			GetMonitorRect(&p, &m, GETMON_WORKAREA|GETMON_FROM_POINT);
			RECT r;
			GetWindowRect(hDlg, &r);
#if 0
			// at cursor
			r.right -= r.left;
			r.bottom -= r.top;
			p.x = iminmax(p.x - r.right / 2,  m.left, m.right - r.right);
			p.y = iminmax(p.y - 10,  m.top, m.bottom - r.bottom);
#else
			// center screen
			p.x = (m.left + m.right - r.right + r.left) / 2;
			p.y = (m.top + m.bottom - r.bottom + r.top) / 2;
#endif
			SetWindowPos(hDlg, NULL, p.x, p.y, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
		}
		return 1;

	case WM_MOUSEMOVE:
	case WM_NCMOUSEMOVE:
		SetForegroundWindow(hDlg);
		break;

	case WM_COMMAND:
		switch ( LOWORD( wParam ))
		{
		case IDOK:
			GetDlgItemText (hDlg, 402, buffer, 256);
		case IDCANCEL:
			RemoveSticky(hDlg);
			EndDialog(hDlg, LOWORD(wParam));
			return 1;
		}

	default:
		break;
	}
	return 0;
}
Example #9
0
bool search_fullscreen_app(){	
	HWND fg_hwnd = GetForegroundWindow();
	LONG style = GetWindowLong(fg_hwnd, GWL_STYLE);
	if (WS_CAPTION == (style & WS_CAPTION))
		return false;
	RECT s;
	fullscreen_app_hMon = GetMonitorRect(fg_hwnd, &s, GETMON_FROM_WINDOW);
	RECT r;
	GetWindowRect(fg_hwnd, &r);
	return r.right - r.left >= s.right - s.left && r.bottom - r.top >= s.bottom - s.top;
}
Example #10
0
BOOL CMonitor::IsOnMonitor(const CWnd* pWnd) const
{
    CRect rect;
    GetMonitorRect(rect);

    ASSERT(::IsWindow(pWnd->GetSafeHwnd()));
    CRect wndRect;
    pWnd->GetWindowRect(&wndRect);

    return rect.IntersectRect(rect, wndRect);
}
Example #11
0
void CMonitor::ClipRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) const
{
    int w = lprc->right - lprc->left;
    int h = lprc->bottom - lprc->top;

    CRect rect;
    if ( UseWorkAreaRect )
        GetWorkAreaRect( &rect );
    else
        GetMonitorRect( &rect );

    lprc->left = max( rect.left, min( rect.right - w, lprc->left ) );
    lprc->top = max( rect.top, min( rect.bottom - h, lprc->top ) );
    lprc->right = lprc->left + w;
    lprc->bottom = lprc->top  + h;
}
Example #12
0
//these two center methods are adapted from David Campbell's
//MSJ article (see comment at the top of the header file)
void CMonitor::CenterRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) const
{
    int  w = lprc->right - lprc->left;
    int  h = lprc->bottom - lprc->top;

    CRect rect;
    if ( UseWorkAreaRect )
        GetWorkAreaRect( &rect );
    else
        GetMonitorRect( &rect );

    lprc->left = rect.left + ( rect.Width() - w ) / 2;
    lprc->top = rect.top + ( rect.Height() - h ) / 2;
    lprc->right	= lprc->left + w;
    lprc->bottom = lprc->top + h;
}
BOOL BackupDB(CString dbPath, CString prefix, CDittoPopupWindow **popUpMsg)
{
	if ((*popUpMsg) == NULL)
	{
		CRect r;
		GetMonitorRect(0, r);
		*popUpMsg = new CDittoPopupWindow();
		(*popUpMsg)->Create(CRect(r.right - 400, r.bottom - 100, r.right - 10, r.bottom - 10), NULL);		
		::SetWindowPos((*popUpMsg)->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
		(*popUpMsg)->ShowWindow(SW_SHOW);
		(*popUpMsg)->UpdateText(_T("Backing up Ditto's Database"));
	}
	CString backup = GetFilePath(dbPath);

	CInternetUpdate update;

	long runningVersion = update.GetRunningVersion();
	CString versionString = update.GetVersionString(runningVersion);

	backup += GetFileName(dbPath) += _T("_") + prefix + _T("_") + versionString;
	backup.Replace(_T(".db"), _T(""));
	backup.Replace(_T("."), _T("_"));

	CString temp = backup;

	temp += _T(".db");

	int i = 1;
	while(FileExists(temp))
	{
		temp.Format(_T("%s_%d.db"), backup, i);
		i++;
	}

	backup = temp;

	BOOL ret = CopyFile(dbPath, backup, TRUE);

	if ((*popUpMsg) != NULL)
	{
		(*popUpMsg)->UpdateText(_T("Running Ditto database scripts"));
	}

	return ret;
}
Example #14
0
HDC CMonitor::CreateDC() const
{
	ASSERT( IsMonitor() );

	CString name;
	GetName( name );

	HDC hdc = ::CreateDC( name, name, NULL, NULL );
	ASSERT( hdc != NULL );

	CRect rect;
	GetMonitorRect( &rect );

	::SetViewportOrgEx( hdc, -rect.left, -rect.top, NULL );
	::SetViewportExtEx( hdc, rect.Width(), rect.Height(), NULL );

	return hdc;
}
Example #15
0
// creates an HDC for the monitor
// it is up to the client to call DeleteDC
//
// for normal multimonitor drawing it is not necessary to get a
// dc for each monitor. Windows takes care of drawing correctly
// on all monitors
//
// Only very exacting applications would need a DC for each monitor
HDC CMonitor::CreateDC() const
{
    ASSERT(IsMonitor());

    CString name;
    GetName(name);

    //create a dc for this display
    HDC hdc = ::CreateDC(name, name, nullptr, nullptr);
    ASSERT(hdc != nullptr);

    //set the viewport based on the monitor rect's relation to the primary monitor
    CRect rect;
    GetMonitorRect(&rect);

    ::SetViewportOrgEx(hdc, -rect.left, -rect.top, nullptr);
    ::SetViewportExtEx(hdc, rect.Width(), rect.Height(), nullptr);

    return hdc;
}
void CMainFrame::ShowErrorMessage(CString csTitle, CString csMessage)
{
    Log(StrF(_T("ShowErrorMessage %s - %s"), csTitle, csMessage));

    CToolTipEx *pErrorWnd = new CToolTipEx;
    pErrorWnd->Create(this);
    pErrorWnd->SetToolTipText(csTitle + "\n\n" + csMessage);

    CPoint pt;
    CRect rcScreen;
    GetMonitorRect(0, &rcScreen);
    pt = rcScreen.BottomRight();

    CRect cr = pErrorWnd->GetBoundsRect();

    pt.x -= max(cr.Width() + 50, 150);
    pt.y -= max(cr.Height() + 50, 150);

    pErrorWnd->Show(pt);
    pErrorWnd->HideWindowInXMilliSeconds(4000);
}
Example #17
0
static BOOL TaskEnumFunc(const struct tasklist *p, LPARAM lParam)
{
    HWND hwnd = p->hwnd;
    Desk *f = (Desk*)lParam;
    int n;
    for (n = 0;;)
    {
        winStruct ws;
        memset(&ws, 0, sizeof ws);

        if (false == GetTaskLocation(hwnd, &ws.info))
            break;

        if (GetMonitorRect(hwnd, NULL, GETMON_FROM_WINDOW) != f->mon)
            break;

        ws.hwnd = hwnd;
        ws.iconic = FALSE != IsIconic(hwnd);
        ws.active = p->active;
        ws.index = 0;

        if (0 == ws.info.width && 0 == ws.info.height && !ws.iconic)
        {
            if (2 == ++n)
                break;
            hwnd = GetLastActivePopup(hwnd);
            continue;
        }

        winStruct *p = new winStruct(ws);
        p->next = f->winList;
        f->winList = p;

        ++f->winCount;
        break;
    }
    return TRUE;
}
Example #18
0
void Helpers::GetMonitorRect(HWND hWnd, CRect& rectMonitor)
{
    HMONITOR hMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
    GetMonitorRect(hMonitor, true, rectMonitor);
}
Example #19
0
BOOL CToolTipEx::Show(CPoint point)
{
	m_reducedWindowSize = false;
    if(m_pBitmap)
    {
        m_RichEdit.ShowWindow(SW_HIDE);
    }
    else
    {
        m_RichEdit.ShowWindow(SW_SHOW);
    }

	CRect rect;

	if(CGetSetOptions::GetSizeDescWindowToContent() == FALSE)
	{
		rect.left = point.x;
		rect.top = point.y;
		CSize size;
		CGetSetOptions::GetDescWndSize(size);
		rect.right = rect.left + size.cx;
		rect.bottom = rect.top + size.cy;

		EnsureWindowVisible(&rect);
	}
	else
	{
		rect = GetBoundsRect();

		//account for the scroll bars
		rect.right += 20;
		rect.bottom += 20;

		if (m_pBitmap)
		{
			int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
			int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);

			rect.right = rect.left + nWidth;
			rect.bottom = rect.top + nHeight;
		}
		else if(m_csRTF != "")
		{
			//if showing rtf then increase the size because
			//rtf will probably draw bigger
			long lNewWidth = (long)rect.Width() + (long)(rect.Width() *1.5);
			rect.right = rect.left + lNewWidth;

			long lNewHeight = (long)rect.Height() + (long)(rect.Height() *1.5);
			rect.bottom = rect.top + lNewHeight;
		}

		rect.right += CAPTION_BORDER * 2;
		rect.bottom += CAPTION_BORDER * 2;

		

		CRect rcScreen;

		ClientToScreen(rect);

		CRect cr(point, point);

		int nMonitor = GetMonitorFromRect(&cr);
		GetMonitorRect(nMonitor, &rcScreen);

		//ensure that we don't go outside the screen
		if(point.x < 0)
		{
			point.x = 5;
			m_reducedWindowSize = true;
		}
		if(point.y < 0)
		{
			point.y = 5;
			m_reducedWindowSize = true;
		}

		rcScreen.DeflateRect(0, 0, 5, 5);

		long lWidth = rect.Width();
		long lHeight = rect.Height();

		rect.left = point.x;
		rect.top = point.y;
		rect.right = rect.left + lWidth;
		rect.bottom = rect.top + lHeight;
		
		if (rect.right > rcScreen.right)
		{
			rect.right = rcScreen.right;
			m_reducedWindowSize = true;
		}
		if (rect.bottom > rcScreen.bottom)
		{
			rect.bottom = rcScreen.bottom;
			m_reducedWindowSize = true;
		}
	}

    SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height
                 (), SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOACTIVATE |
                 SWP_NOZORDER);

    return TRUE;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if(CFrameWnd::OnCreate(lpCreateStruct) ==  - 1)
    {
        return  - 1;
    }

    //Center the main window so message boxes are in the center
    CRect rcScreen;
    GetMonitorRect(0, &rcScreen);
    CPoint cpCenter = rcScreen.CenterPoint();
    //MoveWindow(cpCenter.x, cpCenter.x,  - 2,  - 2);

    //Then set the main window to transparent so it's never shown
    //if it is shown then only the task tray icon
    //m_Transparency.SetTransparent(m_hWnd, 0, true);

    SetWindowText(_T(""));

    Log(_T("Setting polling timer to track focus"));
    SetTimer(ACTIVE_WINDOW_TIMER, g_Opt.FocusWndTimerTimeout(), 0);

	SetTimer(READ_RANDOM_DB_FILE, g_Opt.ReadRandomFileInterval() * 1000, 0);

    SetWindowText(_T("Ditto"));

    HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

    m_TrayIcon.Create(NULL, WM_ICON_NOTIFY, _T("Ditto"), hIcon, IDR_MENU, FALSE, _T(""), _T(""), NULL, 20);
    m_TrayIcon.SetSingleClickSelect(TRUE);
    m_TrayIcon.MinimiseToTray(this);
    m_TrayIcon.SetMenuDefaultItem(ID_FIRST_SHOWQUICKPASTE, FALSE);

    //Only if in release
    #ifndef _DEBUG
        {
            //If not showing the icon show it for 40 seconds so they can get to the option
            //in case they can't remember the hot keys or something like that
            if(!(CGetSetOptions::GetShowIconInSysTray()))
            {
                SetTimer(HIDE_ICON_TIMER, 40000, 0);
            }
        }
    #endif 

    //SetTimer(CLOSE_WINDOW_TIMER, ONE_HOUR*24, 0);
    SetTimer(REMOVE_OLD_REMOTE_COPIES, ONE_DAY, 0);
    SetTimer(REMOVE_OLD_ENTRIES_TIMER, ONE_MINUTE*15, 0);

	//found on some computers GetTickCount gettickcount returns a smaller value than other, can't explain
	//check here to see if we need to make an adjustment
	IdleSeconds();

    m_ulCopyGap = CGetSetOptions::GetCopyGap();

    theApp.AfterMainCreate();

    m_thread.Start(this);

    return 0;
}
Example #21
0
void Helpers::GetDesktopRect(HWND hWnd, CRect& rectDesktop)
{
    HMONITOR hMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
    GetMonitorRect(hMonitor, false, rectDesktop);
}
Example #22
0
int get_place(plugin_info *PI)
{
    int sw, sh, x, y, w, h;
    bool top, vcenter, bottom, left, center, right;

	// multimon - current monitor
    PI->hMon = GetMonitorRect(PI->hwnd, &PI->mon_rect, GETMON_FROM_WINDOW);

    sw  = PI->mon_rect.right  - PI->mon_rect.left;
    sh  = PI->mon_rect.bottom - PI->mon_rect.top;
    x   = PI->xpos - PI->mon_rect.left;
    y   = PI->ypos - PI->mon_rect.top;
    w   = PI->width;
    h   = PI->height;

    x = iminmax(x, 0, sw - w);
    y = iminmax(y, 0, sh - h);

    top        = y == 0;
    vcenter    = y == sh/2 - h/2;
    bottom     = y == (sh - h);

    left       = x == 0;
    center     = x == sw/2 - w/2;
    right      = x == (sw - w);

    if (top)
    {
        if (left)   return POS_TopLeft   ;
        if (center) return POS_TopCenter ;
        if (right)  return POS_TopRight  ;
        return POS_Top;
    }

    if (bottom)
    {
        if (left)   return POS_BottomLeft   ;
        if (center) return POS_BottomCenter ;
        if (right)  return POS_BottomRight  ;
        return POS_Bottom;
    }

    if (left)
    {
        if (vcenter) return POS_CenterLeft;
        return POS_Left;
    }

    if (right)
    {
        if (vcenter) return POS_CenterRight;
        return POS_Right;
    }

    if (center)
    {
        if (vcenter) return POS_Center;
        return POS_CenterH;
    }

    if (vcenter)
        return POS_CenterV;
    return POS_User;
}
Example #23
0
LRESULT CALLBACK BBP_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static UINT msgs[] = { BB_RECONFIGURE, BB_BROADCAST, BB_DESKCLICK, 0};

    LRESULT Result = 0;
    plugin_info *PI  = (plugin_info *)GetWindowLongPtr(hwnd, 0);

    //dbg_printf("message %x", message);

    if (NULL == PI)
    {
        if (WM_NCCREATE == message)
        {
            // bind the window to the structure
            PI = (plugin_info *)((CREATESTRUCT*)lParam)->lpCreateParams;
            PI->hwnd = hwnd;
            SetWindowLongPtr(hwnd, 0, (LONG_PTR)PI);
        }
        return DefWindowProc(hwnd, message, wParam, lParam);
    }

    switch (message)
    {
        case WM_CREATE:
            SendMessage(GetBBWnd(), BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            MakeSticky(hwnd);
            goto pass_nothing;

        case WM_DESTROY:
            SendMessage(GetBBWnd(), BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            RemoveSticky(hwnd);
            goto pass_nothing;

        // ==========
        case BB_BROADCAST:
        {
            const char *temp = (LPCSTR)lParam;
            int f, len;

            if (0 == stricmp(temp, "@BBShowPlugins")) {
                PI->toggled_hidden = false;
                BBP_set_window_modes(PI);
                goto pass_result;
            }
            if (0 == stricmp(temp, "@BBHidePlugins")) {
                if (PI->pluginToggle) {
                    PI->toggled_hidden = true;
                    BBP_set_window_modes(PI);
                }
                goto pass_result;
            }

            if ('@' != *temp++)
                goto pass_nothing;

            len = PI->broam_key_len;
            if (len && 0 == memicmp(temp, PI->broam_key, len) && '.' == temp[len]) {
                f = 0;
                temp += len + 1;
                goto do_broam;
            }

            if (PI->next)
                goto pass_nothing;

            len = PI->broam_key_len_common;
            if (len && 0 == memicmp(temp, PI->broam_key, len)) {
                f = BBP_BROAM_COMMON;
                temp += len;
                goto do_broam;
            }

            goto pass_nothing;

        do_broam:
            f |= BBP_handle_broam(PI, temp);
            PI->process_broam(_THIS_ temp, f);
            goto pass_result;
        }

        // ==========

        case BB_DESKCLICK:
            if (lParam == 0
             && PI->clickRaise
             && false == PI->alwaysOnTop
             && false == PI->inSlit)
                SetWindowPos(hwnd, HWND_TOP,
                    0,0,0,0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
            goto pass_nothing;

        // ==========

        case WM_WINDOWPOSCHANGING:
            if (PI->is_moving) {
                if (false == PI->inSlit
                 && 0 == (0x8000 & GetAsyncKeyState(VK_SHIFT)))
				 SnapWindowToEdge((WINDOWPOS*)lParam, PI->snapWindow, true);
                if (PI->is_sizing) {
                    WINDOWPOS* wp = (WINDOWPOS*)lParam;
                    if (wp->cx < 12) wp->cx = 12;
                    if (wp->cy < 12) wp->cy = 12;
                }
            }
            goto pass_nothing;

        case WM_WINDOWPOSCHANGED:
            if (PI->is_sizing) {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                PI->width = wp->cx;
                PI->height = wp->cy;
                InvalidateRect(hwnd, NULL, FALSE);
            }
			SnapWindowToEdge((WINDOWPOS*)lParam, PI->snapWindow, true);
            goto pass_nothing;

        case WM_ENTERSIZEMOVE:
            PI->is_moving = true;
            goto pass_nothing;

        case WM_EXITSIZEMOVE:
            BBP_exit_moving(PI);
            BBP_set_autoHide(PI, PI->autoHide);
            if (PI->inSlit)
                SendMessage(PI->hSlit, SLIT_UPDATE, 0, (LPARAM)PI->hwnd);
            goto pass_nothing;

        // ==========
        case WM_LBUTTONDOWN:
            SetFocus(hwnd);
            UpdateWindow(hwnd);
            if (false == PI->inSlit && (MK_CONTROL & wParam)) {
                // start moving, when control-key is held down
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0);
                goto pass_result;
            }
            goto pass_nothing;

        case WM_MOUSEMOVE:
            if (false == PI->mouse_over)
            {
                PI->mouse_over = true;
                set_autohide_timer(PI, true);
            }

            if (PI->auto_hidden)
            {
                PI->auto_shown = true;
                BBP_set_window_modes(PI);
                goto pass_result;
            }

            goto pass_nothing;

        case WM_TIMER:
            if (AUTOHIDE_TIMER != wParam)
                goto pass_nothing;

            if (check_mouse(hwnd))
                goto pass_result;
#if 0
            {
                POINT pt;
                GetCursorPos(&pt);
                if (PI->hMon != GetMonitorRect(&pt, NULL, GETMON_FROM_POINT))
                    goto pass_result;
            }
#endif
            if (PI->mouse_over) {
                POINT pt;
                GetCursorPos(&pt);
                ScreenToClient(hwnd, &pt);
                PostMessage(hwnd, WM_MOUSELEAVE, 0, MAKELPARAM(pt.x, pt.y));
                PI->mouse_over = false;
            }

            if (PI->auto_shown) {
                if (PI->suspend_autohide && BBVERSION_LEAN)
                    goto pass_result;
                PI->auto_shown = false;
                BBP_set_window_modes(PI);
            }

            set_autohide_timer(PI, false);
            goto pass_result;


        case BB_AUTOHIDE:
            if (PI->inSlit)
                PostMessage(PI->hSlit, message, wParam, lParam);

            if (wParam)
                PI->suspend_autohide |= lParam;
            else
                PI->suspend_autohide &= ~lParam;

            if (PI->suspend_autohide && PI->auto_hidden) {
                PI->auto_shown = true;
                BBP_set_window_modes(PI);
            }

            set_autohide_timer(PI, true);
            goto pass_result;

        case WM_CLOSE:
            goto pass_result;

        case WM_ERASEBKGND:
            Result = TRUE;
            goto pass_result;

        default:
        pass_nothing:
            return PI->wnd_proc(_THIS_ hwnd, message, wParam, lParam, NULL);
    }
pass_result:
    return PI->wnd_proc(_THIS_ hwnd, message, wParam, lParam, &Result);
}
Example #24
0
void Helpers::GetDesktopRect(const CPoint& point, CRect& rectDesktop)
{
    HMONITOR hMonitor = ::MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);
    GetMonitorRect(hMonitor, false, rectDesktop);
}