forked from kurowskicisa/EIB-HMG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoveActiveWindow.prg
158 lines (92 loc) · 3.1 KB
/
MoveActiveWindow.prg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
*-----------------------------------------------------------------------------*
#include "eib_hmg.ch"
*-----------------------------------------------------------------------------*
#DEFINE HTCAPTION 2
#DEFINE WM_NCLBUTTONDOWN 161
*------------------------------------------------------------------------------*
PROCEDURE MoveActiveWindow( hWnd , cForm )
*------------------------------------------------------------------------------*
LOCAL nMouseRow := GetCursorRow()
LOCAL nMouseCol := GetCursorCol()
LOCAL nFormRow := GetProperty( cForm , 'Row' )
LOCAL nFormCol := GetProperty( cForm , 'Col' )
LOCAL nFormHeight := GetProperty( cForm , 'Height' )
LOCAL nFormWidth := GetProperty( cForm , 'Width' )
LOCAL nDesktopHeight := GetDesktopRealHeight()
LOCAL nDesktopWidth := GetDesktopRealWidth()
LOCAL nAPPRow := 0
LOCAL nAPPCol := 0
DEFAULT hWnd := GetActiveWindow()
DECLARE WINDOW win_Main
IF nMouseRow >= nFormRow .AND. nMouseRow <= ( nFormRow + 80 - 1 )
IF nFormCol >= 0
PostMessage( hWnd , WM_NCLBUTTONDOWN , HTCAPTION , 0 )
ENDIF
ENDIF
do_events()
nAPPRow := GetProperty( cForm , 'Row' )
nAPPCol := GetProperty( cForm , 'Col' )
do_events()
IF nAPPCol < 0
nAPPCol := SetProperty( cForm , 'Col' , 0 )
ELSE
IF nAPPCol + nFormWidth > nDesktopWidth
SetProperty( cForm , 'Col' , nDesktopWidth - nFormWidth )
nAPPCol := GetProperty( cForm , 'Col' )
ELSE
SetProperty( cForm , 'Col' , nAPPCol )
ENDIF
ENDIF
IF nAPPRow < 0
nAPPRow := SetProperty( cForm , 'Row' , 0 )
ELSE
IF nAPPRow + nFormHeight > nDesktopHeight
SetProperty( cForm , 'Row' , nDesktopHeight - nFormHeight )
nAPPRow := GetProperty( cForm , 'Row' )
ELSE
SetProperty( cForm , 'Row' , nAPPRow )
ENDIF
ENDIF
do_events()
APP_ROW := nAPPRow
APP_COL := nAPPCol
do_events()
aFrm[ 1 , 2 ] := APP_ROW
aFrm[ 1 , 3 ] := APP_COL
do_events()
RETURN
#IFDEF _HMG_2_
//*****************************************************************************************
//* borrowed from [MiniGUI]\samples\advanced\FitToDesktop\FitToDesktop.prg
//*****************************************************************************************
#pragma BEGINDUMP
#include <mgdefs.h>
HB_FUNC (GETDESKTOPREALTOP)
{
RECT rect;
SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );
hb_retni(rect.top);
}
HB_FUNC (GETDESKTOPREALLEFT)
{
RECT rect;
SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );
hb_retni(rect.left);
}
HB_FUNC (GETDESKTOPREALWIDTH)
{
RECT rect;
SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );
hb_retni(rect.right - rect.left);
}
HB_FUNC (GETDESKTOPREALHEIGHT)
{
RECT rect;
SystemParametersInfo( SPI_GETWORKAREA, 1, &rect, 0 );
hb_retni(rect.bottom - rect.top);
}
#pragma ENDDUMP
#ENDIF
*-----------------------------------------------------------------------------*
*-----------------------------------------------------------------------------*
*-----------------------------------------------------------------------------*