Module cCJGridSearchDialog.pkg
1Use Windows.pkg
2
3// This is a popup search modal dialog to be used with cCJGrid (mostly prompt lists). It provides the standard
4// form or checkbox with an ok button. It is invoked by calling RequestGridSearch.
5// This is all private.
6
7{ Visibility=Private }
8Class cCJGridSearchForm is a Form
9
10 Procedure Construct_Object
11 Forward Send Construct_Object
12 Property Integer piKeyCode 0 // the CJ shift key from OnComKeyDown
13 Property Integer piKeyShift 0 // the CJ VK key from OnComKeyDown
14 On_Key kCancel Send Cancel
15 End_Procedure // Construct_Object
16
17 Procedure Add_Focus Handle hoParent Returns Integer
18 Handle hWnd
19 Integer iVoid iKeyCode iKeyShift
20 Forward Send Add_Focus hoParent
21 Get piKeyCode to iKeyCode
22 Get piKeyShift to iKeyShift
23 If (iKeyCode<>0) Begin
24 Get Form_Window_Handle 0 to hWnd
25 Move (PostMessage(hWnd,WM_KEYDOWN,iKeyCode,iKeyShift)) to iVoid
26 End
27 Else Begin
28 Send Select_All
29 End
30 End_Procedure
31
32End_Class
33
34{ Visibility=Private }
35Class cCJGridSearchDialog is a ModalPanel
36
37 Procedure Construct_Object
38 Forward Send Construct_Object
39 Property Boolean pbOK False
40 Set Locate_mode to CENTER_ON_PARENT
41 End_Procedure // Construct_Object
42
43 Procedure SearchOk
44 Set pbOK to True
45 Send Close_Panel
46 End_Procedure
47
48 // function that sets eveything up and pops up a modal dialog. The value selected is returned by ref.
49 // This is passed a column object and it expects that this column object is based on cCJGridColumn. The Keys passed
50 // are the raw shift key and VK key as passed from a grid control and is used to seed the form.
51 { Visibility=Private }
52 Function RequestGridSearch Integer iKeyCode Integer iKeyShift Handle hoCol String ByRef sValue Returns Boolean
53 Handle hoSearchForm hoButton
54 Integer iWidth eDataType
55 Boolean bOk bCapslock bCkbox bChecked
56 String sHeader sMask sNewValue
57
58 Get pbCheckbox of hoCol to bCkbox
59 Get SelectedRowValue of hoCol to sNewValue
60 If bCkBox Begin
61 // if checkbox, set default width to 50 and use the
62 // current state as the search.
63 Move 50 to iWidth
64 Get ValueToCheckedState of hoCol sNewValue to bChecked
65 End
66 Else Begin
67 If (iKeyShift<>0) Begin
68 Move '' to sNewValue
69 End
70 Get piWidth of hoCol to iWidth
71 Get GuiToDialog 0 iWidth to iWidth
72 Move (Low(iWidth)) to iWidth
73 If (iWidth<50) Begin
74 Move 50 to iWidth
75 End
76 Get psMask of hoCol to sMask
77 Get peDataType of hoCol to eDataType
78 Get pbCapslock of hoCol to bCapslock
79 End
80
81 Get psCaption of hoCol to sHeader
82
83 Set Label to (C_$Search +":" * sHeader)
84
85 If (iWidth>=100) Begin
86 Set Size to (24+14+5) (iWidth+5+5)
87 End
88 Else Begin
89 Set Size to (14+5+5) (iWidth+5+5+5+50)
90 End
91
92 // create the search control, form or checkbox
93 If not bCkBox Begin
94 // a form
95 Get Create (RefClass(cCJGridSearchForm)) to hoSearchForm
96 Set Location of hoSearchForm to 5 5
97 Set Size of hoSearchForm to 14 iWidth
98 Set Form_DataType of hoSearchForm to eDataType
99 Set Form_Mask of hoSearchForm to sMask
100 Set Capslock_State of hoSearchForm to bCapslock
101 Set piKeyCode of hoSearchForm to iKeyCode
102 Set piKeyShift of hoSearchForm to iKeyShift
103 Set Value of hoSearchForm to sNewValue
104 End
105 Else Begin
106 // a checkbox
107 Get Create (RefClass(CheckBox)) to hoSearchForm
108 Set location of hoSearchForm to 5 5
109 Set Checked_State of hoSearchForm to bChecked
110 Set Label of hoSearchForm to sHeader
111 End
112
113 // create the ok Button
114 Get Create (RefClass(Button)) to hoButton
115 Set Label of hoButton to C_$Ok
116 Set Message of hoButton to (RefProc(SearchOk))
117 If (iWidth>=100) Begin
118 Set Location of hoButton to 24 (iWidth+5-50)
119 End
120 Else Begin
121 Set Location of hoButton to 5 (iWidth+5+5)
122 End
123 Set Default_State of hoButton to True
124
125 Send Popup // invoke the search dialog
126
127 Get pbOK to bOk
128 If bOk Begin
129 If not bCkBox Begin
130 Get Value of hoSearchForm to sValue
131 End
132 Else Begin
133 Get Checked_State of hoSearchForm to bChecked
134 Get CheckedStateToValue of hoCol bChecked to sValue
135 End
136 End
137 Function_Return bOk
138 End_Procedure
139
140End_Class
141
142
143