Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Form that is showing dialog box is disabled - looses behavior of when showing dialogbox

Form that is showing dialog box is disabled - looses behavior of when showing dialogbox

Scheduled Pinned Locked Moved Visual Basic
workspacebusinessperformancehelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nlarson11
    wrote on last edited by
    #1

    Hello, Here is the situtation: 1 exe (acting like main menu) that launches 1-N dlls where each dll is seperate application. The exe and dlls all are sharing the same memory for the environment. We have a business requirement that if one of the applications is showing a dialog box, it cannot lock up the other running applications-ugly work around but we have accomplished this. Because N number of windows can be running at once there is a feature called, clever enough, "Show Open Windows" which when shows disables all the running forms so that the user must get rid of showopen windows before they can do anything else. While this action was not a problem, if any of those forms where showing dialogboxes then the dialog boxes were still enabled allowing the user to interact with them. I created an extension to the form to use a custom ShowDialog routine that setup an event that if the calling form's enabled problem changed then change the enabled property within the dialog box works fine. The problem is if the parent form(one that showed the dialog) is disabled by the "show open windows" call, when it is reenabled by the showopenwindows going away, the dialog remains on top of the calling form but you can interact with the calling form - changing it's context etc. This is easily repeatable including if you use a msgbox. Is there any value/flag that I can test for and reset to get the form back into the state where you can't interact with it until it's dialogbox goes away? Example of the code to make this behavior happen: 'note #1: the first timer was used to check the enabled property for it's state 'note #2: the second timer disables the form 5 seconds after you click on the button to show the messagebox. 5 seconds after that the form will reenable allowing you to interact with it even though the message box is still showing.

    Public Class Form1
    Private _timer As Timer
    Private _timerdisable As Timer

    Private Sub Form1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        \_timer = New Timer(500)
        \_timer.AutoReset = True
        AddHandler \_timer.Elapsed, AddressOf Timer\_Elapsed
        \_timer.Enabled = True
    
        \_timerdisable = New Timer(5000)
        \_timerdisable.AutoReset = True
        AddHandler \_timerdisable.Elapsed, AddressOf TimerDisable\_Elapsed
    End Sub
    
    Private Sub Timer\_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
        If Me.InvokeRequired Then
            Me
    
    L N 2 Replies Last reply
    0
    • N nlarson11

      Hello, Here is the situtation: 1 exe (acting like main menu) that launches 1-N dlls where each dll is seperate application. The exe and dlls all are sharing the same memory for the environment. We have a business requirement that if one of the applications is showing a dialog box, it cannot lock up the other running applications-ugly work around but we have accomplished this. Because N number of windows can be running at once there is a feature called, clever enough, "Show Open Windows" which when shows disables all the running forms so that the user must get rid of showopen windows before they can do anything else. While this action was not a problem, if any of those forms where showing dialogboxes then the dialog boxes were still enabled allowing the user to interact with them. I created an extension to the form to use a custom ShowDialog routine that setup an event that if the calling form's enabled problem changed then change the enabled property within the dialog box works fine. The problem is if the parent form(one that showed the dialog) is disabled by the "show open windows" call, when it is reenabled by the showopenwindows going away, the dialog remains on top of the calling form but you can interact with the calling form - changing it's context etc. This is easily repeatable including if you use a msgbox. Is there any value/flag that I can test for and reset to get the form back into the state where you can't interact with it until it's dialogbox goes away? Example of the code to make this behavior happen: 'note #1: the first timer was used to check the enabled property for it's state 'note #2: the second timer disables the form 5 seconds after you click on the button to show the messagebox. 5 seconds after that the form will reenable allowing you to interact with it even though the message box is still showing.

      Public Class Form1
      Private _timer As Timer
      Private _timerdisable As Timer

      Private Sub Form1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          \_timer = New Timer(500)
          \_timer.AutoReset = True
          AddHandler \_timer.Elapsed, AddressOf Timer\_Elapsed
          \_timer.Enabled = True
      
          \_timerdisable = New Timer(5000)
          \_timerdisable.AutoReset = True
          AddHandler \_timerdisable.Elapsed, AddressOf TimerDisable\_Elapsed
      End Sub
      
      Private Sub Timer\_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
          If Me.InvokeRequired Then
              Me
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You could also try to create non-blocking variants of the dialogs; Show a window, set a boolean to indicate that it's showing something. When the flag gets set, attach a delegate to one of the events that fire when the form closes to reset the bool.

      I are Troll :)

      N 1 Reply Last reply
      0
      • L Lost User

        You could also try to create non-blocking variants of the dialogs; Show a window, set a boolean to indicate that it's showing something. When the flag gets set, attach a delegate to one of the events that fire when the form closes to reset the bool.

        I are Troll :)

        N Offline
        N Offline
        nlarson11
        wrote on last edited by
        #3

        Thank you for replying... "non-blocking variants of the dialogs;" - not doable... too much code would need to change to mimic the dialog behavior with the calling form.

        'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

        1 Reply Last reply
        0
        • N nlarson11

          Hello, Here is the situtation: 1 exe (acting like main menu) that launches 1-N dlls where each dll is seperate application. The exe and dlls all are sharing the same memory for the environment. We have a business requirement that if one of the applications is showing a dialog box, it cannot lock up the other running applications-ugly work around but we have accomplished this. Because N number of windows can be running at once there is a feature called, clever enough, "Show Open Windows" which when shows disables all the running forms so that the user must get rid of showopen windows before they can do anything else. While this action was not a problem, if any of those forms where showing dialogboxes then the dialog boxes were still enabled allowing the user to interact with them. I created an extension to the form to use a custom ShowDialog routine that setup an event that if the calling form's enabled problem changed then change the enabled property within the dialog box works fine. The problem is if the parent form(one that showed the dialog) is disabled by the "show open windows" call, when it is reenabled by the showopenwindows going away, the dialog remains on top of the calling form but you can interact with the calling form - changing it's context etc. This is easily repeatable including if you use a msgbox. Is there any value/flag that I can test for and reset to get the form back into the state where you can't interact with it until it's dialogbox goes away? Example of the code to make this behavior happen: 'note #1: the first timer was used to check the enabled property for it's state 'note #2: the second timer disables the form 5 seconds after you click on the button to show the messagebox. 5 seconds after that the form will reenable allowing you to interact with it even though the message box is still showing.

          Public Class Form1
          Private _timer As Timer
          Private _timerdisable As Timer

          Private Sub Form1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
              \_timer = New Timer(500)
              \_timer.AutoReset = True
              AddHandler \_timer.Elapsed, AddressOf Timer\_Elapsed
              \_timer.Enabled = True
          
              \_timerdisable = New Timer(5000)
              \_timerdisable.AutoReset = True
              AddHandler \_timerdisable.Elapsed, AddressOf TimerDisable\_Elapsed
          End Sub
          
          Private Sub Timer\_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
              If Me.InvokeRequired Then
                  Me
          
          N Offline
          N Offline
          nlarson11
          wrote on last edited by
          #4

          Turns out, the value/flag in question is the property 'CanFocus'. This property is of course 'readonly'. Does anyone know how to override this value behind the scenes(api call or whatever)? thank you Nathan

          'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups