Schultz’s PowerBuilder Notes

Opening up a Window from a Menu Item

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

//////////////////////////////////////////////////////////////////////////////
// Event: ue_opensheet
//
//   Description: Checks if the requested sheet is open.  If it is, the sheet
//                is brought to the top.  If it isn't, a new sheet is opened.
//
//   Arguments: None.
//   Returns: None.
//
//////////////////////////////////////////////////////////////////////////////
//   Revision History
//
// Date      By   Description/Comments
// --------  ---  ----------------------------------------------
// 09/21/99       Initial Version
// 10/02/01  fjs  Spun off much logic to wf_IsSheetOpen()
//
//////////////////////////////////////////////////////////////////////////////

string   ls_requested_sheet_name
w_sheet  lw_newsheet

// New sheet name
ls_requested_sheet_name = Upper(Message.StringParm)

if NOT wf_IsSheetOpen(ls_requested_sheet_name) then
// Search didn't find an open occurrence.  Open a new sheet.
   OpenSheet(lw_newsheet, ls_requested_sheet_name, this, 0, Layered!)
end if

2) Calling script in menu


message.stringparm = 'w_acct_mach_oper'
of_SendMessage("ue_opensheet" )

Opening a Sheet with Parm from a menu

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

//////////////////////////////////////////////////////////////////////////////
// Event: ue_opensheetwithparm
//
//   Description: Checks if the requested sheet is open.  If it is, the sheet
//                is brought to the top.  If it isn't, a new sheet is opened.
//
//   Arguments: None.
//   Returns: None.
//
//////////////////////////////////////////////////////////////////////////////
//   Revision History
//
// Date      By   Description/Comments
// --------  ---  ----------------------------------------------
// 10/02/01  fjs  Initial Version.
//
//////////////////////////////////////////////////////////////////////////////

double                ld_parm
powerobject           lpo_parm
str_opensheetwithparm lstr_parms
string                ls_requested_sheet_name, ls_parm_type, ls_parm
w_sheet               lw_newsheet

lstr_parms = Message.PowerObjectParm

if NOT wf_IsSheetOpen(ls_requested_sheet_name) then
   // Search didn't find an open occurrence.  Open a new sheet.

   ls_requested_sheet_name = Upper(lstr_parms.s_sheet_name)
   ls_parm_type = Lower(lstr_parms.s_parm_type)
   choose case ls_parm_type
       case "stringparm"
          ls_parm = lstr_parms.a_parm_value
          OpenSheetWithParm(lw_newsheet, ls_parm, ls_requested_sheet_name, this, 0, Layered!)
       case "powerobjectparm"
          lpo_parm = lstr_parms.a_parm_value
          OpenSheetWithParm(lw_newsheet, lpo_parm, ls_requested_sheet_name, this, 0, Layered!)
       case "doubleparm"
          ld_parm = lstr_parms.a_parm_value
          OpenSheetWithParm(lw_newsheet, ld_parm, ls_requested_sheet_name, this, 0, Layered!)
       case else
          if IsNull(ls_parm_type) then
             ls_parm_type = "null"
         end if
         MessageBox("Error - w_lm_frame:ue_OpenSheetWithParm", 'Unknown parm type: "' + ls_parm_type + '"' )
         Return
    end choose
end if

2) Calling script in menu

The following will open the window "w_finishingtimesheet" and pass it the parameter "Menu"

// Set the structure variables
istr_opensheetwithparm.s_parm_type = 'stringparm'
istr_opensheetwithparm.s_sheet_name = 'w_finishingtimesheets'
istr_opensheetwithparm.a_parm_value = 'Menu'
Message.PowerObjectParm = istr_opensheetwithparm
of_SendMessage("ue_opensheetwithparm" )

May 6, 2008 - Posted by rick130 | Menus, Powerscript, Window Controls | , , , , , , , , , , | No Comments Yet

No comments yet.

Leave a comment