Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmPOS
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
fmPOS
Commits
1d30b086
Commit
1d30b086
authored
Apr 26, 2017
by
Carwyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.设置添加界面文件
parent
4049a277
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
153 additions
and
1 deletions
+153
-1
fmp_settings
+1
-1
include/window/fmp_window.hpp
+152
-0
No files found.
fmp_settings
@
1926f363
Subproject commit
ad13983a4b3d985172e888a3fd4eb0e72794cae1
Subproject commit
1926f36397458dd693582b1a13b75656655f827f
include/window/fmp_window.hpp
0 → 100644
View file @
1d30b086
#ifndef FMP_WINDOW_H
#define FMP_WINDOW_H
#include <QWidget>
#include <QJsonObject>
#include <QDesktopWidget>
#include <QPainter>
#include <QStyleOption>
#include <QMap>
#ifdef Q_OS_WIN
#include <Windows.h>
#include <windowsx.h>
#endif
class
FMPWindow
:
public
QWidget
{
public
:
explicit
FMPWindow
(
QWidget
*
parent
=
0
)
:
QWidget
(
parent
)
{
setWindowFlags
(
Qt
::
FramelessWindowHint
|
Qt
::
WindowStaysOnTopHint
);
setAttribute
(
Qt
::
WA_QuitOnClose
,
false
);
setAttribute
(
Qt
::
WA_DeleteOnClose
,
true
);
}
virtual
~
FMPWindow
()
{}
#ifdef Q_OS_WIN
public
:
virtual
void
show
()
{
showNormal
();
::
SetForegroundWindow
((
HWND
)
effectiveWinId
());
::
SetWindowPos
(
(
HWND
)
effectiveWinId
(),
HWND_TOPMOST
,
0
,
0
,
0
,
0
,
SWP_NOMOVE
|
SWP_NOSIZE
|
SWP_SHOWWINDOW
);
showNormal
();
::
SetForegroundWindow
((
HWND
)
effectiveWinId
());
QDesktopWidget
w
;
QRect
rc
=
w
.
availableGeometry
();
setGeometry
((
rc
.
width
()
-
width
())
/
2
,
(
rc
.
height
()
-
height
())
/
2
,
width
(),
height
());
return
QWidget
::
show
();
}
protected
:
bool
nativeEvent
(
const
QByteArray
&
eventType
,
void
*
message
,
long
*
result
)
{
Q_UNUSED
(
eventType
);
MSG
*
msg
=
(
MSG
*
)
message
;
//! true indicates the message need to be processed by DefWindowProc
bool
fCallDWP
=
true
;
bool
fMsgDone
=
false
;
switch
(
msg
->
message
)
{
case
WM_NCHITTEST
:
{
*
result
=
winNCHitTest
(
msg
);
if
(
*
result
!=
HTNOWHERE
)
{
// HTMINBUTTON 等消息当作HTCLIENT处理
switch
(
*
result
)
{
case
HTMINBUTTON
:
case
HTMAXBUTTON
:
case
HTCLOSE
:
*
result
=
HTCLIENT
;
break
;
}
fCallDWP
=
false
;
}
break
;
}
case
WM_GETMINMAXINFO
:
{
// 最大化时的处理
MINMAXINFO
*
mmi
=
(
MINMAXINFO
*
)
(
msg
->
lParam
);
QDesktopWidget
desktopWidget
;
QRect
desktop
=
desktopWidget
.
availableGeometry
();
mmi
->
ptMaxSize
.
x
=
desktop
.
width
();
mmi
->
ptMaxSize
.
y
=
desktop
.
height
();
mmi
->
ptMaxPosition
.
x
=
desktop
.
x
();
mmi
->
ptMaxPosition
.
y
=
desktop
.
y
();
mmi
->
ptMinTrackSize
.
x
=
minimumWidth
();
// minimum width for your window
mmi
->
ptMinTrackSize
.
y
=
minimumHeight
();
// minimum height for your window
mmi
->
ptMaxTrackSize
.
x
=
maximumWidth
();
mmi
->
ptMaxTrackSize
.
y
=
maximumHeight
();
*
result
=
0
;
fMsgDone
=
true
;
break
;
}
default
:
break
;
}
fMsgDone
=
fMsgDone
||
!
fCallDWP
;
return
fMsgDone
;
}
void
paintEvent
(
QPaintEvent
*
event
)
{
Q_UNUSED
(
event
);
QStyleOption
opt
;
opt
.
init
(
this
);
QPainter
p
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
opt
,
&
p
,
this
);
}
protected
:
long
winNCHitTest
(
MSG
*
msg
)
{
// Mouse position
QPoint
mouse_pos
(
GET_X_LPARAM
(
msg
->
lParam
),
GET_Y_LPARAM
(
msg
->
lParam
));
QRect
window_rect
=
geometry
();
// Set default value (HTNOWHERE) (1,1).
USHORT
uRow
=
1
;
USHORT
uCol
=
1
;
bool
fOnResizeBorder
=
false
;
//! Test caption area
QRegion
m_children_region
(
0
,
0
,
width
()
-
54
,
60
);
QRegion
new_region
=
m_children_region
.
translated
(
window_rect
.
x
()
,
window_rect
.
y
());
if
(
new_region
.
contains
(
mouse_pos
))
{
//! Title regions contains the mouse position, treat it as caption area
uRow
=
0
;
}
// Hit test (HTTOPLEFT, ... HTBOTTOMRIGHT)
LRESULT
hitTests
[
3
][
3
]
=
{
{
HTTOPLEFT
,
fOnResizeBorder
?
HTTOP
:
HTCAPTION
,
HTTOPRIGHT
},
{
HTLEFT
,
HTNOWHERE
,
HTRIGHT
},
{
HTBOTTOMLEFT
,
HTBOTTOM
,
HTBOTTOMRIGHT
},
};
//! Test borders area
if
(
minimumSize
()
!=
maximumSize
())
{
//! To be implemented
}
return
hitTests
[
uRow
][
uCol
];
}
#endif
};
#endif // FMP_WINDOW_H
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