| Hyderabad Jobs | Book Website | ![]() |
I Love Hyderabad | Hyderabad Colleges |
| Home | Business Emails | Hyderabad Classifieds | Contact Us | |
| 7 Wonders of Hyderabad | Web Hosting | Yellow Pages | Our Network | |
Advanced PowerBuilder
Opening an Instance of a WindowTo open an instance of a window as a sheet, we use the OpenSheet() function and a local variable declaration. If we open more than one instance of a window, the data in each instance is independent of the other. We want to allow the user to open an instance of w_product_master whenever (s)he selects 'Product Master Maint.' option from the Module menu, so we have to write script for this menu item. Open m_mdi_menu from the menu painter, go to the script for 'Module > Product Master Maint.' If you look at events for a menu item, you'll see that there are two events: Clicked and Selected events. The Selected event occurs whenever a user scrolls through the menu options using the arrow keys or the mouse pointer. The Clicked event occurs when the user clicks on the option or presses the Enter key when the option is highlighted. This is the event for which we want to write code.
The first line declares l_sheet1 as a local variable based on w_product_master. The second line calls the OpenSheet() function with the following parameters: l_sheet1 is the name of the window which is to be opened. ParentWindow is the name of the MDI Frame in which the window is to be opened. When you code the script for a menu item, this parameter is always ParentWindow. You can hard code the MDI Frame window name into the script, but, by using ParentWindow, maintenance required is reduced in cases where name of the MDI frame window is changed. This also gives us a chance to attach the menu to any MDI Frame window. 4 is the menu option under which the list of opened sheets is to be displayed. The standard place to display opened windows is the Window menu option, the second option from the right. PowerBuilder allows you to specify this as the default when a zero is used. We know that, m_mdi_menu doesn't have a Window option. So, the open sheet's names would be displayed under the Module option for now. When we assign menus to other sheets, the problem would be rectified. The reason we didn't paint Window menu option for the m_mdi_menu menu is that, the options under the Window menu option doesn't apply unless at least a sheet is opened in the MDI frame window. When a sheet is opened, the menu attached to that sheet has the Window menu option and the opened window names listing will automatically move to Window menu option from Module menu option. Cascaded! argument indicates how the opened sheets are to be arranged in the frame. PowerBuilder supports three basic formats: Cascaded!, Layered! and Original!. We declared w_product_master as a local variable and then used this in the OpenSheet() function, as it allows us to open more than one instance of w_product_master window. If we had used the following code and then try to open another instance of the window it would only activate the sheet.
Try running the application to see how the menu option allows you to open multiple instances of w_product_master:
You can see from the Window menu that we have opened three instances of the same window and the sheets are displayed in a cascaded fashion. At this time, open w_product_master, and set the menu name to m_sheet_menu in the Window Properties sheet. Save it and close the window. Now, run the application. You will observe that PowerBuilder displays a new menu when you open an instance of w_product_master by selecting 'Module > Product Master Maint.' from the menu. Now try to open another instance of w_product_master from the new menu, you can't do that. That is because, you wrote the script for m_mdi_menu menu, and NOT for m_sheet_menu. So, copy the script from 'Module > Product Master Maint.' in m_mdi_menu to 'Module > Product Master Maint.' in m_sheet_menu. At this point, you can see all the CommandButtons painted in w_product_master. Even if you open ten instances of the same window, you can still see them in all windows. Don't you think that we can get rid of all the CommandButtons and push the functionality into the menu options. If you do it, user will be selecting the menu options, instead of clicking on CommandButtons. Let's learn more about this user interface.
|
| Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com |