View previous topic :: View next topic |
Author |
Message |
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Sun Jun 15, 2014 10:16 pm Post subject: Creating a new folder |
|
|
Is there a standard dialog to create a new folder? I know there is subroutine MKDIR@ but this needs a path to be already defined - it doesn't provide the dialog window to speicfy this path. To select an existing directory there is BROWSE_FOR_FOLDER@ but this doesn't seem to allow creation of a new folder. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Sun Jun 15, 2014 10:40 pm Post subject: |
|
|
I do not know of a standard dialog box that only creates a new folder but the standard Open and Save As dialog boxes also allow you to create new folders. |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Sun Jun 15, 2014 11:26 pm Post subject: |
|
|
Many thanks for the quick reply, Paul! Yes, I know that this can be done, but it's not really a neat solution, as the prime function of these dialogs is to define file paths - it needs a right-click to select the new folder option. Not altogether sure how this path would be returned without selection of a file, which I don't want to have to do: at this point in the program it's just creation of a folder in which to save a number of new files.
- Steve |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Mon Jun 16, 2014 7:06 am Post subject: |
|
|
In theory you could write your own dialog using ClearWin+ with %bv and possibly %lv but it would not be easy. |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Mon Jun 16, 2014 8:10 am Post subject: |
|
|
Yes, that was my thought too. I think for the present I'll set up a simple text box for the user to type in the required path to the new directory, which can then be passed to MKDIR@. Primitive but workable! Can replace it later by something a bit cleverer. |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Mon Jun 16, 2014 8:45 pm Post subject: Re: |
|
|
silicondale wrote: | Primitive but workable! Can replace it later by something a bit cleverer. |
Hi Steve,
How about something simple like this sample.
Actually the browse for folder dialog can create folders. The easiest approach to accomplish that is to use COM-automation on the Shell.Application COM-object. The sample project I linked above includes a small DLL for that purpose.
Have fun! |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Tue Jun 17, 2014 6:51 am Post subject: |
|
|
Thanks for this Jalih. I now see that SHBrowseForFolder can be used create new folders. This function is called within browse_for_folder@ so presumably I could add this functionality to ClearWin+.
I will add this to the wish list. |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Tue Jun 17, 2014 8:02 am Post subject: |
|
|
Many thanks, jalih - for the 'something cleverer' ! Will try it today.
-----------------
[edit] Just tried it - simply brilliant! It does exactly what I needed. Many thanks for this. |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Mon Aug 11, 2014 12:54 pm Post subject: |
|
|
Hi, Jalih -- although that works brilliantly on my computer, a friend who is testing it has trouble installing. He uses BitDefender security, and it reports a trojan and refuses to load browse.dll (Gen:Trojan.Heur.GM.0144010002). I have to say that I've tried with Norton, Sophos, and Microsoft antivirus and none of these detect any problem. Could be a false positive from BitDefender but I thought I should tell you!
Just did a Metascan and 4 out of 40 antivirus programs detected this trojan - apart from Bitdefender these were F-Secure, Emsisoft, and Lavasoft. The other 36 said it was clean. |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Fri Aug 15, 2014 4:10 pm Post subject: Re: |
|
|
silicondale wrote: | ...a friend who is testing it has trouble installing. He uses BitDefender security, and it reports a trojan and refuses to load browse.dll (Gen:Trojan.Heur.GM.0144010002). I have to say that I've tried with Norton, Sophos, and Microsoft antivirus and none of these detect any problem. Could be a false positive from BitDefender but I thought I should tell you! |
Sorry for the late reply. Anyway, browse.dll should be clean. I use Microsoft antivirus and Avast myself. Avast in particulary has a tendency to report a lot of files as malware. It even deleted most of the files during adw modula-2 compiler installation.
Below is the minibasic source code for the browse.dll:
Code: |
##NOCONSOLE
##MAKEDLL
export BrowseForFolder
func BrowseForFolder(string title, string buffer)
IUnknown *objShell
IDispatch *objFolder, *objFolderItem
string *path
objShell = CreateComObject("Shell.Application", "")
if objShell = NULL
buffer = ""
return
endif
GetComProperty(objShell, "%o", &objFolder, ".BrowseForFolder(%d,%s, %d)", 0, title, 0)
if objFolder = NULL
buffer = ""
else
GetComProperty(objFolder, "%o", &objFolderItem, ".Self")
GetComProperty(objFolderItem, "%s", &path, ".Path")
buffer = #path
SysFreeString(path)
objFolderItem->Release()
objFolder->Release()
endif
objShell->Release()
endf
|
|
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Fri Aug 15, 2014 5:32 pm Post subject: |
|
|
many thanks, jalih - I thought as much! I had a similar problem today loading a java update, which was rejected by Norton. Some of the antivirus programs are getting a bit too fierce. |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Sat Aug 23, 2014 7:56 am Post subject: |
|
|
Hi Steve, it's time to update into this decade...
Could you test this project?
I made a quick attempt to use Windows 7 style file dialogs. |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Sun Aug 24, 2014 2:59 pm Post subject: |
|
|
Hi, jalih .. getting virus warnings again. Virus.Win32.Heur.l on the browse.exe file, and Norton has just deleted the dll files for containing 'Suspicious.Cloud.7.EP"
However, I did buy the Minibasic compiler and rebuilt the one you sent before, whcih scans clean. Could do the same with this one. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7934 Location: Salford, UK
|
Posted: Tue Feb 10, 2015 12:23 pm Post subject: |
|
|
It turns out that there is an existing undocumented function for this.
Here is a sample program.
Code: | program main
include <windows.ins>
logical L
character(256) path
L = browse_for_folder1@(0,"Some instructions",path,Z'40')
if(L) print*, path
end |
Notes:
1) The first argument can be set to the HWND of the parent window.
2) Google search for "BROWSEINFO structure MSDN" for flags other than Z'40'. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Thu Dec 29, 2016 7:26 pm Post subject: |
|
|
This sample code now gives ne a floating point stack fault. I ran this example after my code failed.
It is interesting to note that whether or not the Z'40' or z'41' is present, the dialog always allows making a new folder. |
|
Back to top |
|
|
|