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
183081cc
Commit
183081cc
authored
Aug 25, 2017
by
Adi Shavit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes window position only if BOTH top corners are outside ALL monitors.
parent
8ffa2947
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
window_w32.cpp
modules/highgui/src/window_w32.cpp
+28
-9
No files found.
modules/highgui/src/window_w32.cpp
View file @
183081cc
...
...
@@ -324,15 +324,34 @@ icvLoadWindowPos( const char* name, CvRect& rect )
RegQueryValueEx
(
hkey
,
"Width"
,
NULL
,
&
dwType
,
(
BYTE
*
)
&
rect
.
width
,
&
dwSize
);
RegQueryValueEx
(
hkey
,
"Height"
,
NULL
,
&
dwType
,
(
BYTE
*
)
&
rect
.
height
,
&
dwSize
);
if
(
rect
.
x
!=
(
int
)
CW_USEDEFAULT
&&
(
rect
.
x
<
-
200
||
rect
.
x
>
3000
)
)
rect
.
x
=
100
;
if
(
rect
.
y
!=
(
int
)
CW_USEDEFAULT
&&
(
rect
.
y
<
-
200
||
rect
.
y
>
3000
)
)
rect
.
y
=
100
;
if
(
rect
.
width
!=
(
int
)
CW_USEDEFAULT
&&
(
rect
.
width
<
0
||
rect
.
width
>
3000
)
)
rect
.
width
=
100
;
if
(
rect
.
height
!=
(
int
)
CW_USEDEFAULT
&&
(
rect
.
height
<
0
||
rect
.
height
>
3000
)
)
rect
.
height
=
100
;
// Snap rect into closest monitor in case it falls outside it. // Adi Shavit
// set WIN32 RECT to be the loaded size
POINT
tl_w32
=
{
rect
.
x
,
rect
.
y
};
POINT
tr_w32
=
{
rect
.
x
+
rect
.
width
,
rect
.
y
};
// find monitor containing top-left and top-right corners, or NULL
HMONITOR
hMonitor_l
=
MonitorFromPoint
(
tl_w32
,
MONITOR_DEFAULTTONULL
);
HMONITOR
hMonitor_r
=
MonitorFromPoint
(
tr_w32
,
MONITOR_DEFAULTTONULL
);
// if neither are contained - the move window to origin of closest.
if
(
NULL
==
hMonitor_l
&&
NULL
==
hMonitor_r
)
{
// find monitor nearest to top-left corner
HMONITOR
hMonitor_closest
=
MonitorFromPoint
(
tl_w32
,
MONITOR_DEFAULTTONEAREST
);
// get coordinates of nearest monitor
MONITORINFO
mi
;
mi
.
cbSize
=
sizeof
(
mi
);
GetMonitorInfo
(
hMonitor_closest
,
&
mi
);
rect
.
x
=
mi
.
rcWork
.
left
;
rect
.
y
=
mi
.
rcWork
.
top
;
}
if
(
rect
.
width
!=
(
int
)
CW_USEDEFAULT
&&
(
rect
.
width
<
0
||
rect
.
width
>
3000
))
rect
.
width
=
100
;
if
(
rect
.
height
!=
(
int
)
CW_USEDEFAULT
&&
(
rect
.
height
<
0
||
rect
.
height
>
3000
))
rect
.
height
=
100
;
RegCloseKey
(
hkey
);
}
...
...
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