1 /* ------------- sysmenu.c ------------ */
3 #include "dflat32/dflat.h"
5 int SystemMenuProc(DFWINDOW wnd
, DFMESSAGE msg
, PARAM p1
, PARAM p2
)
11 wnd
->holdmenu
= ActiveMenuBar
;
12 ActiveMenuBar
= &SystemMenu
;
13 SystemMenu
.PullDown
[0].Selection
= 0;
16 wnd1
= GetParent(wnd
);
17 mx
= (int) p1
- GetLeft(wnd1
);
18 my
= (int) p2
- GetTop(wnd1
);
19 if (HitControlBox(wnd1
, mx
, my
))
23 DfPostMessage(wnd
, CLOSE_WINDOW
, 0, 0);
26 if (p2
== GetTop(GetParent(wnd
))) {
27 DfPostMessage(GetParent(wnd
), msg
, p1
, p2
);
28 DfSendMessage(wnd
, CLOSE_WINDOW
, TRUE
, 0);
34 ActiveMenuBar
= wnd
->holdmenu
;
39 return DefaultWndProc(wnd
, msg
, p1
, p2
);
42 /* ------- Build a system menu -------- */
43 void BuildSystemMenu(DFWINDOW wnd
)
46 DFWINDOW SystemMenuWnd
;
48 SystemMenu
.PullDown
[0].Selections
[6].Accelerator
=
49 (GetClass(wnd
) == APPLICATION
) ? ALT_F4
: CTRL_F4
;
53 ht
= MenuHeight(SystemMenu
.PullDown
[0].Selections
);
54 wd
= MenuWidth(SystemMenu
.PullDown
[0].Selections
);
56 if (lf
+wd
> DfGetScreenWidth()-1)
57 lf
= (DfGetScreenWidth()-1) - wd
;
58 if (tp
+ht
> DfGetScreenHeight()-2)
59 tp
= (DfGetScreenHeight()-2) - ht
;
61 SystemMenuWnd
= DfCreateWindow(POPDOWNMENU
, NULL
,
62 lf
,tp
,ht
,wd
,NULL
,wnd
,SystemMenuProc
, 0);
64 #ifdef INCLUDE_RESTORE
65 if (wnd
->condition
== ISRESTORED
)
66 DeactivateCommand(&SystemMenu
, ID_SYSRESTORE
);
68 ActivateCommand(&SystemMenu
, ID_SYSRESTORE
);
71 if (TestAttribute(wnd
, MOVEABLE
)
72 #ifdef INCLUDE_MAXIMIZE
73 && wnd
->condition
!= ISMAXIMIZED
76 ActivateCommand(&SystemMenu
, ID_SYSMOVE
);
78 DeactivateCommand(&SystemMenu
, ID_SYSMOVE
);
80 if (wnd
->condition
!= ISRESTORED
||
81 TestAttribute(wnd
, SIZEABLE
) == FALSE
)
82 DeactivateCommand(&SystemMenu
, ID_SYSSIZE
);
84 ActivateCommand(&SystemMenu
, ID_SYSSIZE
);
86 #ifdef INCLUDE_MINIMIZE
87 if (wnd
->condition
== ISMINIMIZED
||
88 TestAttribute(wnd
, MINMAXBOX
) == FALSE
)
89 DeactivateCommand(&SystemMenu
, ID_SYSMINIMIZE
);
91 ActivateCommand(&SystemMenu
, ID_SYSMINIMIZE
);
94 #ifdef INCLUDE_MAXIMIZE
95 if (wnd
->condition
!= ISRESTORED
||
96 TestAttribute(wnd
, MINMAXBOX
) == FALSE
)
97 DeactivateCommand(&SystemMenu
, ID_SYSMAXIMIZE
);
99 ActivateCommand(&SystemMenu
, ID_SYSMAXIMIZE
);
102 DfSendMessage(SystemMenuWnd
, BUILD_SELECTIONS
,
103 (PARAM
) &SystemMenu
.PullDown
[0], 0);
104 DfSendMessage(SystemMenuWnd
, SETFOCUS
, TRUE
, 0);
105 DfSendMessage(SystemMenuWnd
, SHOW_WINDOW
, 0, 0);