Results 1 to 13 of 13

Thread: [RESOLVED] Custom button msgbox??

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Resolved [RESOLVED] Custom button msgbox??

    I need to make a msgbox that asks if the user would like to create a new document or add to an old one. i could make it a yes no msgbox and ask if they wish to append. Then if they click no it will create a new one.

    But i would prefer not to do it that way i would rather have a msgbox that asks the user this question then one button that says "Append to old" and another that says "Create new".

    Is there anyway of doing this or will i have to use my previous (and crap!!) method...

    cheers

    GTJ

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Custom button msgbox??

    I don't know what your previous option was, but in order to get a "messagebox" to ask the questions that you want asked, you will have to build your own using a standard VB form.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Custom button msgbox??

    Or rather, to offer the answers you want offered

    Once you've made it a form, you can wrap it in a function and show it Modally from within there, so it is just like VB's MessageBox() function.

    VB Code:
    1. ' In a MessageBox module
    2. Enum CustomMessageBoxResult
    3.     mbAppend
    4.     mbCreate
    5. End Enum
    6.  
    7. Function CustomMessageBox(ByRef pszText As String, ByRef pszTitle As String) As CustomMessageBoxResult
    8. Dim objMB As FMessageBox
    9.     Set objMB = New FMessageBox
    10.     With objMB
    11.         .lblText.Caption = pszText
    12.         .Caption = pszTitle
    13.         .Show vbModal
    14.         CustomMessageBox = .Result
    15.     End With
    16.     Set objMB = Nothing
    17. End Function

    and in your FMessageBox form you will need a Result property
    VB Code:
    1. Private mResult As CustomMessageBoxResult
    2.  
    3. ' set the above variable and hide the form when the user clicks a button
    4.  
    5. Friend Property Get Result() As CustomMessageBoxResult
    6.     Result = mResult
    7. End Property

    Argh, how hard does it have to be to type "CustomMessageBox"

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Custom button msgbox??

    Of what type is FMessageBox?

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Custom button msgbox??

    my guess its the new form ?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Custom button msgbox??

    Quote Originally Posted by me
    your FMessageBox form
    Indeed

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Custom button msgbox??

    Quote Originally Posted by [A51g]Static
    my guess its the new form ?
    Yeah, mine too, but someone else reading this post might not make that connection.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Custom button msgbox??

    how do i grey out the 'x' in the top right hand corner??? vb msgboxes have the 'x' greyed out...

  9. #9
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Custom button msgbox??

    Also have a look here:
    Is it possible to subclass the MsgBox?

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Custom button msgbox??

    disregard my last question about greying out, i just removed it... easier!

    another question: where might i get the sound that the msgbox makes if it is a vbinformation msgbox?? (the two notes)

    is it in c:\windows... or summin??

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Custom button msgbox??

    i have found the sound in c:\windows\media how would i get it to play when the form loads??

  12. #12
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Custom button msgbox??

    i think its the PlaySound API?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Custom button msgbox??

    A related question was asked earlier today. You can find it here.

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