Window Message und PowerBuilder - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Window Message und PowerBuilder

Description:

Windows hat ein Event gesteuertes User Interface, das von PowerBuilder ... Start Screensaver. To start the screen saver write: ** WM_SYSCOMMAND 0x0112 274 ... – PowerPoint PPT presentation

Number of Views:305
Avg rating:3.0/5.0
Slides: 30
Provided by: christop169
Category:

less

Transcript and Presenter's Notes

Title: Window Message und PowerBuilder


1
Window Message und PowerBuilder
  • Ludwin Feiten
  • Power People

2
Fahrplan
  • Motivation
  • Send Function
  • Beispiel
  • Suchen in der Win-API Help
  • Beispiel für PB Custom Events

3
Motivation
  • PowerBuilder hat die Send()-Funktion
  • Die Informationen darüber sind verstreut und
    mühsam zu finden.

4
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
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
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
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
Messages Wie kann man sie finden?
  • windows API help
  • http//msdn.microsoft. com/library/
  • winuser.h
  • C\Program Files\Sybase\Shared\PowerBuilder\cgen\h
    \nt\winuser.h

9
Bspl. Tab out a field
  • Suchen in der Windows API Hilfe mit
  • Key pressed notification
  • Führt zu
  • WM_KEYDONW

10
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
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
Besp. Scroll a window
  • Win32 and COM Development gt  User Interface gt 
    Windows Shell gt  Windows Controls gt  Individual
    Control Information gt  Scroll Bars 

13
Syntax WM_VSCROLL
  • 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.
  • 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.

14
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
Strategien zur Suche
  • Suche in MSDN Home gt  MSDN Library gt  Win32 and
    COM Development gt  User Interface gt  Windows
    Shell gt  Windows Controls
  • Subtopics
  • General Control Information
  • Individual Control Information
  • Suche unter
  • "Messages" and "Notifications"

16
Strategien zur Suche
  • Suche in winusers.h
  • nach brauchbaren Schlagwörtern.
  • Mappen von PB-Events auf WN-Events
  • Suche in spezieller Liste-gt www.powerpeople.de

17
PowerBuilder custom events
  • pbm_custom01 event ID maps to wm_user0
  • pbm_custom02 event ID maps to wm_user1,
  • pbm_custom75 event ID to wm_user74.
  • WM_USER is defined in winusers.h
  • define WM_USER 0x0400 1024

18
Application Ping-Pong
19
Ping - Pong
  • Suche der Instanzen des Programms (Find
    Instances)
  • Schicken eines Pings (Send Ping)
  • Empfangen des Ping (ue_ping)-gt Pong
  • Empfangen des Pong (ue_pong)

20
Find Instances
  • If nRet gt 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) 'rn'
  • //Exit
  • End If
  • Case FWP_CONTAINS
  • // Original autor Karl E. Peterson
  • // Aus VB "geklaut"
  • ulong hWndTmp,
  • FindWindowPartial
  • string lpClassName,
  • lpWindowName,
  • TitleTmp,
  • TitleStart
  • integer nRet
  • 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 ""

21
Send ping
  • unsignedlong hndl_me,
  • hndl_you
  • hndl_me handle(parent)
  • hndl_you long(em_win_handle.text)
  • IF hndl_you gt 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
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 Id1025)
  • send (wparam, 1025, handle(this), il_number )
  • end event

23
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
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
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
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
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
Einige Events
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
  • mailtoludwin.feiten_at_powerpeople.de
Write a Comment
User Comments (0)
About PowerShow.com