Project

General

Profile

Statistics
| Revision:

vdfsplat / AppSrc / cOutputWindow.pkg @ 58

History | View | Annotate | Download (11.7 KB)

1
//TH-Header
2
//*****************************************************************************************
3
// Copyright (c)  2004 Debug Project
4
// All rights reserved.
5
//
6
// $FileName    : cOutputWindow package
7
// $ProjectName : DebugAssistent
8
// $Authors     : Wil van Antwerpen
9
// $Created     : 27.07.2004  09:51
10
// $Type        : (C)opyright 2004 Antwise Solutions
11
//
12
// Contents:
13
//
14
//*****************************************************************************************
15
//TH-RevisionStart
16
//TH-RevisionEnd
17

    
18
// Use cOutputWindow.h
19
Use cWinFunc.pkg
20
Use cVirtualKeys.pkg
21
Use FindWindows.pkg
22

    
23
Integer ghoOutputWindow
24

    
25
Define IDC_EDIT1 For 1002   // == $3EA
26
Define IDC_EDIT2 For 1003   // == $3EA
27
Define IDC_EDIT3 For 1004   // == $3EA
28

    
29

    
30

    
31

    
32

    
33
Class cOutputWindow Is a dfObject
34

    
35
  Procedure Construct_Object
36
    Forward Send Construct_Object
37
    Property String  psCaption         Public "Output Window"
38
    Property Integer phWndOutputWindow Public 0
39
    Property Integer phWndEditBox      Public 0
40
    Property Integer phWndCloseButton  Public 0
41
    Property Integer phWndClearButton  Public 0
42
  End_Procedure // Construct_Object
43

    
44

    
45
  // This function will find the current output window of this
46
  // application and set all the window handles to the
47
  // current outputwindow
48
  // If there is no output window
49
  Function OutputWindowConnected Returns Boolean
50
    Integer hDlg         // Variable that stores the output dialog handle
51
    Handle  hWndEdit     // Variable that stores the edit window handle
52
    Handle  hWndCloseBtn
53
    Handle  hWndClearBtn //
54
    Handle  hWndChild
55
    DWORD   dwStyle      // Variable to manipulate the window style
56
    Integer bTest        // Variable to test the results
57
    Boolean bOk
58
    String  sCaption
59

    
60
    Get psCaption To sCaption
61
    Move (False) To bOk
62
    // Get handle of output window dialog.
63
    Move ( FindWindow("", sCaption) ) To hDlg
64
    If (hDlg=0) Begin
65
      // no output window, create it.
66
      Showln ""
67
    End
68
    Move ( FindWindow("", sCaption) ) To hDlg
69
    If (hDlg <> 0) Begin
70
      Get FindNextChildWindowByClass hDlg 0 'Button' To hWndChild
71
      Move hWndChild To hWndCloseBtn
72
      Get FindNextChildWindowByClass hDlg hWndChild 'Button' To hWndChild
73
      Move hWndChild To hWndClearBtn
74
      Get FindNextChildWindowByClass hDlg hWndChild 'Edit' To hWndChild
75
      Move hWndChild To hWndEdit
76
      Move (True) To bOk
77
      Set phWndOutputWindow To hDlg
78
      Set phWndEditBox      To hWndEdit
79
      Set phWndCloseButton  To hWndCloseBtn
80
      Set phWndClearButton  To hWndClearBtn
81
    End
82
    Else Begin
83
      Set phWndOutputWindow To 0
84
      Set phWndEditBox      To 0
85
      Set phWndCloseButton  To 0
86
      Set phWndClearButton  To 0
87
    End
88
    Function_Return (bOk)
89
  End_Function // OutputWindowConnected
90

    
91
  // Clears the output window
92
  Procedure Clear
93
    Handle  hWnd
94
    Handle  hWndClearBtn
95
    Integer iVoid
96
    If (OutputWindowConnected(Self)) Begin
97
      Get phWndOutputWindow To hWnd
