--- a/Win32FileDialog.st Wed Mar 23 14:39:42 2016 +0100
+++ b/Win32FileDialog.st Wed Mar 23 14:59:57 2016 +0100
@@ -212,7 +212,7 @@
^ (Win32FileDialog new openFile: 'c:\untitled.txt') file.
"
- self openFile
+ Win32FileDialog openFile
"
!
@@ -486,8 +486,7 @@
hideReadonly
"Hides the file dialog's Readonly check box. "
- self
- style:(self style bitOr: (self class commonDialogConstantAt:'OfnHidereadonly'))
+ self style:(self style bitOr:OFN_HIDEREADONLY)
"Modified: / 26-10-2010 / 18:46:48 / cg"
!
@@ -554,8 +553,7 @@
"Allows a previously opened file to be opened
(e.g. change.log)"
- self
- style:(self style bitOr: (self class commonDialogConstantAt:'OfnShareaware'))
+ self style:(self style bitOr:OFN_SHAREAWARE)
"Modified: / 26-10-2010 / 18:47:36 / cg"
!
@@ -705,24 +703,25 @@
|rslt openFileNameStructExternalBytes|
[
- self fillStruct.
- parent notNil ifTrue:[
- openFileNameStruct hwndOwner:parent.
- ].
- style notNil ifTrue:[
- openFileNameStruct flags:style
- ].
- openFileNameStructExternalBytes := ExternalBytes from:openFileNameStruct asByteArray.
- rslt := OperatingSystem getOpenFilename:openFileNameStructExternalBytes.
- rslt ifTrue:[
- self getFileName
- ] ifFalse:[
- fileName := nil.
- error := OperatingSystem commDlgExtendedError.
- ].
+ self fillStruct.
+ parent notNil ifTrue:[
+ openFileNameStruct hwndOwner:parent.
+ ].
+ style notNil ifTrue:[
+ openFileNameStruct flags:style
+ ].
+ openFileNameStructExternalBytes := ExternalBytes from:openFileNameStruct asByteArray.
+ rslt := OperatingSystem getOpenFilename:openFileNameStructExternalBytes.
+ rslt ifTrue:[
+ self getFileName
+ ] ifFalse:[
+ fileName := nil.
+ error := OperatingSystem commDlgExtendedError.
+ self error:('GetOpenFile failed with error: %1' bindWith:error).
+ ].
] ensure:[
- openFileNameStructExternalBytes free.
- self cleanUp.
+ openFileNameStructExternalBytes notNil ifTrue:[openFileNameStructExternalBytes free].
+ self cleanUp.
].
"Created: / 23-01-2011 / 10:58:30 / cg"
@@ -881,29 +880,29 @@
fillStruct
"Private - fills the openFileNameStruct"
- | temp |
+ |maxPath lpstrFileInOut|
- temp := fileName "asAsciiZ".
- lpstrFile := ExternalBytes new:512 withAll:0.
- lpstrFile replaceBytesFrom:1 to:temp size with:temp startingAt:1.
+ maxPath := 1024.
+ lpstrFileInOut := ExternalBytes new:maxPath.
+ lpstrFileInOut replaceFrom:1 to:fileName size with:fileName startingAt:1.
lpstrFilter := ExternalBytes newNullTerminatedFromString: self filters.
lpstrInitialDir := ExternalBytes newNullTerminatedFromString: self directory pathName.
openFileNameStruct
- lpstrFile: lpstrFile address ;
- nMaxFile: 512;
- lpstrFilter: lpstrFilter address ;
- nFilterIndex: defFilterIndex ; "set by filters"
- lpstrInitialDir: lpstrInitialDir address.
+ lpstrFile: lpstrFileInOut address ;
+ nMaxFile: maxPath;
+ lpstrFilter: lpstrFilter address ;
+ nFilterIndex: defFilterIndex ; "set by filters"
+ lpstrInitialDir: lpstrInitialDir address.
- ( temp := defExtension) notNil ifTrue: [
- lpstrDefExt := ExternalBytes newNullTerminatedFromString: temp.
- openFileNameStruct lpstrDefExt: lpstrDefExt address].
+ defExtension notNil ifTrue: [
+ lpstrDefExt := ExternalBytes newNullTerminatedFromString: defExtension.
+ openFileNameStruct lpstrDefExt: lpstrDefExt address].
- ( temp := title ) notNil ifTrue: [
- lpstrTitle := ExternalBytes newNullTerminatedFromString: temp.
- openFileNameStruct lpstrTitle: lpstrTitle address ].
+ title notNil ifTrue: [
+ lpstrTitle := ExternalBytes newNullTerminatedFromString: title.
+ openFileNameStruct lpstrTitle: lpstrTitle address ].
"Modified: / 27-10-2010 / 10:56:01 / cg"
!