1 / 52

PWB510 Pocket PowerBuilder Advanced Topics

PWB510 Pocket PowerBuilder Advanced Topics. Reed Shilts / Michael Cobb Pocket PowerBuilder Engineering. Pocket PowerBuilder Advanced Topics. Session Overview. Pocket PowerBuilder IDE Designing a Pocket PC User Interface Migrating code between Pocket PowerBuilder and PowerBuilder 9.0

albert
Download Presentation

PWB510 Pocket PowerBuilder Advanced Topics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PWB510 Pocket PowerBuilder Advanced Topics Reed Shilts / Michael CobbPocket PowerBuilder Engineering

  2. Pocket PowerBuilder Advanced Topics Session Overview • Pocket PowerBuilder IDE • Designing a Pocket PC User Interface • Migrating code between Pocket PowerBuilder and PowerBuilder 9.0 • Database connections to ASA • Synchronizing remote database using MobiLink • Packaging & Deployment • WinCE fun with external function calls

  3. Pocket PowerBuilder IDE • PK10U.EXE • Very similar to PowerBuilder 9.0 • New file extensions • Workspace - PKW • Target – PKT • Library – PKL • Runtime library – PKD • Resource file – PKR

  4. Window Painter Pocket PowerBuilder IDE • Main Window • Show SIP Button • Close (OK) RecommendedWindow is destroyed – Close event processed • Smart Minimize (X)Window is NOT destroyed on CE – resize event (sizetype=1) fires Close event fires on desktop but not on PDANext window open command causes resize event (sizetype=0) to fire on CENext open command causes open event to fire on desktop • Response Window • No menu bar • No Smart Minimize

  5. Project Painter Pocket PowerBuilder IDE • Deployment Targets • CE device • PPC 2000 emulator • PPC 2002 emulator • PPC 2003 emulator and devices in next release • desktop • Version information • Applicable for desktop • Applicable for CAB file when deploying to PDA • Build CAB file for distribution

  6. Database Painter Pocket PowerBuilder IDE • One DB Interface in release 1.0 • ODBC to Adaptive Server Anywhere • ADO/CE will be available in a future release • MobiLink Synchronization Server • Occasionally connected applications • Launches dbmlsrv8 as a separate process • Connects to consolidated database • Sybase Central • Launches a separate Sybase Central process • DBPaint sample application for ASA on device

  7. Debugger Pocket PowerBuilder IDE • Use debugger to test desktop deployment in release 1.0 • Same behavior as PowerBuilder 9.0 debugger • Remote debugging planned for future release • CE debugging suggestions • Message boxes • Log entries in a multi-line edit control

  8. New Wizards Pocket PowerBuilder IDE • Import desktop to CE • Migrates PowerBuilder libraries to Pocket PowerBuilder format • New libraries copied to same directory as old libraries with .PKL extension • Export CE to desktop • Migrates Pocket PowerBuilder libraries to PowerBuilder 9.0 format • New libraries copied to same directory as old libraries with .PBL extension • MobiLink Synchronization for ASA • Generates objects for launching MobiLink synchronization from remote client • Optional window to change dbmlsync runtime arguments • Sync User and Subscription Maintenance • Available in PPB 1.01 • Generates objects to maintain synchronization user and subscriptionsin a remote ASA database

  9. User Interface for Pocket PC Applications Best Practices • Minimize the use of global variables • Easier to reuse code • Use one or more custom class user objects • Instantiate user object in application open event • Destroy user object in application close event • UO Instance variables take the place of global variables • UO functions take the place of global functions • Inherit from a base UO for code reuse • Main window acts as “dispatcher” for the application • Partition each module in a separate PKD for memory efficiency • Design UI to minimize typing – Let the user select choices from a list wherever possible

  10. Treeview Controls User Interface for Pocket PC Applications • Ideal for main window • Hierarchical presentation of data • Single select only • Expand / Collapse individual treeview items • Use the data property of treeviewitem objects to store additional information • Encapsulate treeview processing logic in standard visual user object inherited from “treeview” • Context menus • Context menus are declared as instance variables of treeview user object • Create context menus in treeview constructor event • Destroy menus in destructor event • Rightclicked event – tap and hold • Different context menu depending on the treeview item selected

  11. Listview Controls User Interface for Pocket PC Applications • Each entry may contain multiple columns • ExtendedSelect property allows multiple selects • Use the data property of listviewitem objects to store additional information • Encapsulate listview processing logic in standard visual user object inherited from “listview”

  12. Tab Controls User Interface for Pocket PC Applications • Great way to maximize real estate • Tab labels appears at the bottom of page • Controlling tab pages • SelectedTab property tells you which tab has focus • SelectTab() function programmatically selects a new tab page • SelectionChanged event tells you when selected tab page changes

  13. DirList Function User Interface for Pocket PC Applications • Populates a listbox with a list of files • On Pocket PC, do not create the listbox dynamically • Simply hide the listbox if you wish to present the list in a treeview or datawindow String as_dsns[] Long numdsns, i Boolean bDirListOK a_listbox.Reset() bDirListOK = a_listbox.DirList("\*.dsn", 1) if bDirListOK then numdsns = a_listbox.TotalItems() for i = 1 to numdsns as_dsns[i] = a_listbox.Text(i) next else messagebox("DirList Failed", "") end if

  14. Migrating Code Between PPB and PB 9 Overview • Export CE to desktop wizard • Converts entire Pocket PowerBuilder target to PB 9 format • .PBL files in ANSI format • Select “File, New, Tool” from system menu • Import desktop to CE wizard • Converts PowerBuilder 9.0 target to Pocket PowerBuilder format • .PKL files in Unicode format • Select “File, New, Target” from system menu • Importing a single object • Pocket PowerBuilder reads either ANSI or Unicode source file • Exporting a single object • Pocket PowerBuilder exports source in Unicode format • Use Notepad to open object and save as ANSI file before importing into PowerBuilder 9.0

  15. Database Connections to ASA Overview • Create CE database on desktop • Create File DSN with connection information • Simple ASCII text file copied to root directory of CE device • DBPaint application allows user to edit a file DSN once it is deployed to device • Copy database and DSN to device using ActiveSync • Open Main Window BEFORE connecting to ASA database

  16. Database Connections to ASA Sample Code // Window Open Event this.EVENT POST ue_postopen() // ue_postopen event sqlca.dbms='odb' sqlca.dbparm="ConnectString='DSN=SalesDB_remote'" // establish DB connection connect using sqlca;

  17. Synchronizing ASA Database with MobiLink

  18. Synchronizing ASA database with MobiLink Overview • Select “File, New, Database, MobiLink Synchronization for ASA” from system menu to launch wizard • Generates objects to launch MobiLink client on CE device • gf_application_name_sync(“MLUser”, “Mlpassword”) • gf_application_name_configure_sync() • nvo_application_name_sync • w_application_name_sync • w_application_name_sync_options • s_application_name_sync_parms

  19. Synchronizing ASA database with MobiLink User Object to control synchronization process • Nvo_application_name_sync • Instance variables contain the default runtime arguments for the sychronization client • Default runtime arguments (set by the application developer while running the wizard) are saved in WinCE Registry the first time the user object is instantiated • HKEY_CURRENT_USER\Software\Sybase\Pocket PowerBuilder\1.0u\application_name\MobiLink" • Subsequently, runtime arguments are read from the WinCE Registry • List of publications (-n) • MobiLink User (-u) • MobiLink Password (-mp) • Connectstring to remote ASA database (-c) • Log settings • Other runtime arguments & extended arguments • Host and Port address of MobiLink server • Window handle to receive WM_COPYDATA messages back from dbmlsync (-wh) • Window class name associated with dbmlsync process (-wc)

  20. Synchronizing ASA database with MobiLink User Object to control synchronization process • Functions in Nvo_application_name_sync • Uf_runsync() • Uf_runsync_with_window() • Uf_cancelsync() • Uf_encrypt_password() * • Uf_decrypt_password() * • Uf_set_mluser_name() • Uf_set_password() * You may wish to replace these functions with your own implementation

  21. Synchronizing ASA database with MobiLink User Object to control synchronization process • Events in Nvo_application_name_sync • Ue_begin_sync() • Ue_begin_logscan() • Ue_end_logscan() • Ue_connect_mobilink() • Ue_begin_upload() • Ue_end_upload() • Ue_wait_for_upload_ack() • Ue_upload_ack() • Ue_begin_download() • Ue_end_download() • Ue_disconnect_mobilink() • Ue_end_sync() • Ue_display_message() • Ue_error_message() • Ue_file_message() • Ue_progress_info() • Ue_warning_message()

  22. Synchronizing ASA database with MobiLink User Object to control synchronization process • How to Customize Event Processing in nvo_application_name_sync • Inherit from nvo_application_name_sync • Extend event scripts to perform your own processing • This.uf_cancelsync() lets you cancel the synchronization request • i_syncwindow.event DYNAMIC TRIGGER ue_display_msg(lmsg) • Customize gf_application_name_sync() function to instantiate your descendant nvo nvo_salesdb_sync_extended l_uosync long rc double dRC boolean bAppWin l_uosync = CREATE nvo_salesdb_sync_extended • Event processing is synchronous. MobiLink synchronization client waits • for your user event to complete before continuing.

  23. Synchronizing ASA database with MobiLink Implementing Synchronizations objects into your application • Create a new menuitem for “File, Synchronization Options” on a main window • Gf_application_name_configure_sync() • nvo is instantiated • w_application_name_sync_options window is opened for user to type password and other runtime arguments • User and password returned via sync_parms structure • gf_application_name_sync() is called to run the sync request

  24. New Wizard for ML User and Subscriptions ML User and Subscription Maintenance on the remote database • Select “File, New, Database, Sync User and Subscription Maintenance” from system menu to launch wizard • Generates objects to create MobiLink User and Subscription on the remote ASA database • nvo_application_name_mluser • w_application_name_mluser • w_application_name_mlsubscription • vo_application_name_mluser • m_application_name_mluser • d_application_name_mluser

  25. Packaging and Deployment

  26. Packaging and Deployment Overview • Generate a CAB file • Single package • Single Platform: “my_app.ARM.CAB” • Installed and Uninstalled • Basic level of User Deployment • Generate a “setup” program • The “my_setup.exe” which does everything. • Multiple CAB Files • Multiple Platforms • May Contain PK*.DLL redistributable files too • Easiest level for final customer • Pocket PB Helps You – Project Painter

  27. Package For Deploy (CAB) CAB file Project Painter – CheckBox: “Build CAB File for Distribution” • Generates “inf” file and runs “CabWiz” from Microsoft. • INF file is an ASCII text file • We leave the INF file and the BAT file around for your modification • Compatible with PPC-2003 standards • Uses Installation Directories • Uses Version Information fields • Company Name  “Provider Name” • Product Name  “Application Name” • Description  comment in header • Copyright  comment in header • Version  comment in header

  28. Package For Deploy (CAB) CAB file The INF file comes from a template file • %install%\Support\cabwiz\cab_template.inf Suggestion: • Rename and manipulate the generated INF file • Manipulate the template for common standards.Remember – keep copies since a PPB update may overwrite this file! Of course, we are considering what to put onto a “deploy options” wizard page…

  29. Package For Deploy (CAB) – Example (1/2) CAB Example Add A Shortcut on the Start Menu to the Application…. • Generate your application (foo.exe) • Generate the CAB file (foo.ARM.CAB & foo.x86.CAB) • Rename “foo.inf”  “myfoo.inf”Rename “foo_makecab.bat”  “myfoo_makecab.bat” • TextEdit “myfoo_makecab.bat” – change INF filename… (cont’d…)

  30. Package For Deploy (CAB) – Example (2/2) CAB Example (cont’d) • TextEdit “myfoo.inf” • Uncomment “;CEShortcuts=…” in [DefaultInstall] section • In [Shortcuts.All] section add the actual shortcut…Foo Application,0,foo.exe,%CE17% • Run batch file to create CABs“myfoo_makecab.bat” • Copy “myfoo.ARM.CAB” to PDA • To Install: Tap the CAB file • To Remove: “Settings  System  Remove Programs” Reference:www.msdn.microsoft.comSearch for: “CE 3.0” CAB Wizard

  31. Deploy with a Setup Program EZSetup Using EZSetup • FREE • Gnu Public License Software (source provided) • http://www.spbsoftwarehouse.com/enterprise/devtools/ezsetup.html Sybase Does Not Supply This (we cannot ship GPL software…) • To use, download and install to:%PPB_Install%\support\ezsetup

  32. Deploy with a Setup Program EZSetup Project Painter – • Just like for the CAB file (mostly) • Generates an initial “INI” file • INI file is an ASCII text file • We leave the INI file and the BAT file around for your modification • You must edit the INI file “CabFiles” section (add your CABs) • Create a “readme.txt” and “eula.txt” • Batch File has commented out line to run EZSetup • References:www.google.comSearch for: CE + EZSetup

  33. WinCE Fun With External Function Calls…

  34. WinCE Fun With External Function Calls… Overview Like Win3.1/WinNT/Win2K/WinXP, You can directly call other DLLs But – • WinCE uses different DLLs • e.g., Win32 “user32.dll”  WinCE “coredll.dll” • Some documented APIs are not “public” • WM_xxx messages have changes It’s Nice That – • Pocket PB generates Unicode Applications –WinCE has ONLY Unicode APIs…

  35. WinCE Fun With External Function Calls… Use Cases • FindWindowClassic External Function – but a different DLL name • Notification BubbleClassic External Function with a wrinkle. • Popup Calendar and INKCustom Window Types • SOAP Client3rd Party DLL through an adapter DLL

  36. WinCE Fun With External Function Calls… Classic External Function • FindWindowClassic External Function – but a different DLL name • Win32 – “user32.dll” public FUNCTION unsignedlong FindWindow( long cn, string WindowName ) LIBRARY "user32.dll" ALIAS … • WinCE – “coredll.dll” public FUNCTION unsignedlong FindWindow( long cn, string WindowName ) LIBRARY "coredll.dll" ALIAS …

  37. WinCE Fun With External Function Calls… Classic External Function Two ways to access…The “proper” way and the quickie way… Proper Way (O-O) • Abstract base class – “my_external_access”Methods like “FindWindow()” • Derived class – “my_external_access_CE”Override method like “FindWindow()” would use Win-CE DLL version • Derived class – “my_external_access_Win32”Override method like “FindWindow()” would use Win-32 DLL version • Create appropriate derived instance at startup • In all code reference the instance method “FindWindow”

  38. WinCE Fun With External Function Calls… Classic External Function “Less OO” Way… for a method like “FindWindow()”… public FUNCTION unsignedlong FindWindow_NT( long cn, string WindowName ) LIBRARY "user32.dll" ALIAS … public FUNCTION unsignedlong FindWindow_CE( long cn, string WindowName ) LIBRARY "coredll.dll" ALIAS … Create a local method “FindWindow()”… Using a global “environment env” object if env.OSType <> WindowsCE! then return FindWindow_NT( 0, sWinTitle ) else return FindWindow_CE( 0, sWinTitle ) end if

  39. WinCE Fun With External Function Calls… Classic with a Wrinkle • Notification BubbleClassic External Function with a wrinkle. • API Not Named in the DLL !!! • Can’t dynamically load by name.

  40. WinCE Fun With External Function Calls… Classic with a Wrinkle - WorkAround • “Shim” DLLA thin adapter from “C” API to hard linked DLL call… • Now - just regular external function calls… public FUNCTION long NotificationAdd( readonly string Title, readonly string Text, long hwndSink, long NotificationID, long Duration, long hIcon, long Flags)LIBRARY"Notification.dll” public FUNCTION long NotificationRemove... public FUNCTION long NotificationUpdate... • Available from CodeXchange

  41. WinCE Fun With External Function Calls… Notification API • By the way…..Will be a Native function in NEXT Version of Pocket PowerBuilder (“Pumpkin”)

  42. WinCE Fun With External Function Calls… New Window Types • Popup Calendar and INK • Window Class:"SysMonthCal32" • Window Class:"InkX"

  43. WinCE Fun With External Function Calls… New Window Types • Custom Window Types • In PocketBuilder use…hwnd = uf_createwindow("SysMonthCal32", Handle(this)) • The local function… public function unsignedlong uf_createwindow(string classname, unsignedlong hwndparent) // Create a window of the specified classname// as a child of the specified window.return = CreateWindowEx_CE( 0, ClassName, "", & WS_BORDER + WS_CHILD + WS_VISIBLE, & 0,0,0,0, & hwndParent, 0, 0, 0 ) End Function • Refer to PPB “Samples\misc\reeds_tests.pkt”

  44. WinCE Fun With External Function Calls… Calendar and INK • By the way…..Calendar and RichInk will be a Native controls in the NEXT Version of Pocket PowerBuilder (“Pumpkin”)

  45. WinCE Fun With External Function Calls… SOAP Client SOAP Client3rd Party SOAP Handler through an Adapter DLL

  46. WinCE Fun With External Function Calls… SOAP Client SOAP Client3rd Party SOAP Handler through an Adapter DLL SOAP Handler: www.pocketsoap.com Adapter DLL: CodeXchange http://pocketpb.codexchange.sybase.com/ Why ? A) No native SOAP support in Windows-CE or PocketPB B) Free “PocketSOAP” package is fully functional C) Adapter DLL needed because PocketSOAP has a COM interface.

  47. WinCE Fun With External Function Calls… SOAP Client - code (page 1/2) // Service Name: GlobalWeather string sEndPoint = "http://live.capescience.com:80/ccx/GlobalWeather" string sAction = "capeconnect:GlobalWeather:GlobalWeather#getWeatherReport" long lHandle // PocketSoap handle PocketSoap_Create( true, REF lHandle) PocketSoap_SetEndPoint( lHandle, sEndPoint ) PocketSoap_SetSoapAction( lHandle, sAction ) // Airports: BOS, JFK, LAX, LHR, SYD, TYO, CAI PocketSoap_Call( lHandle, "capeconnect:GlobalWeather:GlobalWeather”, // NameSpace, "getWeatherReport", // method "code~tBOS") // arglist (simple)

  48. WinCE Fun With External Function Calls… SOAP Client - code… (page 2/2) // preallocate the result string string sResult int cRetBufLen = 8000 sResult = Space( cRetBufLen ) PocketSoap_GetResults( lHandle, cRetBufLen, REF sResult ) mle_2.text = sResult iRet = PocketSoap_Destroy( lHandle )

  49. WinCE Fun With External Function Calls… SOAP Client References: • PWB-523 (Thursday 1:30) Pocket PowerBuilder & SOAP • www.pocketsoap.com • CodeXchange - PocketPowerBuilder and SOAP

  50. Pocket PowerBuilder and CodeXchange API Manipulation Examples http://pocketpb.codexchange.sybase.com/ Many Advanced Examples Available… • SOAP Client – Adapter DLL and all sources • Notification – Adapter DLL and all sources • Ink & Calendar Examples • Soft Reset and Turn Off the PDA • ZLIB for in-memory compression • Access RAPI • HTML Viewer • Hardware Keys • Battery Status • And more (light PFC just for Pocket PB!!!)

More Related