Results 1 to 6 of 6

Thread: Not sure where to go with creation of custom dialog box.

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    45
    *scratches head*

    I'm trying to find a way to make a custom dialog box. I'm currently working on a large project made up of several .dlls and a multitude of forms. I would like a way to make a simple dialog box yet have it larger than the regular dialog boxes that appear and be able to customize the font.

    It is easy to imagine making a form that you could .Show on the screen and change it's title and message labels but I'm looking for something a little bit easier to use so that it can be dropped into any program.

    At first, I think to myself that I'll just create a form but then I get confused because I want an easy way to pass values to it as to affect its content, and I want it to be about as easy as using a regular message box.

    I want this:

    MyImprovedMsgBoxResult = (MyImprovedMsgBox( Title String, MsgString, ButtonStyle)

    In otherwords, I want the easy flexibility of the built in msgbox function but I want it to be my box that shows up by calling the new MyImprovedMsgBox Function.

    Would I just stick all of the code in a .bas file or what?

    I'd like to hear some strageties here. =)
    thanks.
    -Gregg
    -NoOBie At LaRg3

  2. #2
    Addicted Member
    Join Date
    Oct 2000
    Location
    Orlando, FL
    Posts
    253

    Talking

    I would create a DLL for this.

    EXE-->DLLMsgBox

    All you should need is one class and a form in the DLL.
    Create a Function in the class called ShowDialog or something like that with the Parameters such as this:
    Code:
    Public Function ShowDialog(Title As String, MsgType As Long, ..........) As Long
    With frmDialog
        .Caption = Title 'Caption
        .lblTitle = MsgType 'Label
        .
        'Bunch of other options and settings here
        .
        .Show 1 'Show the form
        ShowDialog = .Result 'Result of the button pressed
    End With
    End Function
    Something like that.

    Since it is a DLL, you can call it from any program.
    Hope that helps
    Always looking for a better and faster way!

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    very simple actually. In a bas module right your function

    Public Function MyBox(Title as string, Msg as string, Type as string) as string

    'Load your form
    Load frmMyBox

    'Setup stuff on it

    frmMyBox.Caption = Title
    frmMyBox.Label1.Caption = Msg

    'Do an if statment to check on type
    If type = "Yes/No" then
    frmMyBox.Comand1.Caption = "Yes"
    frmMyBox.Command2.Caption = "No"
    'Put elses her for other types.
    ...

    'Now show it
    frmMyBox.Show vbModal
    'Use vbModal so that the porgram pauses here until the box is closed

    'In the command button click events set a public variable to something to represent what was clicked and then have the box unloaded. Using Unload frmMyBox

    'Continuing the code in the function
    'Control now returns to it set the function value to what variable you set or the command button

    MyBox = the variable

    End Function

    'To call the function

    a = MyBox("Hey","Done?","Yes/No")

    if a = value of variable if command1 was clicked then
    'do something
    else
    'do solmething else
    end if
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4
    Addicted Member
    Join Date
    Oct 2000
    Location
    Orlando, FL
    Posts
    253
    The module works fine but you can only have 1 instance
    of it. Use a class to be able to use it in multiple projects.
    Always looking for a better and faster way!

  5. #5

  6. #6
    Member
    Join Date
    Jan 2001
    Location
    Dublin
    Posts
    35

    Thumbs up

    Why not create a DLL which is simply a class that has a number of properties, which set the text values on the form, and a method which launches the form and another to close it. I have done this for a progress dialog and have used the winapi to keep the dialog on top of everything else, this works really nice.

    I can help you with this if you need me to.

    Good Luck!

    Nialler

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