dcsimg
Results 1 to 4 of 4

Thread: VB6 Custom MsgBox form

  1. #1

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    VB6 Custom MsgBox form

    I wanted an easy to use, skinnable MsgBox with custom button captions and to have or not have a 'Don't ask me again' option.
    Here's what I came up with.

    This comes from the header of the form:
    Code:
     This form makes as many buttons as you need for the options you
     want to give to the user.
     It can also display and return the value of a "Don't ask me again" checkbox
    
     It has two functions that can be called
          frmMsgBox.Msg: works similar to a normal MsgBox, but it's easier to use
                         Only the Prompt is required
          frmMsgBox.MsgCstm: Allows you to select your own button captions
                             and add as many as you want.
                             A ParramArray is used for the button names
                             This prevents using Optional parameters :/
    
     Both functions return the index number of the button that was clicked (1 based)
          '0' always indicates that the user closed the box without hitting a button
     You can also access the user selected options through the form's two
          Global variables: frmMsgBox.g_lBtnClicked and frmMsgBox.g_bDontAsk
    
    ***********************************************************************************
     Example uses
          Converting a standard MsgBox to frmMsgBox.Msg:
              lOption = MsgBox("Test", vbYesNoCancel Or vbCritical Or vbDefaultButton2)
                  Use:
              lOption = frmMsgBox.Msg("Test", mbYesNoCancel, mbCritical, 2)
    
          Custom MsgBox use:
              frmMsgBox.MsgCstm "Want a cup of coffee?", "Coffee?", mbQuestion, 1, True, _
                                "Yes", "No", "Maybe", "Ask me later"
              Select Case frmMsgBox.g_lBtnClicked
                 Case 0 ' 0 always indicates that the user closed the box without hitting a button
                 Case 1 'the 1st button in your list was clicked
                 Case 2 'the 2nd button in your list was clicked
                 Case 3 'ect.
                 Case 4
              End Select
              bDontAsk = frmMsgBox.g_bDontAsk
    
    ***********************************************************************************
     Tips:
      a. This looks great when a Manifest File is used
      b. You can match the form to your skinned project by:
          1. Delete the command button "btnAction"
          2. Add your own custom button and name it "btnAction"
          3. Set it's index to 0 and adjust it's height
      c. You can copy frmMsgBox.frm and frmMsgBox.frx to the
         VB Templates folder to make it accessible from the
         'Project/Add Form' menu
          The template folder is usually located at:
          C:\Program Files\Microsoft Visual Studio\VB98\Template\Forms
    ***********************************************************************************
    A simple sample project is in the TestForm folder.

    I may add InputBox functionality to it later.

    Let me know if you find any bugs
    Attached Files Attached Files
    Last edited by longwolf; Oct 6th, 2008 at 09:41 PM. Reason: fixing the title

  2. #2
    Lively Member
    Join Date
    Aug 2008
    Location
    Between the keyboard and the chair.
    Posts
    122

    Re: Custom MsgBox form

    Sounds great! Ill give it a try and see what happens!
    If I have helped you out, be a pal and rate the helpful post!

    My CodeBank Submissions:
    Convert Color Values Between Long, RGB and Hex. Updated Sept 25th!
    Update Checker FrameWork

    My WIP Projects:
    Winsock Chat Server/Client Updated Oct 5th!

    Useful Tools:
    Aivosto.com MZ-Tools SysInternals Suite

  3. #3
    New Member
    Join Date
    Aug 2009
    Location
    Gloucester, UK
    Posts
    2

    Re: VB6 Custom MsgBox form

    This is just the kind of thing that I was looking for. Many thanks!

  4. #4
    New Member
    Join Date
    Feb 2017
    Posts
    8

    Re: VB6 Custom MsgBox form

    And still useful and works well in Windows 10 in 2017!
    Many thanks.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width