98
      Get phWndClearButton  To hWndClearBtn
99
      Move (SetForegroundWindow(hWnd)) To iVoid
100
      Move (SetFocus(hWndClearBtn)) To iVoid
101
      If (ghoVirtualKeyboard) Begin
102
        //  VK_RETURN
103
        Send KeyStroke Of ghoVirtualKeyboard VK_LBUTTON 0 1
104
        Send KeyStroke Of ghoVirtualKeyboard VK_LBUTTON 1 1
105
      End
106
    End
107
  End_Procedure // Clear
108

    
109
  Procedure Beginning_Of_Data
110
    If (OutputWindowConnected(Self)) Begin
111
      Send SetToForegroundWindow
112
      If (ghoVirtualKeyboard) Begin
113
        //Send KeyStroke Of ghoVirtualKeyboard VK_CONTROL 0 1
114
        //Send KeyStroke Of ghoVirtualKeyboard VK_HOME 0 1
115
        //Send KeyStroke Of ghoVirtualKeyboard VK_HOME 1 1
116
        //Send KeyStroke Of ghoVirtualKeyboard VK_CONTROL 1 1
117
        Send Key Of ghoVirtualKeyboard (Key_Ctrl+Key_Home)
118
      End
119
    End
120
  End_Procedure // Beginning_Of_Data
121

    
122
  Procedure End_Of_Data
123
    If (OutputWindowConnected(Self)) Begin
124
      Send SetToForegroundWindow
125
      If (ghoVirtualKeyboard) Begin
126
        //Send KeyStroke Of ghoVirtualKeyboard VK_CONTROL 0 1
127
        //Send KeyStroke Of ghoVirtualKeyboard VK_HOME 0 1
128
        //Send KeyStroke Of ghoVirtualKeyboard VK_HOME 1 1
129
        //Send KeyStroke Of ghoVirtualKeyboard VK_CONTROL 1 1
130
        Send Key Of ghoVirtualKeyboard (Key_Ctrl+Key_End)
131
      End
132
    End
133
  End_Procedure // End_Of_Data
134

    
135
  Function Line_Count Returns Integer
136
    Integer iCount
137
    Handle  hWndEdit
138
    If (OutputWindowConnected(Self)) Begin
139
      Get phWndEditBox To hWndEdit
140
      If (hWndEdit) Begin
141
        //Get Windows_Message iMsg wParam lParam
142
        Move (SendMessage(hWndEdit,EM_GETLINECOUNT,0,0)) To iCount
143
        Decrement iCount
144
      End
145
    End
146
    Function_Return iCount
147
  End_Function // Line_Count
148

    
149
  Procedure Close_Panel
150
    Handle  hWnd
151
    Integer iVoid
152
    Get phWndOutputWindow To hWnd
153
    If (hWnd) Begin
154
      Move (SendMessage(hWnd,WM_CLOSE,0,0)) To iVoid
155
    End
156
  End_Procedure // Close_Panel
157

    
158

    
159
  // Switch to multibyte character set
160
  // This can be used for for ex. displaying the Euro sign
161
  Procedure MultiByteCharacterSet
162
    Handle  hWndEdit     // Variable that stores the edit window handle
163
    DWORD   dwStyle      // Variable to manipulate the window style
164
    Integer iVoid        // Variable to test the results
165

    
166
    If (OutputWindowConnected(Self)) Begin
167
      Get phWndEditBox To hWndEdit
168
      If (hWndEdit <> 0) Begin
169
        // Change the style - remove ES_OEMCONVERT!
170
        Move (GetWindowLong(hWndEdit, GWL_STYLE)) To dwStyle
171
        If (dwStyle Iand ES_OEMCONVERT);
172
            Move (dwStyle - ES_OEMCONVERT) To dwStyle
173
        Move (SetWindowLong(hWndEdit, GWL_STYLE, dwStyle)) To iVoid
174
      End
175
    End
176
  End_Procedure // MultiByteCharacterSet
