Module cCJMDIWindowsMenuItem.pkg
1Use cCJCommandBarSystem.pkg
2
3Register_Function Client_ID Returns Integer
4
5// only used by cCJMDIWIndowsMenuItem
6{ Visibility=Private }
7Class cCJMDIWindowItem is a cCJMenuItem
8
9 Procedure Construct_Object
10 Forward Send Construct_Object
11 Property Handle phWindow 0 // object id of view
12 Set pbControlFlagNoMovable to True
13 Set pbActiveUpdate to True
14 End_Procedure
15
16 Procedure OnExecute Variant vCommandBarControl
17 Handle hWindow
18 Get phWindow to hWindow
19 Send Activate_View of hWindow
20 End_Procedure
21
22End_Class
23
24
25{ OverrideProperty=psCategory InitialValue=C_$CategoryWindow}
26Class cCJMDIWindowsMenuItem is a cCJMenuItem
27
28 Procedure Construct_Object
29 Forward Send Construct_Object
30 Property Handle[] phArrayOfWindows
31 Set peControlType to xtpControlPopup
32 Set psCategory to C_$CategoryWindow
33 End_Procedure
34
35 // This adds MDI windows to the existing menu items.
36 // This removes any existing windows menus and always adds a new set to the end
37
38 Procedure OnPopupInit Variant vCommandBarControl Handle hCommandBarControls
39 Handle hClientArea hView
40 String sLabel
41 Integer i iWindows
42 Handle[] hArrayOfWindows
43 Variant vItem
44
45 // delete all windows actions and menu items. Assume we have an array of DF action objects for the windows
46 // also assume that destroying an action removes all menu instances of that action
47 Get phArrayOfWindows to hArrayOfWindows
48 Move (SizeOfArray(hArrayOfWindows)) to iWindows
49 For i from 0 to (iWindows-1)
50 Send Destroy of hArrayOfWindows[i] // assume this removes all menu items of this action
51 Loop
52 Move (ResizeArray(hArrayOfWindows,0)) to hArrayOfWindows
53
54 // Add all views to this menu. Create the action and add the item
55 Move 0 to i
56 Get Client_Id to hClientArea // object id of client area
57 If (hClientArea > 0) Begin
58 Get Next_Mdi_Dialog of hClientArea True to hView // find first view
59 While (hView <> 0)
60 If (Active_State(hView)) Begin
61 // create the action
62 Get Create U_cCJMDIWindowItem to hArrayOfWindows[i]
63 Get Label of hView to sLabel // caption bar (name) of view
64 Set psCaption of hArrayOfWindows[i] to sLabel
65 Set psDescription of hArrayOfWindows[i] to ("Make this view (" - trim(sLabel) - ") the active window.")
66 If (current_scope(desktop)=hView and View_mode(hView)<>VIEWMODE_ICONIZE) Begin
67 Set pbChecked of hArrayOfWindows[i] to True
68 End
69 Set phWindow of hArrayOfWindows[i] to hView // used by custom OnExecute
70 If (i=0) Begin
71 Set pbControlBeginGroup of hArrayOfWindows[i] to True
72 End
73 // Create a menu item for this action
74 Get AddDynamicControl of hArrayOfWindows[i] hCommandBarControls to vItem
75 Increment i
76 End
77 Get Next_Mdi_Dialog of hClientArea False to hView // find next
78 Loop
79 End
80
81 Set phArrayOfWindows to hArrayOfWindows
82
83 End_Procedure
84
85End_Class
86
87