Schultz’s PowerBuilder Notes

Getting a Reference to a Submenu


Getting a reference to the window’s menu is easily accomplished using the window’s MenuId property.  But what if you want to get a reference to a submenu and all you have is a string with the menu’s name?  This following function will do the trick: Continue reading

August 1, 2009 Posted by | 1. PowerBuilder General, Menus, Powerscript | , , | 1 Comment

Opening up a Window from a Menu Item


1) Create the following user event in your application’s frame window

Continue reading

May 6, 2008 Posted by | Menus, Powerscript, Window Controls | , , , , , , , , , , | Leave a comment

Using a Menu on a Response window to give you Key Short Keys


Aron wanted a datawindow to be able have all the standard windows shortcut key “<cntl> A” for “Select All”. He was using the PFC multi row select, so he was able to give the standard <Cntl> and <Shift> extended selection.

His solution was to use a hidden menu where the Select All menu item is triggered by the shortcut key “<Cntl> A”. This problem was complicated by the fact that the window was a Response window, and needed to have the menu assignment done dynamically. Here is the code he put in the PreOpen Event.

menu lm

// m_response_edit is menu inherited from m_frame

int i

// In order to make keyboard shortcuts available, create a hidden menu
If Not IsValid(This.menuId) Then
   // Instantiate the menu
   This.ChangeMenu(m_response_edit)
   lm = This.menuId

   // Hide the menu and it's first level items
   lm.visible = False
   For i = 1 To UpperBound(lm.item)
      lm.item[i].visible = False
   Next
End if

May 6, 2008 Posted by | Menus | , , , , , | 1 Comment

Adding “Export to Excel” Menu item


Add a menu item under FUNCTIONS which exports a datawindow to excel. This example assumes PFC is being used.

M_frame

Add the item Functions > Export to Excel

Script

of_SendMessage(‘ue_export’)

Properties:

Enabled = FALSE

w_sheet_lm

Your main sheet ancestor

  • Instance Variables

Protected:

u_dw idw_export

  • ue_export

//////////////////////////////////////////////////////////////////////////////
// Event: w_sheet_lm:ue_export
//
// Description: export the registered datawindow (idw_export) to excel
//
//////////////////////////////////////////////////////////////////////////////

if IsValid(idw_export) then
. idw_export.SaveAs(“”, Excel5!, TRUE)
end if

How to use

  1. In the Activate Event of the sheet, enable the menu item EXPORT
  2. In the Deactivate Event of the sheet, disable the menu item EXPORT
  3. In the window pfc_preopen event, associate the datawindow you wish to export to idw_export
  4. If you want to do something trickier, for example, you want to allow the user to select one of several different datawindows to export, override the sheet’s UE_EXPORT event.

April 15, 2008 Posted by | Menus | , , | Leave a comment

Pop Up Menus


Launching a Pop Up Menu

menuname.PopMenu ( xlocation, ylocation )

Continue reading

April 9, 2008 Posted by | Menus | , , | Leave a comment

Tool Bar Properties


How do I get PFC help to appear on the menu bar

  • Right click the menu bar
  • Select “Customize … “ from the popup menu
  • Select the “Custom” radio button
  • Drag an icon from the array of icons available and position it on the toolbar
  • The command line should read
winhlp32.exe C:\PWRS6\PB6\Help\pbpfc60.hlp
winhlp32.exe C:\Program Files\Sybase\PowerBuilder 7.0\Help\pbpfc70.hlp
  • Enter toolbar text and a tooltip Miscellaneous PowerBuilder Stuff

How do I get and set the toolbar properties?

boolean          lb_visible
integer          li_toolbarindex
string           ls_title
ToolbarAlignment ltb_alignment

this.GetToolbar(li_toolbarindex, lb_visible, ltb_alignment, ls_title)

Where else can I set toolbar properties

Several toolbar properties are set in the application object

iapp_object.ToolbarSheetTitle = “Sheet toolbar”
iapp_object.ToolbarFrameTitle = “Frame toolbar”

How do I hide a toolbar?

this.ToolBarVisible = False

Continue reading

April 9, 2008 Posted by | Menus | , , , | 1 Comment