Domain Builder

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Sunday, 27 January 2008

Capturing Special Keys on your DataWindow

Posted on 23:47 by Unknown
A common requirement for applications is to capture certain keystrokes and perform special
actions when the user presses these keys. To capture keystrokes on your DataWindow, do the
following:
  1. Declare an event on your DataWindow (possibly your ancestor DW, as is done here) and assign that event the pbm_dwnkey event id. This causes all keystrokes to be processed through the event.
  2. Code that event to handle the special keystrokes in the desired manner. Ideally, common keystrokes (like Enter, Tab) will be captured at the ancestor level and a standard event will be called. A sample event that catches certain keystrokes is shown below.
In this sample event, the following keystrokes can be captured:
  • tabs: to do so, a descendant DW sets the ib_CaptureTab instance variable to True. The
    ue_Tab or ue_BackTab event are then invoked when Tab/BackTab is pressed to allow
    the descendant to code appropriate logic.
  • enter keys: to do so, a descendant DW sets the ib_CaptureEnter instance variable to True.
    The ue_Enter event is then called when Enter is pressed to allow the descendant to code
    appropriate logic.
sample ue_key event code:
// if descendent DW wants tab ... capture it
IF ib_CaptureTab AND KeyDown(KeyTab!) THEN
// determine whether it is a tab or back-tab
IF NOT KeyDown(KeyShift!) THEN
This.POST ue_Tab()
ELSE
This.POST ue_BackTab()
END IF
Return 1 // have key not otherwise be ignored by PB

// if descendent DW wants enter keys ... capture it
ELSEIF ib_CaptureEnter AND KeyDown(KeyEnter!) THEN
This.POST ue_Enter()
Return 1 // have key not otherwise be ignored by PB

// otherwise send the key to the window-level for standard processing
ELSE
IF IsValid(iw_ParentWin) THEN
iw_ParentWin.TriggerEvent(Key!)
ELSE
// how did we get a key event for invalid parent?
f_SignalError(0/gi_zero,"Invalid Parent Window in Key Event")
END IF
END IF


Note: a handle to the parent window (iw_ParentWin) is obtained in the Constructor event. PFC's
of_GetParentWindow function is a good method to generically get a handle to the parent
window.
Email ThisBlogThis!Share to XShare to Facebook
Posted in DataWindow | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Using Windows Scripting Host
    You can use Windows Scripting Host on PowerBuilder for many purpose. On sample code below, you can use it to get the network domain, user na...
  • List available ODBC datasources
    You can list available ODBC datasources from within PowerBuilder. You need to declare the following external functions : FUNCTION integer SQ...
  • Sorting Datawindow
    Here's a script to sort datawindow rows when the column header is clicked as in windows explorer. Requirements : Column header should be...
  • Faster Exist Checking in Oracle
    When performing checks in business logic to see if a record is used as part of a foreign key in a child table people often opt for the Selec...
  • Return Code on Application Exit
    Sometime when a PowerBuilder application is called by other program or a shell script, programmer want a return code after exiting the Power...
  • Keeping Column into Array
    With this simple tips you can keep all the column name on DataWindow into an array int colNum, numCols string colName[] numCols = Integer(dw...
  • Julian Date
    Here's a function to calculate Julian Day number for the specified day, month, year. If the year is B.C. it must be negative. /* public...
  • Getting Computer Name
    You can get the computer name from within the application. Declare the Win32 API modul on Declare -> Local External Functions Function bo...
  • Get a list of printers installed
    In this example, we populate a listbox with the printers name /* Get Printer List */ string printers[] int rtn, i, nbPrinters rtn = Registry...
  • Calling Oracle Stored Procs/Functions from PB
    Whenever you want to make a call to an Oracle stored procedure or stored function, a good approach is to first declare it as an external fun...

Categories

  • Database
  • DataWindow
  • PowerScript
  • Win32 API

Blog Archive

  • ▼  2008 (34)
    • ►  March (14)
    • ►  February (1)
    • ▼  January (19)
      • Avoiding "Double" Error Messages in DW Validation
      • Capturing Special Keys on your DataWindow
      • Center a Response Window
      • If Statements Using SQL
      • Run an Application Only Once
      • C/C++ Datatype Conversion
      • Registering OCX Components in an Exe
      • Get The Name of a Network Share
      • Get Volume Information
      • Mapping a Network Drive
      • Getting Active Directory
      • Getting Computer Name
      • Sending Key Press
      • Sending Hexadecimal Character to Printer
      • Calling an Internet Browser from Application
      • Getting Date Format from Windows Registry
      • Return Code on Application Exit
      • Sitemap
      • Privacy Policy
Powered by Blogger.

About Me

Unknown
View my complete profile