Modeless dialog which halts program execution....
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Modeless dialog which halts program execution....

  1. #1
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    171

    Modeless dialog which halts program execution....

    I need to make a modeless dialog which halts the program, just like a modal dialog does. It's basically like a debugging dialog which will display messages. I want to keep it up, so that there is a history, but after every message I want to wait for them to hit a button, say a "Continue" button or something like that.

    Anyone have any ideas on how I should go about this. I'm not looking for you to code it for me, just some suggestions and maybe a pointer or two.

  2. #2
    Join Date
    Aug 2003
    Location
    London
    Posts
    515
    Some sort of loop that checks a return code & only continues when something = True? Not the most elegant, but pretty simple...!

    Create a new form, put 2 objects on it, txtError (text box) and cmdContinue (command button), paste the following code into the forms module...

    edit: this doesn't make it 'modal', user could still click elsewhere....you could maybe limit mouse movement to the form being displayed....?

    Code:
    Option Explicit
    
    Private m_bOKClicked As Boolean
    
    Private Sub Form_Load()
    
    '// Reset flag
        m_bOKClicked = False
    
        Call LoadMessage
    
    End Sub
    
    Private Sub cmdContinue_Click()
        m_bOKClicked = True
    End Sub
    
    Private Sub LoadMessage()
    
    '// Get your message to display here....
        Me.txtError = "Blah Blah Blah Happened..."
        
    '// Show form before enter loop...
        Me.Visible = True
    
        Do Until m_bOKClicked
            DoEvents
        Loop
        
        MsgBox "Error Was processed, form can now unload!"
    
    End Sub
    Last edited by Dmorley; July 12th, 2004 at 11:07 AM.

  3. #3
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    171
    Or I guess another way to think of it is to have a Modal dialog which can start the program execution again when a button is clicked, but doesn't hide or unload my dialog

  4. #4
    Join Date
    May 2002
    Location
    Vancouver, BC
    Posts
    171
    I tried your code, or a variation on it. The problemis that DoEvents causes the CPU to hit 100%. Is there another, slightly better approach to this???

  5. #5
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,451
    Add a Sleep API call before or after the doevents statement.

    The doEvents Statement will allow you program to receive messages, however, since you are in a tight loop, the processor will be pegged.

    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    Do
    Sleep 100
    DoEvents
    Loop

    That should do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center