|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Fri Dec 28, 2007 10:48 pm
com calls for common dialog boxes |
I'm trying to use microsoft's common dialog classes to get a open/save file dialog box, so i can export/import information into a database. I've searched msdn, and over the internet for a simple method of using one via com calls. So far i've come up with 2 possiblities.
First is using the getOpenFileName function, but this requires passing in a openFileName structure, with some 20 varibles in it. I'ld try this but don't really think that any of cmud's varibles would equate to a structure.
Second method is to use an showopen method that i've found as part of the common dialog control.
I have been able to link to the "useraccounts.commondialog" (only present in xp, not server 2003 or vista) com object, but everything past that has come up null or given an error.
Any help or suggestions to get this working, or another easy method that works on all 3 operating systems would be greatly appreciated. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sat Dec 29, 2007 4:46 pm |
Have a look at Vijilante toolbox in the package library I think he has some sort of hook set up to access an access database in that. As for the dialog box once you have hooked CMud to the database via com why not use the boxes that Cmud has built in?
As for objects I THINK that the Array variable type is what you are supposed to use for connecting to things via com...
Edit:
I went back and had another look at Vijilante's toolbox myself and I was right he does have everything you need to connect to an access database in the MappingWidgets class.
Of special interest to you would be the OpenMapDatabaseForQuery, SpecialMapQuery, aliases and the onExit event.
If you wanted to use a different type of database you could change the provider string in the OpenMapDatabaseForQuery alias.
Vijilante wrote: |
#CALL @MapCon.Open(%concat("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=",%pref(MapFile))) |
To use a different file you would change the last part of the above quote.
#CALL @MapCon.Open(%concat("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\path\mydatabase.mdb"))
Have fun... |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Fri Jan 04, 2008 2:30 pm |
Slim version using Local Vars and win XP only controls
$Dialog=%comcreate("useraccounts.commondialog")
#IF ($Dialog.ShowOpen) {$strFile=$Dialog.FileName} {#ECHO No File Selected. complete this code block} |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sun Jan 06, 2008 12:31 pm |
Actually that might work on Vista and Win 2003 but nothing Win 2000 or before. Could someone with Vista try my code and let me know if it works?
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Sun Jan 06, 2008 4:50 pm |
I'm using XP SP2 and it almost works...I just changed #IF ($Dialog.OpenFile) to #IF ($Dialog.ShowOpen)
$Dialog.OpenFile threw an error and then locked up CMUD. |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sun Jan 06, 2008 7:23 pm |
Oops typo on my part, post aboved edited with fix.
|
|
|
|
|
|