1. Pete Yankovich
  2. PowerBuilder
  3. Friday, 9 October 2020 15:03 PM UTC

In PB 2017 R2, can a Main! window be modal, ie, focus can not go to another window or menu when open.

Brad Wery Accepted Answer Pending Moderation
  1. Friday, 9 October 2020 15:49 PM UTC
  2. PowerBuilder
  3. # 1

Ultimate Suite allows you to open windows as Modal windows.

https://www.pbultimatesuite.com/EN/modernize-pb-interface/powermodal.html

 

Comment
  1. Pete Yankovich
  2. Monday, 12 October 2020 12:12 PM UTC
Can you give any more details about Ultimate Suite, ie, is it another PBL in the app, are there instructions on how to integrate with the app? Are there any drawbacks? Has it been successfully used in other apps?
  1. Helpful
  1. Brad Wery
  2. Tuesday, 13 October 2020 14:05 PM UTC
It's a 3rd party produce made up of a few PBL's (or PBD's depending on the edition you get). The help file contains all the information you would need to implement. The Modal window object is pretty easy. To use "Globally", you would just do something like this:



//Global Variable

n_cst_powermodal PowerModal



//When you want to open a window

w_mywindow lw_window

PowerModal.OpenModal(lw_window)



If you want to close the modal window with a return value you would do this:

PowerModal.CloseModal("My return value") //or one of the other overloads



I'm not aware of any drawbacks... yet. I've used it successfully in a few applications (NotepadPB for example). I'm not sure how may people are using PowerModal.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 9 October 2020 19:33 PM UTC
  2. PowerBuilder
  3. # 2

Hi Pete;

   No, Main windows can never be modal. However, you can easily "fake it out" by placing code in the Windows "deactivate" event that then immediately returns focus back to the main window. Thus to the App user, the Main window "seems" modal.  ;-)

HTH

Regards ... Chris

Comment
  1. Pete Yankovich
  2. Monday, 12 October 2020 15:30 PM UTC
Thanks Chris, these things work to a point, but what I'm trying to achieve is to prevent the user from opening other windows when a particular window is open. My code so far:



MessageBox(this.title,"Opening other screens may cause unpredictable results in " + this.title, StopSign!, OK!)

post SetFocus(this)



Two issues:

- the deactivate event also fires when I close the particular window.

- another window will open if user clicks on it's menu item. How to close that window?
  1. Helpful
  1. Pete Yankovich
  2. Tuesday, 13 October 2020 12:34 PM UTC
Here is my code in window deactivate event. I'm using the boolean to control when the deactivate event does anything. The GetActiveSheet returns null reference error. It should be returning the active window. or null, if none. Any help with this issue?



window activesheet



If not ib_deactivate then

ib_deactivate = true

return 1

End if



MessageBox(this.title,"Opening other screens may cause unpredictable results in " + this.title, StopSign!, OK!)



activesheet = w_frame.GetActiveSheet()

IF IsValid(activesheet) THEN

close(activesheet)

END IF



post SetFocus(this)

  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 15 October 2020 02:47 AM UTC
  2. PowerBuilder
  3. # 3

Greetings, Pete -

I'm not saying this is an ideal solution or easy to implement...but can you (1) enforce restrictions on the "modal" window so that it opens only when no other windows are already open, and (2) disable all menu items and other means of opening other windows when the "modal" window is open?

Regards, John

Comment
  1. Pete Yankovich
  2. Thursday, 15 October 2020 12:10 PM UTC
I did the latter of your suggestions to an extent. There is only one menu item that should not be available when the modal window is open, so I disable it when the modal window is opened.



Also, in reference to another post, I was calling GetActiveSheet in the deactivate event. It was throwing a null reference error. Why would that be? I was calling it for the MDI window, w_frame.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.