Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ludwin Feiten Window Message und PowerBuilder Ludwin Feiten Power People.

Similar presentations


Presentation on theme: "Ludwin Feiten Window Message und PowerBuilder Ludwin Feiten Power People."— Presentation transcript:

1 Ludwin Feiten Window Message und PowerBuilder Ludwin Feiten Power People

2 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 2/29 Fahrplan Motivation Send Function Beispiel Suchen in der Win-API Help Beispiel für PB Custom Events …

3 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 3/29 Motivation PowerBuilder hat die Send()-Funktion Die Informationen darüber sind verstreut und mühsam zu finden.

4 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 4/29 Window Events PowerBuilder ist eine Windows Anwendung Windows hat ein Event gesteuertes User Interface, das von PowerBuilder genutzt werden kann. Triggern von Events durch senden von Messages an Controls. SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );

5 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 5/29 SendMessage Function In Windows sind nicht nur Windows windows sondern auch fast alle anderen visuellen Control wie Buttons, Scrollbars, Editfields, etc. Zur Identifizierung gibt es einen handle

6 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 6/29 Send Function in PowerBuilder Send ( handle, message#, lowword, long ) –handle: A long whose value is the system handle of a window (that you have created in PowerBuilder or another application) to which you want to send a message. –message#: An UnsignedInteger whose value is the system message number of the message you want to send. –Lowword: A long whose value is the integer value of the message. If this argument is not used by the message, enter 0. –Long: The long value of the message or a string.

7 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 7/29 Send Function: Beispiele Dieses Statement scrollt das Fenster w_emp eine Seite hoch: –Send(Handle(w_emp), 277, 2, 0) Das folgende Statements click den CommandButton cb_OK: –Send(Handle(Parent), 273, 0, Handle(cb_OK))

8 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 8/29 Messages: Wie kann man sie finden? windows API help –http://msdn.microsoft. com/library/ winuser.h –C:\Program Files\Sybase\Shared\PowerBuilder\c gen\h\nt\winuser.h

9 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 9/29 Bspl.: Tab out a field Suchen in der Windows API Hilfe mit –Key pressed notification Führt zu: –WM_KEYDONW

10 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 10/29 Syntax WM_KEYDOWN WM_KEYDOWN WPARAM wParam LPARAM lParam wParam: Specifies the virtual-key code of the nonsystem key. lParam: Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. 0-15: Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative. 16-23: Specifies the scan code. The value depends on the OEM 24: Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0, 25-28: Reserved; do not use 29: Specifies the context code. The value is always 0 for a WM_KEYDOWN message 30: Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up 31: Specifies the transition state. The value is always zero for a WM_KEYDOWN message Return Value: An application should return zero if it processes this message. 24: Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0, 25-28: Reserved; do not use 29: Specifies the context code. The value is always 0 for a WM_KEYDOWN message 30: Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up 31: Specifies the transition state. The value is always zero for a WM_KEYDOWN message Return Value: An application should return zero if it processes this message.

11 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 11/29 Nächster Schritt winuser.h –#define WM_KEYDOWN 0x0100 hex 0x0100 ist dec 256. (Windows Rechner in Wissenschaftlicher Ansicht) wParam muss der ASCII-Code for the Tab-Key sein: Das ist 9. lParam ist Null. Der Aufruf ist: send(Handle(this), 256,9, long(0,0))

12 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 12/29 Besp. Scroll a window Win32 and COM DevelopmentWin32 and COM Development > User Interface > Windows Shell > Windows Controls > Individual Control Information > Scroll Bars User InterfaceWindows ShellWindows ControlsIndividual Control InformationScroll Bars

13 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 13/29 Syntax WM_VSCROLL WM_VSCROLL –WPARAM wParam –LPARAM lParam; wParam: –The high-order word specifies the current position of the scroll box if the low-order word is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, this word is not used. –The low-order word specifies a scroll bar value that indicates the user's scrolling request. This parameter can be one of the following values. SB_BOTTOM: Scrolls to the lower right. SB_ENDSCROLL: Ends scroll. SB_LINEDOWN: Scrolls one line down. SB_LINEUP: Scrolls one line up. SB_PAGEDOWN: Scrolls one page down. SB_PAGEUP: Scrolls one page up. SB_THUMBPOSITION: The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation. SB_THUMBTRACK: The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to. SB_TOP: Scrolls to the upper left. lParam: –If the message is sent by a scroll bar, this parameter is the handle to the scroll bar control. If the message is not sent by a scroll bar, this parameter is NULL.

14 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 14/29 Nächster Schritt: winuser.h –#define WM_VSCROLL 0x0115 hex 0x0115 ist dec 277. SB_PAGEDOWN ist 3 lParam ist Null. Der Aufruf ist: send(Handle(this), 277,3, long(0,0))

15 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 15/29 Strategien zur Suche Suche in: MSDN Home > MSDN Library > Win32 and COM Development > User Interface > Windows Shell > Windows ControlsMSDN HomeMSDN LibraryWin32 and COM DevelopmentUser InterfaceWindows ShellWindows Controls Subtopics: General Control Information Individual Control Information Suche unter: "Messages" and "Notifications"

16 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 16/29 Strategien zur Suche Suche in winusers.h nach brauchbaren Schlagwörtern. Mappen von PB-Events auf WN- Events Suche in spezieller Liste: -> www.powerpeople.dewww.powerpeople.de

17 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 17/29 PowerBuilder custom events pbm_custom01 event ID maps to wm_user+0 pbm_custom02 event ID maps to wm_user+1, … pbm_custom75 event ID to wm_user+74. WM_USER is defined in winusers.h: #define WM_USER0x0400= 1024

18 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 18/29 Application Ping-Pong

19 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 19/29 Ping - Pong Suche der Instanzen des Programms (Find Instances) Schicken eines Pings (Send Ping) Empfangen des Ping (ue_ping)-> Pong Empfangen des Pong (ue_pong)

20 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 20/29 Find Instances // Original autor: Karl E. Peterson // Aus VB "geklaut" ulonghWndTmp,& FindWindowPartial string lpClassName,& lpWindowName,& TitleTmp,& TitleStart integernRet integer method constant integer FWP_STARTSWITH = 1 constant integer FWP_CONTAINS = 0 constant integer GW_HWNDNEXT = 2 TitleStart = parent.title// "Application Ping Pong" mle_windows.text = "" setnull(lpClassName) setnull(lpWindowName) hWndTmp = FindWindow(lpClassName, lpWindowName) Do Until hWndTmp = 0 // // Make sure this window has no parent. // If GetParent(hWndTmp) = 0 Then // // Retrieve caption text from current window. // TitleTmp = Space(256) nRet = GetWindowText(hWndTmp, TitleTmp, Len(TitleTmp)) If nRet > 0 Then // // Clean up return string, preparing for // case-insensitive comparison. // TitleTmp = upper(Left(TitleTmp, nRet)) // // Use appropriate method to determine if // current window//s caption either starts // with or contains passed string. // CHOOSE Case Method Case FWP_STARTSWITH If pos(TitleTmp, upper(TitleStart)) = 1 Then FindWindowPartial = hWndTmp mle_windows.text += TitleTmp + ' HWND: ' + string(FindWindowPartial) + '~r~n' //Exit End If Case FWP_CONTAINS If pos(TitleTmp, upper(TitleStart)) > 0 Then FindWindowPartial = hWndTmp mle_windows.text += TitleTmp + ' HWND: ' + string(FindWindowPartial) + '~r~n' // Exit End If End CHOOSE End If // // Get next window in master window list and continue. // hWndTmp = GetWindow(hWndTmp, GW_HWNDNEXT) Loop

21 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 21/29 Send ping unsignedlong hndl_me,& hndl_you hndl_me = handle(parent) hndl_you = long(em_win_handle.text) IF hndl_you > 0 THEN // Send a ping to pbm_custom01 and transmit my handle and instance number in the params send (hndl_du, 1024, hndl_ich, il_nummer ) ; ELSE MessageBox("Oups", em_window.text + " is not running!") END IF

22 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 22/29 ue_ping event ue_ping pbm_custom01 Messagebox("Here is window: "+string(handle(this))," Got a Ping from: " + string (wparam) + " with Instance No. "+string(lparam) ) // Pong to sender of the Ping (Event Id:1025) send (wparam, 1025, handle(this), il_number ) ; end event

23 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 23/29 ue_pong event ue_ping pbm_custom02 Messagebox("Here is window: "+string(handle(this))," Got the Pong from: " + string (wparam) + " with Instance No. "+string(lparam) ) end event

24 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 24/29 Starting Syscommands Start Screensaver To start the screen saver write: /* ** WM_SYSCOMMAND 0x0112 274 ** SC_SCREENSAVE 0xF140 61760 */ send(handle(This),274,61760,0)

25 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 25/29 Starting Syscommands Maximize a frame To maximize a window when it opens put the following code into the Open event. CONSTANT Integer WM_SYSCOMMAND = 274 CONSTANT UInt SC_MAXIMIZE = 61488 // Send(Handle(This), WM_SYSCOMMAND, SC_MAXIMIZE, 0)

26 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 26/29 Starting Syscommands CONSTANT Integer WM_SYSCOMMAND = 274 CONSTANT UInt SC_MAXIMIZE = 61488 CONSTANT UInt SC_CLOSE = 61536 // 0xF060 CONSTANT UInt SC_SCREENSAVE = 61760 // 0xF140 CONSTANT UInt SC_RESTORE = 61728 // 0xF120 CONSTANT UInt SC_MINIMIZE = 61472 // 0xF020 Send(Handle(w_test), WM_SYSCOMMAND, SC_MINIMIZE, long(0,0) ) ………… send(Handle(Parent),16,0,0) //Close

27 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 27/29 Ein Window ohne Titlebar verschieben Um ein Window ohne Titlebar zu verschieben muss der folgende Code in das mousedown event. CONSTANT uint WM_NCLBUTTONDOWN = 161 CONSTANT uint HTCAPTION = 2 Post( Handle( this ), WM_NCLBUTTONDOWN, HTCAPTION, Long( xpos, ypos ) )

28 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 28/29 Einige Events … messagelowwordlong KeyboardWM_KEYDOWN = 256 WM_KEYUP = 257 ASCII Value of the nonsystem Key Backspace8 Tab9 carriage return13 0 Mouse WM_LBUTTONDBLCLK= 515 MK_LBUTTON0x0001 MK_RBUTTON0x0002 MK_SHIFT0x0004 MK_CONTROL0x0008 MK_MBUTTON0x0010 The low-order word specifies the x-coordinate of the cursor. The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. SliderWM_HSCROLL = 276 WM_VSCROLL = 277 SB_LINEUP 0 SB_LINELEFT 0 SB_LINEDOWN 1 SB_LINERIGHT 1 SB_PAGEUP 2 SB_PAGELEFT 2 SB_PAGEDOWN 3 SB_PAGERIGHT 3 SB_THUMBPOSITION 4 SB_THUMBTRACK 5 SB_TOP 6 SB_LEFT 6 SB_BOTTOM 7 SB_RIGHT 7 SB_ENDSCROLL 8 0

29 Ludwin Feiten PBUGG Düsseldorf 26.05.2006 Window Messages und PowerBuilder Folie 29/29 Kontakt Sind noch Fragen offen? Bei Rückfragen oder Anregungen bitte an: Ludwin Feiten Power People Inh. Ludwin Feiten Am Borsigturm 50 D-13507 Berlin fon +49 (0)30 43032350 fax +49 (0)30 43032355 http://www.powerpeople.de mailto:ludwin.feiten@powerpeople.de


Download ppt "Ludwin Feiten Window Message und PowerBuilder Ludwin Feiten Power People."

Similar presentations


Ads by Google