Author Topic: OpenFileDialog  (Read 15693 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
OpenFileDialog
« on: January 28, 2007, 09:12:18 AM »
To continue a thread here that I started in the net forum, here  I am looking for a was in visual lisp to evoke the windows dialog box below with the ability to select multiple files.
I am not sure of the method needed or how to set it up.
But if you can do this to browse for folders, why can't you Browse for files?
Code: [Select]
(setq shell (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
(setq folder
(vlax-invoke-method
shell
'BrowseForFolder
0
message
512
path
)
)
<edit: spelling>
« Last Edit: January 29, 2007, 09:10:48 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Patrick_35

  • Guest
Re: OpenFileDialog
« Reply #1 on: January 28, 2007, 03:04:32 PM »
Hi
Try this
Code: [Select]
(defun FileBox(/ cdl f)
;OFN_READONLY &H1       1 La case 'Lecture seule' est cochée à la création de la fenêtre.
;OFN_OVERWRITEPROMPT &H2       2 Afficher un message de confirmation d'écrasement de fichier si celui-ci existe déjà.
;OFN_HIDEREADONLY &H4       4 Case à cocher 'Lecture seule' invisible.
;OFN_NOCHANGEDIR &H8       8 Conserve le répertoire d'origine à la fermeture de la fenêtre.
;OFN_SHOWHELP &H10      16 Afficher le bouton 'Aide' dans la boîte de dialogue.
;OFN_NOVALIDATE &H100     256 Ne vérifie pas la validité de la saisie (validité du nom de fichier).
;OFN_ALLOWMULTISELECT &H200     512 Autoriser la sélection multiple de fichiers.
;OFN_EXTENSIONDIFFERENT &H400    1024 Indique que l'utilisateur a choisi une extension différente de celle par défaut.
;OFN_PATHMUSTEXIST &H800    2048 Les chemins et fichiers saisis doivent exister.
;OFN_FILEMUSTEXIST &H1000    4096 Seuls des fichiers existants peuvent être saisis.
;OFN_CREATEPROMPT &H2000    8192 Afficher une fenêtre de confirmation de création de fichier.
;OFN_SHAREAWARE &H4000   16384 Ignorer les erreurs de partage réseau.
;OFN_NOREADONLYRETURN &H8000   32768 Ne sélectionne pas la case à cocher 'Lecture seule'.
;OFN_NOTESTFILECREATE &H10000   65536 Le fichier ne sera pas créé avant la fermeture de la fenêtre.
;OFN_NONETWORKBUTTON &H20000 131072 Cache (désactive) le bouton 'Réseau'.
;OFN_NOLONGNAMES &H40000 262144 Utilise les noms courts de fichier (sans effet dans le cas des fenêtres du type 'Explorer').

;OFN_EXPLORER &H80000 524288 Donne un style 'Explorer' à la boîte de dialogue (par défaut).
; Qui ne fonctionne apparement pas sous XP

;OFN_LONGNAMES &H200000 2097152 Gestion des noms longs pour les boîtes de dialogue n'ayant pas le style 'Explorer'.
;OFN_NODEREFERENCELINKS &H100000 1048576 La boîte de dialogue prendra le nom et le chemin du raccourci sélectionné.

  (setq cdl (vlax-create-object "userAccounts.CommonDialog"))
  (vlax-put-property cdl 'filter (vlax-make-variant "Fichiers dessins (*.dwg)| *.dwg |Fichiers DXF (*.dwf) |Tous les fichiers (*.*)|*.*"))
  (vlax-put-property cdl 'filterindex 1)
  (vlax-put-property cdl 'flags (+ 4 8 512 2048 4096 131072 2097152))
  (vlax-put-property cdl 'initialdir (getvar "dwgprefix"))
  (if (eq (vlax-invoke cdl 'showopen) -1)
    (setq f (vlax-get-property cdl 'filename))
    (setq f nil)
  )
  (vlax-release-object cdl)
  f
)

ps : sorry for the language. It's in french

@+


<edit: Fixed Code tags>
« Last Edit: January 28, 2007, 03:35:39 PM by CAB »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #2 on: January 28, 2007, 03:39:58 PM »
Yes, I expected that to work but my Windows2000 does not have "comdlg32.dll" or "comdlg.dll"
Is that file only added when you use NET or Visual basic?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #3 on: January 28, 2007, 04:15:04 PM »
CAB,
all windows installations have comdlg, but the file may be a different name. To determine if you can create that dialog, try to create it from the class name ..
Code: [Select]
(setq dialog (vlax-create-object "MSComDlg.CommonDialog"))

To determine which values you need to set, you can refer to the constants provided by patrick, but some of the variable names are different depending upon the version of Windows you have.
To get the correct names, just dump the object

Code: [Select]
(vlax-dump-object dialog)

You will now be able to see the values you need to set.

I have revised the code provided by Patrick to work on my system (along with a couple of code corrections)
Code: [Select]
(defun FileBox(/ cdl f)
;OFN_READONLY &H1       1 La case 'Lecture seule' est cochée à la création de la fenêtre.
;OFN_OVERWRITEPROMPT &H2       2 Afficher un message de confirmation d'écrasement de fichier si celui-ci existe déjà.
;OFN_HIDEREADONLY &H4       4 Case à cocher 'Lecture seule' invisible.
;OFN_NOCHANGEDIR &H8       8 Conserve le répertoire d'origine à la fermeture de la fenêtre.
;OFN_SHOWHELP &H10      16 Afficher le bouton 'Aide' dans la boîte de dialogue.
;OFN_NOVALIDATE &H100     256 Ne vérifie pas la validité de la saisie (validité du nom de fichier).
;OFN_ALLOWMULTISELECT &H200     512 Autoriser la sélection multiple de fichiers.
;OFN_EXTENSIONDIFFERENT &H400    1024 Indique que l'utilisateur a choisi une extension différente de celle par défaut.
;OFN_PATHMUSTEXIST &H800    2048 Les chemins et fichiers saisis doivent exister.
;OFN_FILEMUSTEXIST &H1000    4096 Seuls des fichiers existants peuvent être saisis.
;OFN_CREATEPROMPT &H2000    8192 Afficher une fenêtre de confirmation de création de fichier.
;OFN_SHAREAWARE &H4000   16384 Ignorer les erreurs de partage réseau.
;OFN_NOREADONLYRETURN &H8000   32768 Ne sélectionne pas la case à cocher 'Lecture seule'.
;OFN_NOTESTFILECREATE &H10000   65536 Le fichier ne sera pas créé avant la fermeture de la fenêtre.
;OFN_NONETWORKBUTTON &H20000 131072 Cache (désactive) le bouton 'Réseau'.
;OFN_NOLONGNAMES &H40000 262144 Utilise les noms courts de fichier (sans effet dans le cas des fenêtres du type 'Explorer').

;OFN_EXPLORER &H80000 524288 Donne un style 'Explorer' à la boîte de dialogue (par défaut).
; Qui ne fonctionne apparement pas sous XP

;OFN_LONGNAMES &H200000 2097152 Gestion des noms longs pour les boîtes de dialogue n'ayant pas le style 'Explorer'.
;OFN_NODEREFERENCELINKS &H100000 1048576 La boîte de dialogue prendra le nom et le chemin du raccourci sélectionné.

  (setq cdl (vlax-create-object "MSComDlg.CommonDialog"))
  (vlax-put-property cdl 'filter (vlax-make-variant "AutoCAD Drawing (*.dwg)| *.dwg |Drawing eXchange File DXF (*.dwf) |All Files (*.*)|*.*"))
  (vlax-put-property cdl 'filterindex 1)
  (vlax-put-property cdl 'flags (+ 4 8 512 2048 4096 131072 2097152))
  (vlax-put-property cdl 'initdir (getvar "dwgprefix"))
  (vlax-put-property cdl 'maxfilesize 1024)
  (if (eq (vlax-invoke cdl 'showopen) -1)
    (setq f nil)
    (setq f (vlax-get-property cdl 'filename))
  )
  (vlax-release-object cdl)
  f
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Patrick_35

  • Guest
Re: OpenFileDialog
« Reply #4 on: January 28, 2007, 07:31:54 PM »
Sorry Keith
But comdlg don't work with Windows XP  and A2000 :-(
(setq cdl (vlax-create-object "MSComDlg.CommonDialog")) return nil

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #5 on: January 28, 2007, 08:17:34 PM »
Shoot, it returns nil here as well. :-(
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #6 on: January 29, 2007, 08:35:15 AM »
Well ... I have just tried it again, this time on XP SP2 ... so far I have been able to run it on Win98, WinME, WinXP SP1, and WinXP SP2 ... 4 different computers 2 with XP.

There must be something different in your setup preventing it from being created.

Open the registry, select hkey_classes_root then scroll down and see if you can find "MSComDlg.CommonDialog"
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #7 on: January 29, 2007, 08:55:50 AM »
OK, found this:
The {xxxx-xxxx-xxx...} are deferent data values.
Code: [Select]
/CLSID/{XXX-XXX-XXXX...}
/MSComDlg.CommonDialog ->Microsoft ...., version 6.0 (SP6)
.../CLSID  -> {xxx-xxxxx-xxx...}
.../CurVer -> MSComDlg.CommonDialog.1


/MSComDlg.CommonDialog.1 -> {xxx-xxxxx-xxx...}
.../CLSID  -> {xxx-xxxxx-xxx...}

PS I'm runnung Windows 2000
« Last Edit: January 29, 2007, 08:58:25 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #8 on: January 29, 2007, 08:59:50 AM »
Try changing the creation object to "MSComDlg.CommonDialog.1"
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #9 on: January 29, 2007, 09:08:22 AM »
No Joy.
Code: [Select]
_$ (setq dialog (vlax-create-object "MSComDlg.CommonDialog"))
nil
_$ (setq dialog (vlax-create-object "MSComDlg.CommonDialog.1"))
nil
_$ (setq dialog (vlax-create-object "MSComDlg.CommonDialog"))
nil
_$
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Fatty

  • Guest
Re: OpenFileDialog
« Reply #10 on: January 29, 2007, 09:46:29 AM »
Alan, agree with you
Tested in A2005 eng
Not works for me also
Maybe need to register this component before?

~'J'~

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #11 on: January 29, 2007, 09:57:38 AM »
If it is in the registry, then it is already registered.

If you do a search for ComDlg32.ocx do you find anything?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #12 on: January 29, 2007, 10:28:46 AM »
Thanks for the help Keith.
This is what I found.
Don't know why I didn't find it on a previous search.
« Last Edit: January 29, 2007, 10:30:07 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #13 on: January 29, 2007, 10:33:02 AM »
Just tried in ACAD2004 & nil was returned.  :-(
Code: [Select]
(setq dialog (vlax-create-object "MSComDlg.CommonDialog"))
(setq dialog (vlax-create-object "MSComDlg.CommonDialog.1"))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #14 on: January 29, 2007, 10:34:09 AM »
I cannot fathom why it will not allow you to create the window ... have you tried re-registering the dll or OCX with regsvr32 ?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #15 on: January 29, 2007, 11:55:18 AM »
CAB ...

I tried something here in this VLX .. let me know if it works ...

<REMOVED ATTACHMENT -- SEE LATER POST>
« Last Edit: January 29, 2007, 04:15:04 PM by Keith™ »
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #16 on: January 29, 2007, 02:29:09 PM »
I regerestered the ocx & then tried this
Code: [Select]
_$ (setq dialog (vlax-create-object "MSComDlg.CommonDialog"))
nil
_$ (setq dialog (vlax-create-object "MSComDlg.CommonDialog.1"))
nil
_$

I then tried to register the dll & got this
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #17 on: January 29, 2007, 02:55:02 PM »
Cab, try the VLX in the previous post to see if it provides the window, if it does, then I have a sneaking suspicion that the error is related to the design time license I have with the CommDlg32.ocx. Since I have the developer edition of VB both here and at home that may be the defining factor. Either way, if the above code works, it "should" grant you rights to use the dialog based on my giving you rights through my license ... i.e. the type library is on your computer, but the license to use it must come from a licensed developer .. in otherwords I can distribute an application that uses the comdlg window, but I can't distribute the type library and by my distribution of this application in the compiled format, it should .. theoretically give you permissions enough to create the window ... I don't know if it extends past the compiled code .. for example any code you might write.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #18 on: January 29, 2007, 03:25:00 PM »
Loaded it, used Start CommonDialog, Here is what I get:
« Last Edit: January 29, 2007, 03:26:05 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #19 on: January 29, 2007, 03:27:49 PM »
WELL DAGNABIT ... The command is (commondialog) .. forgot to mention that ...

It should work ... back to the drawing board ..
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #20 on: January 29, 2007, 03:32:47 PM »
Code: [Select]
Command: (commondialog)

Error: too many arguments
:-o
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #21 on: January 29, 2007, 03:36:49 PM »
A different error? Now this is really getting intriguing ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Fatty

  • Guest
Re: OpenFileDialog
« Reply #22 on: January 29, 2007, 03:58:52 PM »
Code: [Select]
Command: (commondialog)

Error: too many arguments
:-o
Alan
I've got the similar one:
Code: [Select]
Command: (commondialog (getvar "dwgprefix"))
; error: too many arguments
Command: CommonDialog
Unknown command "COMMONDIALOG".  Press F1 for help
Command: (CommonDialog)
; error: too many arguments

~'J'~

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #23 on: January 29, 2007, 04:15:42 PM »
Ok .. try this one then ...

Same scenario ...

(commondialog) to run
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #24 on: January 29, 2007, 05:23:26 PM »
 :-(
Code: [Select]
Command: (commondialog)
; error: bad argument type: VLA-OBJECT nil
; reset after error
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: OpenFileDialog
« Reply #25 on: January 29, 2007, 05:59:26 PM »
well ... darn ... I know I am sending the license through ... I have just never had to do it through lisp before ... I need to do a little more research ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #26 on: January 29, 2007, 06:47:48 PM »
Thnaks for your time Keith.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: OpenFileDialog
« Reply #27 on: January 30, 2007, 08:58:44 AM »
cab i've been watching what's going on in this thread and am wondering is this what you had in mind for the plottabs script we were discussing last week. so the main goal here is to be able to open multiple files from multiple folders? just curious

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #28 on: January 30, 2007, 09:34:01 AM »
Yes, but a useful tool for other lisp as well.
Here is the alternative routine.
Code: [Select]
;;  Get user pick of files, one at a time
(defun c:test (/ file files)
 
  (if (setq file (getfiled "Select a file to include in Batch" "" "dwg" 128))
    (while
      (setq files (cons file files)
            file  (getfiled "Select another file or Cancel to quit" file "dwg" 128)
      )
    )
    (princ "\nNo files were selected.")
  )
 
  (and files (princ files))
  (princ)
)
« Last Edit: January 30, 2007, 09:45:17 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

hendie

  • Guest
Re: OpenFileDialog
« Reply #29 on: January 30, 2007, 10:53:33 AM »
CAB you could smudge it by using the Browse for folders in your first post...
use the browse for folder to *ahem* browse for folders, then add a listbox to the form that displays all the files in the selected folder, and use that listbox to let the user select multiple files.

fwiw, I have the three controls on my system but still cannot use the commondialog and even stranger, I can bring in a routine from home utilising the common dialog and it works fine, but I cannot copy it across modules.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #30 on: January 30, 2007, 11:21:36 AM »
Thanks hendie for the feed back.

I did consider that method but no easy way to get files from two different folders.
I could add a button to get another folder I suppose.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: OpenFileDialog
« Reply #31 on: January 30, 2007, 12:04:15 PM »
CAB you could smudge it by using the Browse for folders in your first post...
use the browse for folder to *ahem* browse for folders, then add a listbox to the form that displays all the files in the selected folder, and use that listbox to let the user select multiple files.
Thanks hendie for the feed back.

I did consider that method but no easy way to get files from two different folders.
I could add a button to get another folder I suppose.
That is how I do it with my plot dialog box.  I have a button to open the BrowseForFolder dialog, then I add all the drawings in said folder to a list box, then add the selected ones to a list, path and all.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: OpenFileDialog
« Reply #32 on: January 30, 2007, 12:09:11 PM »
Hi
Try this
Code: [Select]
(defun FileBox(/ cdl f)
;OFN_READONLY &H1       1 La case 'Lecture seule' est cochée à la création de la fenêtre.
;OFN_OVERWRITEPROMPT &H2       2 Afficher un message de confirmation d'écrasement de fichier si celui-ci existe déjà.
;OFN_HIDEREADONLY &H4       4 Case à cocher 'Lecture seule' invisible.
;OFN_NOCHANGEDIR &H8       8 Conserve le répertoire d'origine à la fermeture de la fenêtre.
;OFN_SHOWHELP &H10      16 Afficher le bouton 'Aide' dans la boîte de dialogue.
;OFN_NOVALIDATE &H100     256 Ne vérifie pas la validité de la saisie (validité du nom de fichier).
;OFN_ALLOWMULTISELECT &H200     512 Autoriser la sélection multiple de fichiers.
;OFN_EXTENSIONDIFFERENT &H400    1024 Indique que l'utilisateur a choisi une extension différente de celle par défaut.
;OFN_PATHMUSTEXIST &H800    2048 Les chemins et fichiers saisis doivent exister.
;OFN_FILEMUSTEXIST &H1000    4096 Seuls des fichiers existants peuvent être saisis.
;OFN_CREATEPROMPT &H2000    8192 Afficher une fenêtre de confirmation de création de fichier.
;OFN_SHAREAWARE &H4000   16384 Ignorer les erreurs de partage réseau.
;OFN_NOREADONLYRETURN &H8000   32768 Ne sélectionne pas la case à cocher 'Lecture seule'.
;OFN_NOTESTFILECREATE &H10000   65536 Le fichier ne sera pas créé avant la fermeture de la fenêtre.
;OFN_NONETWORKBUTTON &H20000 131072 Cache (désactive) le bouton 'Réseau'.
;OFN_NOLONGNAMES &H40000 262144 Utilise les noms courts de fichier (sans effet dans le cas des fenêtres du type 'Explorer').

;OFN_EXPLORER &H80000 524288 Donne un style 'Explorer' à la boîte de dialogue (par défaut).
; Qui ne fonctionne apparement pas sous XP

;OFN_LONGNAMES &H200000 2097152 Gestion des noms longs pour les boîtes de dialogue n'ayant pas le style 'Explorer'.
;OFN_NODEREFERENCELINKS &H100000 1048576 La boîte de dialogue prendra le nom et le chemin du raccourci sélectionné.

  (setq cdl (vlax-create-object "userAccounts.CommonDialog"))
  (vlax-put-property cdl 'filter (vlax-make-variant "Fichiers dessins (*.dwg)| *.dwg |Fichiers DXF (*.dwf) |Tous les fichiers (*.*)|*.*"))
  (vlax-put-property cdl 'filterindex 1)
  (vlax-put-property cdl 'flags (+ 4 8 512 2048 4096 131072 2097152))
  (vlax-put-property cdl 'initialdir (getvar "dwgprefix"))
  (if (eq (vlax-invoke cdl 'showopen) -1)
    (setq f (vlax-get-property cdl 'filename))
    (setq f nil)
  )
  (vlax-release-object cdl)
  f
)

ps : sorry for the language. It's in french

@+


<edit: Fixed Code tags>


Works for me here. Using windows xp and autocad 2007....but the  dialog box is in french.

Gary
« Last Edit: January 30, 2007, 12:11:21 PM by Gary Fowler »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: OpenFileDialog
« Reply #33 on: January 30, 2007, 12:48:23 PM »
I was searching on the MSDN site and found this question.
Quote
Hey, Scripting Guy! Is there any way I can use a script to present a user with a dialog box and let him or her select a file?

-- BF
And this answer
Quote
Hey, BF. If you’re using Windows 2000, we don’t know of a way to do this, at least not a way that’s built into the operating system. That’s not the case with Windows XP, however. On Windows XP, you can use the UserAccounts.CommonDialog object to present users with a standard File Open dialog box. Here’s what the script looks like:
Here

It doesn't look good for use Win2000 people Alan.  I will continue to look when I have free time.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: OpenFileDialog
« Reply #34 on: January 30, 2007, 12:51:01 PM »
Oh well, at least I'll quit head butting that wall. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
Re: OpenFileDialog
« Reply #35 on: January 30, 2007, 01:52:14 PM »
I was searching on the MSDN site and found this question.
Quote
Hey, Scripting Guy! Is there any way I can use a script to present a user with a dialog box and let him or her select a file?

-- BF
And this answer
Quote
Hey, BF. If you’re using Windows 2000, we don’t know of a way to do this, at least not a way that’s built into the operating system. That’s not the case with Windows XP, however. On Windows XP, you can use the UserAccounts.CommonDialog object to present users with a standard File Open dialog box. Here’s what the script looks like:
Here

It doesn't look good for use Win2000 people Alan.  I will continue to look when I have free time.
Once again this doesn't Alan, but Tim's previous post was for a single selection Dialog box, HERE is for a multi-select Dialog Box.

Sorry Alan  :-(

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: OpenFileDialog
« Reply #36 on: January 30, 2007, 02:03:46 PM »
 . . . good ole ObjectDCL . . .  :lol:
James Buzbee
Windows 8

T.Willey

  • Needs a day job
  • Posts: 5251
Re: OpenFileDialog
« Reply #37 on: January 30, 2007, 02:05:48 PM »
. . . good ole ObjectDCL . . .  :lol:
Does ObjectDCL has the same limit as regural dcl?  Limited by the amout of items you can select, I think it's around 255 (Acads magic number).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CADmium

  • Newt
  • Posts: 33
Re: OpenFileDialog
« Reply #38 on: August 26, 2009, 03:17:38 AM »
Is there a flag for the UserAccounts.CommonDialog-Object to get a Filesaveas-dialog ?
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

CADmium

  • Newt
  • Posts: 33
Re: OpenFileDialog
« Reply #39 on: August 26, 2009, 03:38:21 AM »
ok .. found it ... look at the Object "SAFRCFileDlg.FileSave"
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."