Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
00c30681
Commit
00c30681
authored
May 16, 2012
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Snap-to-Screen Edge feature in the case of multiple monitors (patch by Adi Shavit)
parent
5f9e295a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
3 deletions
+36
-3
window_w32.cpp
modules/highgui/src/window_w32.cpp
+36
-3
No files found.
modules/highgui/src/window_w32.cpp
View file @
00c30681
...
...
@@ -54,6 +54,9 @@
#include <stdio.h>
#include <assert.h>
#define COMPILE_MULTIMON_STUBS // Required for multi-monitor support
#include <multimon.h>
#ifdef HAVE_OPENGL
#include <memory>
#include <algorithm>
...
...
@@ -1065,7 +1068,7 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
icvSetWindowLongPtr
(
hWnd
,
CV_USERDATA
,
window
);
icvSetWindowLongPtr
(
mainhWnd
,
CV_USERDATA
,
window
);
// Recalculate window pos
ition
// Recalculate window pos
icvUpdateWindowPos
(
window
);
result
=
1
;
...
...
@@ -1633,7 +1636,7 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
WINDOWPOS
*
pos
=
(
WINDOWPOS
*
)
lParam
;
// Update the toolbar pos
ition
/size
// Update the toolbar pos/size
if
(
window
->
toolbar
.
toolbar
)
{
RECT
rect
;
...
...
@@ -1647,6 +1650,36 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
break
;
}
case
WM_WINDOWPOSCHANGING
:
{
// Snap window to screen edges with multi-monitor support. // Adi Shavit
LPWINDOWPOS
pos
=
(
LPWINDOWPOS
)
lParam
;
RECT
rect
;
GetWindowRect
(
window
->
frame
,
&
rect
);
HMONITOR
hMonitor
;
hMonitor
=
MonitorFromRect
(
&
rect
,
MONITOR_DEFAULTTONEAREST
);
MONITORINFO
mi
;
mi
.
cbSize
=
sizeof
(
mi
);
GetMonitorInfo
(
hMonitor
,
&
mi
);
const
int
SNAP_DISTANCE
=
15
;
if
(
abs
(
pos
->
x
-
mi
.
rcMonitor
.
left
)
<=
SNAP_DISTANCE
)
pos
->
x
=
mi
.
rcMonitor
.
left
;
// snap to left edge
else
if
(
abs
(
pos
->
x
+
pos
->
cx
-
mi
.
rcMonitor
.
right
)
<=
SNAP_DISTANCE
)
pos
->
x
=
mi
.
rcMonitor
.
right
-
pos
->
cx
;
// snap to right edge
if
(
abs
(
pos
->
y
-
mi
.
rcMonitor
.
top
)
<=
SNAP_DISTANCE
)
pos
->
y
=
mi
.
rcMonitor
.
top
;
// snap to top edge
else
if
(
abs
(
pos
->
y
+
pos
->
cy
-
mi
.
rcMonitor
.
bottom
)
<=
SNAP_DISTANCE
)
pos
->
y
=
mi
.
rcMonitor
.
bottom
-
pos
->
cy
;
// snap to bottom edge
}
case
WM_ACTIVATE
:
if
(
LOWORD
(
wParam
)
==
WA_ACTIVE
||
LOWORD
(
wParam
)
==
WA_CLICKACTIVE
)
SetFocus
(
window
->
hwnd
);
...
...
@@ -2199,7 +2232,7 @@ icvCreateTrackbar( const char* trackbar_name, const char* window_name,
SendMessage
(
window
->
toolbar
.
toolbar
,
TB_SETBUTTONINFO
,
(
WPARAM
)
tbs
.
idCommand
,
(
LPARAM
)
&
tbis
);
/* Get button pos
ition
*/
/* Get button pos */
SendMessage
(
window
->
toolbar
.
toolbar
,
TB_GETITEMRECT
,
(
WPARAM
)
tbs
.
idCommand
,
(
LPARAM
)
&
rect
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment