Results 1 to 12 of 12

Thread: MsgBox crisis

  1. #1
    Guest

    Exclamation

    Hallo

    I have a small problem with the MsgBox function of VB. My program receives input from an electronic eye. If the user enters invalid values in the textbox, a msgbox with error message pops-up. As soon as this happens, the program stops because the message box is by default modal.

    Is there anyway to remove the modal mode so that the rest of the program can keep on running? I need help desperately?

    Thanx


  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    I'm actually looking for the same thing myself.
    Have a look at these posts
    http://forums.vb-world.net/showthrea...threadid=23960
    http://forums.vb-world.net/showthrea...threadid=26488

  3. #3
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    The only way you can get round this is to create your own MsgBox using a form. You can then use this to show up and let your program to continue processing code by using MsgBoxForm.Show vbModeless (or whatever you call the form!).

    Hope this helps

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  4. #4
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Guys, from MSDN:

    -BEGIN-
    Modeless dialog boxes let you shift the focus between the dialog box and another form without having to close the dialog box. You can continue to work elsewhere in the current application while the dialog box is displayed. Modeless dialog boxes are rare; you will usually display a dialog because a response is needed before the application can continue. From the Edit menu, the Find dialog box in Visual Basic is an example of a modeless dialog box. Use modeless dialog boxes to display frequently used commands or information.
    -END-

    I'm pretty sure that its impossible to make the standard MsgBox non-modal. If you want to do that you'll have to make a dialog box from scratch. I have to code to make them (MsgBox's) disappear automatically though. so if you want it, mail me & i'll send you the project.
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  5. #5
    Addicted Member jeroenh's Avatar
    Join Date
    Aug 2000
    Location
    Rotterdam, Holland
    Posts
    201

    Thumbs up

    Why don't you make your own msgbox. Just take an empty form and put a label on it. Then call the form true a function witch sets the tekst of the label and the title and thats it.

    You can also use an API call to get a msgbox. I don't know what is possible with this call but you can find it at http://www.vbapi.com.

    Good luck.
    Catch you later,

    Jeroen Hoekemeijer
    Code:
    If 1 = 2 Then MajorError

  6. #6
    Guest

    Unhappy

    I was hoping to get around the idea of doing it from scratch. The problem is that we have a central function that calls the msgbox for different events. There are hundreds of possibilities why the msgbox was activated.

    Thanx all

  7. #7
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    Use the MessageBox API

    Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long


    it doesn't block and is the same as Msgbox


    Why don't one of u guys go take a look at my post :
    Strange Table lock behavior

    Thanks

  8. #8
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754

    Post

    Message-Box Modality CWnd::MessageBox

    MB_APPLMODAL The user must respond to the message box before continuing work in the current window. However, the user can move to the windows of other applications and work in those windows. The default is MB_APPLMODAL if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.


    MB_SYSTEMMODAL All applications are suspended until the user responds to the message box. System-modal message boxes are used to notify the user of serious, potentially damaging errors that require immediate attention and should be used sparingly.


    MB_TASKMODAL Similar to MB_APPLMODAL, but not useful within a Microsoft Foundation class application. This flag is reserved for a calling application or library that does not have a window handle available.

    Applies to the MessageBox API and MessageBoxEx API functions
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  9. #9
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    Sorry but what I meant is that Events are still triggered...
    for sure the code stops tracing. If your input code is in a timer or a Mscomm or winsock Event, you should continu receiving and decoding your inputs...

  10. #10
    Guest
    Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long


    I would like to know if you can use this meesagebox when the respond is for example vbYesNo. For some reason it only shows OK even if you specified something else. Am I using it incorrectly?

  11. #11
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    herman,

    If you use the API messagebox you will need to use these constants for it instead of the standard VB ones i.e. VbYesNo.

    Public Const MB_ABORTRETRYIGNORE = &H2&
    Public Const MB_DEFBUTTON1 = &H0&
    Public Const MB_DEFBUTTON2 = &H100&
    Public Const MB_DEFBUTTON3 = &H200&
    Public Const MB_DEFMASK = &HF00&
    Public Const MB_ICONASTERISK = &H40&
    Public Const MB_ICONEXCLAMATION = &H30&
    Public Const MB_ICONHAND = &H10&
    Public Const MB_ICONINFORMATION = MB_ICONASTERISK
    Public Const MB_ICONMASK = &HF0&
    Public Const MB_ICONQUESTION = &H20&
    Public Const MB_ICONSTOP = MB_ICONHAND
    Public Const MB_OK = &H0&
    Public Const MB_OKCANCEL = &H1&
    Public Const MB_RETRYCANCEL = &H5&
    Public Const MB_SETFOREGROUND = &H10000
    Public Const MB_SYSTEMMODAL = &H1000&
    Public Const MB_TASKMODAL = &H2000&
    Public Const MB_YESNO = &H4&
    Public Const MB_YESNOCANCEL = &H3&

    hope this helps
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  12. #12
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    http://www.netfokus.dk/vbadmincode/code/msgbox.zip

    This project is a replacement for the standard VB messagebox function. It allows the programmer to assign, re-assign the owner/parent of the messagebox, thus allowing code processing to continue even though message boxes are on screen. It also accepts parameters to position the messagebox anywhere on the screen. Excellent solution for event driven code, allowing
    events to be raised when message boxes have the focus.
    Author: John Timney
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

Posting Permissions

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



Click Here to Expand Forum to Full Width