Переместите приложение во второй монитор в MFC

Я разрабатываю приложение в VS2008 VC ++. сеть

Я хочу переместить приложение в дополнительный монитор. Не путем перетаскивания использования мыши.

Есть ли любая функция как MoveToMonitor путем нажатия кнопки или любых сочетаний клавиш. Затем это должно переместиться в дополнительный монитор.

5
задан Leon Bambrick 30 March 2011 в 06:02
поделиться

2 ответа

Вы должны быть в состоянии вызвать GetMonitorInfo и переместить ваше окно с помощью этого.

См. здесь. Пример MFC Поддержка нескольких мониторов с помощью GetSystemMetrics EnumDisplayMonitors и GetMonitorInfo" для получения дополнительной информации.

Using the code

CMointor is a basic MFC class that allows you to safely use the multiple-monitor API on any Win32 platform. 

There are three classes in this library:

CMonitors represents the collection of monitors currently attached to the system and wraps the EnumDisplayMonitors API function.

  Collapse Copy Code
//CMonitors' interface
CMonitor GetMonitor( const int index ) const;
int GetCount() const; 

//returns the monitor closest to the specified item
static CMonitor GetNearestMonitor( const LPRECT lprc );
static CMonitor GetNearestMonitor( const POINT pt );
static CMonitor GetNearestMonitor( const CWnd* pWnd );

//is the specificed item visible on any monitor
static BOOL IsOnScreen( const POINT pt );
static BOOL IsOnScreen( const CWnd* pWnd );
static BOOL IsOnScreen( const LPRECT lprc );

//returns the rectangle encompassing all monitors
static void GetVirtualDesktopRect( LPRECT lprc );

//determines whether the given handle is a valid monitor handle
static BOOL IsMonitor( const HMONITOR hMonitor );
static CMonitor GetPrimaryMonitor();
static BOOL AllMonitorsShareDisplayFormat();

static int GetMonitorCount();
CMonitor is a wrapper around an HMONITOR handle (returned from EnumDisplayMonitors) and the GetMonitorInfo function. With CMonitor you can get at the characteristics of a given monitor.

  Collapse Copy Code
//The interface of CMonitor            
void Attach( const HMONITOR hMonitor );
HMONITOR Detach();

void ClipRectToMonitor( LPRECT lprc, 
                        const BOOL UseWorkAreaRect = FALSE ) const;
void CenterRectToMonitor( LPRECT lprc, 
                          const BOOL UseWorkAreaRect = FALSE ) const;
void CenterWindowToMonitor( CWnd* const pWnd,
                            const BOOL UseWorkAreaRect = FALSE ) const;

//creates a device context for the monitor - the client is responsible for 
// DeleteDC
HDC CreateDC() const;

void GetMonitorRect( LPRECT lprc ) const;
//the work area is the monitor rect minus the start bar
void GetWorkAreaRect( LPRECT lprc ) const;

void GetName( CString& string ) const;

int GetBitsPerPixel() const;

//determines if the specified item on the monitor
BOOL IsOnMonitor( const POINT pt ) const;
BOOL IsOnMonitor( const CWnd* pWnd ) const;
BOOL IsOnMonitor( const LPRECT lprc ) const;

BOOL IsPrimaryMonitor() const;
BOOL IsMonitor() const;

CMonitorDC is a CDC derived class that represents a monitor specific device context. I haven't really gone to far with this class but it seemed like a logical part of the library.  

Known Limitations

CMonitor and CMonitors rely on the assumption that a monitor handle does not change. This has proved to be a safe assumption empirically but isn't nessecarily a guarantee.

Если вы на Window 7, то перемещение окон между мониторами - Windows-Arrow

2
ответ дан 15 December 2019 в 00:56
поделиться

Вы используете MoveWindow (или SetWindowPos , хотя в этом случае вам не нужны дополнительные действия) для перемещения Окно к той части рабочего стола, которая отображается на рассматриваемом мониторе. Вы можете найти это (среди других возможностей) EnumDisplayMonitors , который покажет вам прямоугольник, связанный с каждым монитором.

2
ответ дан 15 December 2019 в 00:56
поделиться
Другие вопросы по тегам:

Похожие вопросы: