Module Dfadlg.pkg
1
2// 1/4/99 JJT - Destroy_object passes obj instead of self
3// 01/29/97 JJT - Don't pass self in end_construct_object
4// 07/23/96 JJT - New Class names
5// 04/28/96 JJT - Added Activate_View message
6Use LanguageText.pkg
7Use Windows.pkg
8Use dfConfrm.pkg
9Use GlobalFunctionsProcedures.pkg
10Use tWinStructs.pkg
11
12
13// as of 15.0, moved some of dbViews features up to this level. Load/Save Environment showing view name
14{ ClassType=Abstract }
15{ HelpTopic=AppDialog }
16{ ComponentType=VWClass }
17Class AppDialog is a MdiDialog
18
19 Procedure Construct_Object
20 Forward Send Construct_Object
21
22 // This can be used to stop this view from loading and saving its environment.
23 { Category=Behavior }
24 Property Boolean pbDisableSaveEnvironment False
25
26 // set true to auto-activate the view. This does not work if the object is deferred.
27 // this is a design time property which is applied during end_construct_object. This should
28 { Category=Access }
29 Property Boolean pbAutoActivate False
30
31 // used to keep track of window placment when deactivated object is reactivated.
32 { Visibility=Private }
33 Property tWinWindowPlacement pWindowPlacement
34 End_Procedure
35
36 Procedure End_Construct_Object
37 Boolean bAutoActivate
38 Delegate Send Add_Mdi_Dialog Self
39 Forward Send End_Construct_Object
40 // if auto-activate, add this to he the panel's array of objects to be acivated.
41 Get pbAutoActivate to bAutoActivate
42 If bAutoActivate Begin
43 Delegate Send AddAutoActivateView Self
44 End
45 End_Procedure
46
47 { MethodType=Event NoDoc=True }
48 Procedure Destroy_Object
49 integer obj
50 Move Self to obj
51 Delegate Send Remove_Mdi_Dialog obj
52 Forward Send Destroy_Object
53 End_Procedure // Destroy_Object
54
55 // Augmented to save view position
56 { MethodType=Event }
57 Procedure Notify_Exit_Application
58 Send Save_Environment
59 End_Procedure
60
61 { MethodType=Property Visibility=Private }
62 Function View_Changed returns Integer
63 End_Function
64
65 //
66 // Augment exit_application_check to see if view is changed. If changed,
67 // display exit message as required
68
69 { MethodType=Event }
70 Function Verify_Exit_Application Returns Integer
71 Integer Fail
72 Get View_Changed to Fail // Ask for changes in Data-sets
73 If fail ; // ok a change exist...activate changed view.
74 Get confirm (SFormat(C_$ChangesExistExit, Label(self)) ) to fail
75 Function_return fail
76 End_Function
77
78 // Activates the view. If view is minimized it restores it first
79 // works with both popup_state T and F
80
81 Procedure Activate_View returns Integer
82 Integer rVal
83 If ( View_mode(self)=VIEWMODE_ICONIZE ) ;
84 Set view_mode to viewmode_normal
85 If (Popup_state(self)) ; // support both popup and
86 Get Msg_Popup to rVal
87 else ;
88 Get Msg_Activate to rVal
89 Procedure_Return rVal
90 End_Procedure // Activate_View
91
92
93 // augmented to load last view position
94
95 { NoDoc=True }
96 Procedure Add_Focus Integer hoBase Returns Integer
97 Integer iRetVal bState
98 Get Visible_State to bState
99 Set Visible_State to False
100 Forward Get Msg_Add_Focus hoBase to iRetVal
101 If (iRetVal=0) Begin
102 Send Load_Environment
103 End
104 Set Visible_State to bState
105 Procedure_Return iRetVal
106 End_Procedure
107
108 // This is augmented to send save_environment during a view close (was in close_panel)
109 // we set view_mode to normal if it is zoomed. This is needed to make the MDI stuff work
110 // properly with the save/load environment. The Saved environment data will make it zoom if needed.
111 //
112 { NoDoc=True }
113 Procedure Deactivate Integer eDeactivateScope Returns Integer
114 Integer eArea iFail
115 Boolean bPreserveEnvironment
116 Move (If(num_arguments=0, Area_Type, eDeactivateScope)) to eArea // in case no param is passed
117 If (eArea<>0) Begin
118 Forward Get msg_deactivate eArea to iFail
119 End
120 Else Begin
121 Send Save_Environment
122 Forward Get msg_deactivate eArea to iFail
123
124 // this works around a problem where maximized MDI views get saved but don't come back
125 // correctly when loaded again without exiting. It turns out the the MDI client restores
126 // the view sometimes without telling view_mode. If view_mode is normal, it always works.
127 // This must happen after the view is deactivated!
128
129 If ghoApplication Begin
130 Get pbPreserveEnvironment of ghoApplication to bPreserveEnvironment
131 End
132 // do these checks to have as small of an effect as possible.
133 If (bPreserveEnvironment and iFail=0 and view_mode(Self)=Viewmode_Zoom) Begin
134 Set View_Mode to Viewmode_Normal
135 End
136 End
137 Function_Return iFail
138 End_Procedure
139
140 // Save the window placement information for this to the application object
141
142 { Visibility=Private }
143 Procedure Save_Environment
144 tWinWindowPlacement WindowPlacement
145 Boolean bSuccess bCancel
146 Get pbDisableSaveEnvironment to bCancel
147 If not bCancel Begin
148
149 // save environment to the object, in case it is reactivated during the same run.
150 Move (SizeOfType(tWinWindowPlacement)) to WindowPlacement.length
151 Move (GetWindowPlacement(Window_Handle(Self), addressof(WindowPlacement))) to bSuccess
152 If bSuccess Begin
153 // if minimized, assume restored, as we don't want to restart minimized!
154 If (WindowPlacement.showCmd = SW_SHOWMINIMIZED) Begin
155 Move SW_SHOWNORMAL to WindowPlacement.showCmd
156 End
157 Set pWindowPlacement to WindowPlacement
158 End
159 // also save environment to the application object, so it can be used when reloaded
160 If ghoApplication Send DoSaveEnvironment of ghoApplication Self False
161 end
162 End_Procedure
163
164 // Load the window placement information for this from the application object
165
166 { Visibility=Private }
167 Procedure Load_Environment
168 tWinWindowPlacement WindowPlacement
169 Boolean bSuccess bCancel
170 Get pbDisableSaveEnvironment to bCancel
171 If not bCancel Begin
172 // if view has alrady been activated and deactivated use the setting from windowplacement saved in the object
173 Get pWindowPlacement to WindowPlacement
174 // if length is zero, assume it has never been used before (never deactivated).
175 If (WindowPlacement.length>0) Begin
176 Move (SetWindowPlacement(Window_Handle(Self), AddressOf(WindowPlacement))) to bSuccess
177 End
178 Else Begin
179 If ghoApplication Send DoLoadEnvironment of ghoApplication Self False
180 End
181 end
182 End_Procedure
183
184 { MethodType=Event NoDoc=True }
185 Procedure Entering_Scope Returns Integer
186 Integer rVal
187 Forward Get MSG_Entering_Scope to rVal
188 If not rVal Send Show_View_Name (Label(Self))
189 End_Procedure
190
191 { MethodType=Event NoDoc=True }
192 Procedure Exiting_Scope Integer whereto Returns Integer
193 Integer rVal
194 Forward Get MSG_Exiting_Scope whereto to rVal
195 If not rVal Send Show_View_Name ''
196 End_Procedure
197
198 { Visibility=Private }
199 Procedure Show_view_Name String sHelp
200 Integer rVal Id
201 Get Statusbar_id to id
202 If Id Send Show_View_Name to Id sHelp
203 End_Procedure
204
205End_Class
206
207// logically this is required
208//{ DesignerClass=cDTView }
209{ HelpTopic=View }
210Class View is an AppDialog
211End_Class
212