177

    
178

    
179
  // Property Oem_Translate_State (can only be set)
180
  // Default: True
181
  // If set to true the text is converted from the Windows
182
  // Character Set To the OEM Character Set And then back
183
  // To the Windows Character Set.
184
  //
185
  // Set the OEM_Translate_State To False if you want to display
186
  // multibyte characters such as the EURO
187
  Procedure Set Oem_Translate_State Boolean bState
188
    Handle  hWndEdit     // Variable that stores the edit window handle
189
    DWORD   dwStyle      // Variable to manipulate the window style
190
    Integer iVoid        // Variable to test the results
191

    
192
    If (OutputWindowConnected(Self)) Begin
193
      Get phWndEditBox To hWndEdit
194
      If (hWndEdit <> 0) Begin
195
        // Change the style - remove ES_OEMCONVERT!
196
        Move (GetWindowLong(hWndEdit, GWL_STYLE)) To dwStyle
197
        If (bState) Begin
198
          Move (dwStyle Ior ES_OEMCONVERT) To dwStyle
199
        End
200
        Else Begin
201
          If (dwStyle Iand ES_OEMCONVERT);
202
              Move (dwStyle - ES_OEMCONVERT) To dwStyle
203
        End
204
        Move (SetWindowLong(hWndEdit, GWL_STYLE, dwStyle)) To iVoid
205
      End
206
    End
207
  End_Procedure // Oem_Translate_State
208

    
209
  // Property OnTopState, can only be set
210
  // If set to true the outputwindow will put itself on top of
211
  // all the the other windows, including other programs.
212
  // If set to false the topmost setting will be reset and the
213
  // output window will behave as any other window.
214
  Procedure Set OnTopState Boolean bState
215
    Integer iVoid
216
    Integer tmMode
217
    Handle  hWnd
218
    If (OutputWindowConnected(Self)) Begin
219
      Get phWndOutputWindow To hWnd
220
      If bState Move HWND_TOPMOST To tmMode
221
      Else Move HWND_NOTOPMOST To tmMode
222
      //Set MyTopMost_State To State                              x  y  cx cy
223
      Move (SetWindowPos(hWnd, tmMode, 0, 0, 0, 0, (SWP_NOMOVE Ior SWP_NOSIZE))) To iVoid
224
    End
225
  End_Procedure // Set OnTopState
226

    
227
  // Brings the outputwindow to the foreground, the focus is put on
228
  // the editbox
229
  Procedure SetToForegroundWindow
230
    Integer iVoid
231
    Handle  hWnd
232
    Handle  hWndEdit
233
    If (OutputWindowConnected(Self)) Begin
234
      Get phWndOutputWindow To hWnd
235
      Get phWndEditBox      To hWndEdit
236
      Move (SetForegroundWindow(hWnd)) To iVoid
237
      Move (SetFocus(hWndEdit)) To iVoid
238
    End
239
  End_Procedure // SetToForegroundWindow
240

    
241

    
242
  Procedure SetOutputWindowToMultiByteCharacterSet
243
    Integer hDlg         // Variable that stores the output dialog handle
244
    Handle  hWndEdit     // Variable that stores the edit window handle
245
    Handle  hWndCloseBtn
246
    Handle  hWndClearBtn //
247
    Handle  hWndChild
248
    DWORD   dwStyle      // Variable to manipulate the window style
249
    Integer bTest        // Variable to test the results
250

    
251

    
252
    // Get handle of output window dialog.
253
    Move ( FindWindow("", "Output Window") ) To hDlg
254

    
255
    If (hDlg <> 0) Begin
256
        Showln "The windows dialog = "(IntToHex(hDlg))
257
        //// Get handle of edit control that displays output.
258
        Move (GetDlgItem(hDlg, IDC_EDIT1)) To hWndEdit
259
        Showln "The correct EDIT handle is " (IntToHex(hWndEdit))
260
        //If (hWndEdit <> 0) Begin
