|
-
Feb 7th, 2001, 12:34 PM
#1
Thread Starter
Member
*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.
-
Feb 7th, 2001, 01:00 PM
#2
Addicted Member
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!
-
Feb 7th, 2001, 01:02 PM
#3
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
-
Feb 7th, 2001, 01:05 PM
#4
Addicted Member
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!
-
Feb 7th, 2001, 01:22 PM
#5
Don't forget that you can add your own properties to a form, so you could have properties such as MyMsgBox.Font or MyMsgBox.Display (where you set the modality), etc.
-
Feb 7th, 2001, 01:28 PM
#6
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|