In PB 2017 R2, can a Main! window be modal, ie, focus can not go to another window or menu when open.
- You are here:
- Home
- Q&A
- Q&A
- PowerBuilder
- Main! Modal Window
Resolved
Main! Modal Window
- How-to
- Pete Yankovich
- PowerBuilder
- Friday, 9 October 2020 15:03 PM UTC
- Friday, 9 October 2020 15:49 PM UTC
- PowerBuilder
- # 1
Ultimate Suite allows you to open windows as Modal windows.
https://www.pbultimatesuite.com/EN/modernize-pb-interface/powermodal.html
- Friday, 9 October 2020 19:33 PM UTC
- PowerBuilder
- # 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
- Pete Yankovich
- 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?
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?
-
Helpful Loading... Helpful 0
- Pete Yankovich
- 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)
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)
-
Helpful Loading... Helpful 0
There are no comments made yet.
- Thursday, 15 October 2020 02:47 AM UTC
- PowerBuilder
- # 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
- Pete Yankovich
- 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.
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.
-
Helpful Loading... Helpful 0
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.
However, you are not allowed to reply to this question.
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here. Register Here »
//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.