I've never needed this but a question here got me thinking it couldn't be that hard. Then I started searching the MSDN Library and found nothing I recognized as helpful. Then I searched the web and was shocked to find almost nothing at all.
Finally I found a forum post at another site that led to me Edanmo's old VB6 archives, and a breadcrumb of information there. That was great until I realized how little it covered... such as how to apply the results once you'd managed to raise the dialog in the first place!
As far as I can tell you're pretty much going to need UserControls to implement such features because I can't figure out how to get VB to let you "host" Property Page dialogs in a Form. But this is just a working sample to get you started, and there may be lots for you to discover once you begin fiddling with it.
Requirements
VB6 of course. This might also be converted to work in VB5 but I can't be sure since I haven't tried to.
Any 32- or 64-bit Windows versions that supports VB6 programs.
Microsoft Data Formatting Object Library 6.0 (SP6), i.e. msstdfmt.dll, which comes with VB6 (older service pack versions may possibly be compatible). This needs to be deployed since it isn't among the bits Microsoft ships as part of Windows these days.
What we have here
The demo package attached includes a UserControl that I have named "FmtTextBox" which is basically wrapping a MultiLine = False intrinsic TextBox, a clickable Image control "icon/button" of sorts, and a Variant. The idea is that instead of text, this control's value property (cleverly named "Value") can be any simple data type, and the visible/editable text is parsed-into/formatted-from this Variant Value.
So this makes a sort of non-bindable "TextBox" that handles formatting of many Variant subtypes... and lets the user change the format at run time.
There is also a helper Class that I have named "SettingsManager" designed to assist the program in persisting and restoring these settings between runs of the program.
Then there's the Standard EXE project with one Form that demonstrates the items above.
Running the Demo
Just unzip the attached archive and open the .VBP file in the VB6 IDE via Explorer. You can run it there or compile it first.
I have built "FmtTextBox" to hide its "edit the format button/icon" until the program toggles this on. In the demo a check/uncheck menu item controls this. Here's a peek:
![Name: sshot1.png
Views: 97
Size: 17.1 KB]()
The menu controlling the "edit formatting" button
![Name: sshot2.png
Views: 83
Size: 16.9 KB]()
User can click here to open the Property Page dialog
![Name: sshot3.png
Views: 79
Size: 22.0 KB]()
The Property Page dialog
Whew
This was a lot more than I bargained for when I started it. Partly because a UserControl was needed but more so because using a UserControl fronting a Variant added complexity, and mostly because there was a ton of "guess then cut-and-try work" involved in figuring out how to make use of the PPG dialog once I could get it to show up!
No claims this is bug-free. Consider it a technique demonstration. I'm not sure how practical it might be to do for other controls, but perhaps that isn't needed as much for most controls. As it is I've never needed any of this myself.
But it sure killed some time waiting for phone calls and such.
Finally I found a forum post at another site that led to me Edanmo's old VB6 archives, and a breadcrumb of information there. That was great until I realized how little it covered... such as how to apply the results once you'd managed to raise the dialog in the first place!
As far as I can tell you're pretty much going to need UserControls to implement such features because I can't figure out how to get VB to let you "host" Property Page dialogs in a Form. But this is just a working sample to get you started, and there may be lots for you to discover once you begin fiddling with it.
Requirements
VB6 of course. This might also be converted to work in VB5 but I can't be sure since I haven't tried to.
Any 32- or 64-bit Windows versions that supports VB6 programs.
Microsoft Data Formatting Object Library 6.0 (SP6), i.e. msstdfmt.dll, which comes with VB6 (older service pack versions may possibly be compatible). This needs to be deployed since it isn't among the bits Microsoft ships as part of Windows these days.
What we have here
The demo package attached includes a UserControl that I have named "FmtTextBox" which is basically wrapping a MultiLine = False intrinsic TextBox, a clickable Image control "icon/button" of sorts, and a Variant. The idea is that instead of text, this control's value property (cleverly named "Value") can be any simple data type, and the visible/editable text is parsed-into/formatted-from this Variant Value.
So this makes a sort of non-bindable "TextBox" that handles formatting of many Variant subtypes... and lets the user change the format at run time.
There is also a helper Class that I have named "SettingsManager" designed to assist the program in persisting and restoring these settings between runs of the program.
Then there's the Standard EXE project with one Form that demonstrates the items above.
Running the Demo
Just unzip the attached archive and open the .VBP file in the VB6 IDE via Explorer. You can run it there or compile it first.
I have built "FmtTextBox" to hide its "edit the format button/icon" until the program toggles this on. In the demo a check/uncheck menu item controls this. Here's a peek:
The menu controlling the "edit formatting" button
User can click here to open the Property Page dialog
The Property Page dialog
Whew
This was a lot more than I bargained for when I started it. Partly because a UserControl was needed but more so because using a UserControl fronting a Variant added complexity, and mostly because there was a ton of "guess then cut-and-try work" involved in figuring out how to make use of the PPG dialog once I could get it to show up!
No claims this is bug-free. Consider it a technique demonstration. I'm not sure how practical it might be to do for other controls, but perhaps that isn't needed as much for most controls. As it is I've never needed any of this myself.
But it sure killed some time waiting for phone calls and such.