261
        //    // Change the style - remove ES_OEMCONVERT!
262
        //    Move (GetWindowLong(hWndEdit, GWL_STYLE)) To dwStyle
263
        //    If (dwStyle Iand ES_OEMCONVERT);
264
        //        Move (dwStyle - ES_OEMCONVERT) To dwStyle
265
        //    Move (SetWindowLong(hWndEdit, GWL_STYLE, dwStyle)) To bTest
266
        //End
267

    
268
        Get FindNextChildWindowByClass hDlg 0 'Button' To hWndChild
269
        Move hWndChild To hWndCloseBtn
270
        Get FindNextChildWindowByClass hDlg hWndChild 'Button' To hWndChild
271
        Move hWndChild To hWndClearBtn
272
        Get FindNextChildWindowByClass hDlg hWndChild 'Edit' To hWndChild
273
        Move hWndChild To hWndEdit
274

    
275
        Showln "EDIT2 = " (IntToHex(hWndEdit))
276
        //Move (GetDlgItem(hDlg, IDC_EDIT2)) To hWndCloseBtn
277
        Showln "CLOSE = " (IntToHex(hWndCloseBtn))
278
       // Move (GetDlgItem(hDlg, IDC_EDIT3)) To hWndClearBtn
279
        Showln "CLEAR = " (IntToHex(hWndClearBtn))
280
    End
281
    //Showln "The handle of the dialog is " hDlg
282
    //Showln "The handle of the edit is " hWndEdit
283
          //If State Move HWND_TOPMOST To tmMode
284
          //Else Move HWND_NOTOPMOST To tmMode
285
          //Set MyTopMost_State To State                              x  y  cx cy
286
          //Move (SetWindowPos(Window_Handle(Current_Object), tmMode, 0, 0, 0, 0, (SWP_NOMOVE Ior SWP_NOSIZE))) To retval
287
          //Move (SetWindowPos(hDlg, HWND_TOPMOST, 300, 50, 0, 0, (SWP_NOSIZE))) To bTest
288
          If (hWndEdit) Begin
289
            Move (SetForegroundWindow(hDlg)) To bTest
290
            Move (SetFocus(hWndEdit)) To bTest
291
          End
292
  End_Procedure // SetOutputWindowToMultiByteCharacterSet
293

    
294

    
295
End_Class // cOutputWindow
296

    
297

    
298
Object oOutputWindow Is a cOutputWindow
299
  Move Self To ghoOutputWindow
300
End_Object // oOutputWindow
301

    
302

    
303

    
304
Procedure CallDebugger
305
  Integer hDlg       // Variable that stores the output dialog handle
306
  Integer hWndEdit   // Variable that stores the edit window handle
307
  DWORD   dwStyle    // Variable to manipulate the window style
308
  Integer bTest      // Variable to test the results
309

    
310

    
311
  // Get handle of output window dialog.
312
  Move ( FindWindow("RHBUG", "") ) To hDlg
313

    
314
  If (hDlg <> 0) Begin
315
      // Get handle of edit control that displays output.
316
      //Move (GetDlgItem(hDlg, IDC_EDIT1)) To hWndEdit
317
      //If (hWndEdit <> 0) Begin
318
      //  Showln "DEbug EDIT gevonden"
319
          // Change the style - remove ES_OEMCONVERT!
320
          //Move (GetWindowLong(hWndEdit, GWL_STYLE)) To dwStyle
321
          //If (dwStyle Iand ES_OEMCONVERT);
322
          //    Move (dwStyle - ES_OEMCONVERT) To dwStyle
323
          //Move (SetWindowLong(hWndEdit, GWL_STYLE, dwStyle)) To bTest
324
      //End
325
      Showln "Debugger gevonden"
326
      //Move (SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOMOVE Ior SWP_NOSIZE))) To bTest
327
      Move (SetForegroundWindow(hDlg)) To bTest
328
  End
329

    
330
End_Procedure // CallDebugger