[Gambas-user] Turn off window modality while its showing?

Bruce Steers bsteers4 at gmail.com
Mon Jan 15 13:46:25 CET 2024


On Mon, 15 Jan 2024 at 08:00, BB <adamnt42 at gmail.com> wrote:

> I have a lot of image files that I show in a modal popup form. Now I
> want to stop an instance of the form being modal, so I can select
> another image and pop it up as well (so I can compare them). Any ideas?
>
> b
>

maybe a pseudo modal window will do it?

This ShowModal override should open in Utility mode and work like a modal
form but setting $bPseudo to false while it's open will break it out of
utility mode.

Private $bPseudo As Boolean  ' Modal switch
Private $hWin As Window  ' parent form to disable
Private $iValue As Integer  ' the standard Modal return value holder.

Public Sub UnModal()

  $bPseudo = False

End


Public Sub ShowModal() As Integer

  $hWin = Application.ActiveWindow  ' probably better to explicitly use the
parent form object here.

  Dim bEnabled As Boolean = $hWin.Enabled  ' note parent window enabled
state before making it false
  $hWin.Enabled = False
  $bPseudo = True
  Me.Utility = True
  Super.Show()
  While Object.IsValid(Me) And $bPseudo  ' wait for window close or unmodal
request, letting event loop run.
    Wait 0.1
  Wend

  If Object.IsValid(Me) Then Me.Utility = $bPseudo

  If Object.IsValid($hWin) Then
    $hWin.Enabled = bEnabled
  Endif

  Return $iValue

End

Public Sub Button2_Click()

  $bPseudo = False

End

Something along those lines maybe?

Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20240115/8b7bc157/attachment.htm>


More information about the User mailing list