COMDLG32.DLL Here is a good one.

G

Guest

I just learned how to use the "GetOpenFileNameA" function in comdlg32.dll.

I like it. I also noticed that in IE the "GetOpenFileNameA" window has an
extra pull down box called "Encoding" and in another program I see a "Tools"
button next to the "View Menu" button.

The ideal is this.
If I can add two buttons to the existing "GetOpenFileNameA" window, named
"ZIP" and "UNZIP". I would be able to zip and unzip files right in the
"GetOpenFileNameA" window. This could cut out a lot of programing and make
it easyier to the users.

What do you think, Can I add the buttons and will it make zipping easier?
All opinions welcome.
 
G

Guest

It is possible, (any windows programming is possible
from Access), but too much work. You need to subclass
the dialog. To subclass that dialog, you need to create
and register a callback function, (called by Windows
when you use the GetOpenFileName function). Then
you need to define the new appearance of the dialog in
a format windows can understand, and register that.

I have never seen an Access example of defining the
button names. If I had one, I would provide it and you
could just copy the code. But it is too much work.

sorry,

(david)
 
G

Guest

Thanks David. I guess it was too much to hope for. How well....

How about this:
Has anyone seen a third party function that does what the GetOpenFileName
function does but also has zip Functionality added? I can't believe that I
am the only person in the last ten years that is looking for this
combination.

Scott
 
D

david epsom dot com dot au

Scott Burke said:
Thanks David. I guess it was too much to hope for. How well....

How about this:
Has anyone seen a third party function that does what the GetOpenFileName
function does but also has zip Functionality added? I can't believe that
I
am the only person in the last ten years that is looking for this
combination.


When you have the file dialog open, right click on one of the zip files.

It's not exactly what you wanted, but it may be close enough :~)


(david)
 
G

Guest

True.... What I was trying to do is get a way form thrid party software link
winzip.

Hey David. I found this code on the internet. It has a problem that maybe
you can answear. I am getting an error "Run-time error '7' Out of memory".
I am sure that there is tons of memory. (1 gig + swapfile).

Here is the code:
I will flag the line with the error.
my code says " call uncompress("A:\TMP\MAGINFO.ZIP")

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest
As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function ZCompress Lib "zlib.dll" Alias "compress" (dest As
Any, destLen As Any, src As Any, ByVal srcLen As Long) As Long
Private Declare Function ZUncompress Lib "zlib.dll" Alias "uncompress" (dest
As Any, destLen As Any, src As Any, ByVal srcLen As Long) As Long

Public Function Compress(Data, Optional Key)
Dim lKey As Long 'original size
Dim sTmp As String 'string buffer
Dim bData() As Byte 'data buffer
Dim bRet() As Byte 'output buffer
Dim lCSz As Long 'compressed size

If TypeName(Data) = "Byte()" Then 'if given byte array data
bData = Data 'copy to data buffer
ElseIf TypeName(Data) = "String" Then 'if given string data
If Len(Data) > 0 Then 'if there is data
sTmp = Data 'copy to string buffer
ReDim bData(Len(sTmp) - 1) 'allocate data buffer
CopyMemory bData(0), ByVal sTmp, Len(sTmp) 'copy to data buffer
sTmp = vbNullString 'deallocate string buffer
End If
End If
If StrPtr(bData) <> 0 Then 'if data buffer contains data
lKey = UBound(bData) + 1 'get data size
lCSz = lKey + (lKey * 0.01) + 12 'estimate compressed size
ReDim bRet(lCSz - 1) 'allocate output buffer
Call ZCompress(bRet(0), lCSz, bData(0), lKey) 'compress data (lCSz
returns actual size)
ReDim Preserve bRet(lCSz - 1) 'resize output buffer to actual size
Erase bData 'deallocate data buffer
If IsMissing(Key) Then 'if Key variable not supplied
ReDim bData(lCSz + 3) 'allocate data buffer
CopyMemory bData(0), lKey, 4 'copy key to buffer
CopyMemory bData(4), bRet(0), lCSz 'copy data to buffer
Erase bRet 'deallocate output buffer
bRet = bData 'copy to output buffer
Erase bData 'deallocate data buffer
Else 'Key variable is supplied
Key = lKey 'set Key variable
End If
If TypeName(Data) = "Byte()" Then 'if given byte array data
Compress = bRet 'return output buffer
ElseIf TypeName(Data) = "String" Then 'if given string data
sTmp = Space(UBound(bRet) + 1) 'allocate string buffer
CopyMemory ByVal sTmp, bRet(0), UBound(bRet) + 1 'copy to string
buffer
Compress = sTmp 'return string buffer
sTmp = vbNullString 'deallocate string buffer
End If
Erase bRet 'deallocate output buffer
End If
End Function

Public Function Uncompress(Data, Optional ByVal Key)
Dim lKey As Long 'original size
Dim sTmp As String 'string buffer
Dim bData() As Byte 'data buffer
Dim bRet() As Byte 'output buffer
Dim lCSz As Long 'compressed size

If TypeName(Data) = "Byte()" Then 'if given byte array data
bData = Data 'copy to data buffer
ElseIf TypeName(Data) = "String" Then 'if given string data
If Len(Data) > 0 Then 'if there is data
sTmp = Data 'copy to string buffer
ReDim bData(Len(sTmp) - 1) 'allocate data buffer
CopyMemory bData(0), ByVal sTmp, Len(sTmp) 'copy to data buffer
sTmp = vbNullString 'deallocate string buffer
End If
End If
If StrPtr(bData) <> 0 Then 'if there is data
If IsMissing(Key) Then 'if Key variable not supplied
lCSz = UBound(bData) - 3 'get actual data size
CopyMemory lKey, bData(0), 4 'copy key value to key
ReDim bRet(lCSz - 1) 'allocate output buffer
CopyMemory bRet(0), bData(4), lCSz 'copy data to output buffer
Erase bData 'deallocate data buffer
bData = bRet 'copy to data buffer
Erase bRet 'deallocate output buffer
Else 'Key variable is supplied
lCSz = UBound(bData) + 1 'get data size
lKey = Key 'get Key
End If
**************************************
**************************************
ReDim bRet(lKey - 1) 'allocate output buffer
why does this give me an "out of memory" error.
**************************************
**************************************
Call ZUncompress(bRet(0), lKey, bData(0), lCSz) 'decompress to output
buffer
Erase bData 'deallocate data buffer
If TypeName(Data) = "Byte()" Then 'if given byte array data
Uncompress = bRet 'return output buffer
ElseIf TypeName(Data) = "String" Then 'if given string data
sTmp = Space(lKey) 'allocate string buffer
CopyMemory ByVal sTmp, bRet(0), lKey 'copy to string buffer
Uncompress = sTmp 'return string buffer
sTmp = vbNullString 'deallocate string buffer
End If
Erase bRet 'deallocate return buffer
End If
End Function
 
D

david epsom dot com dot au

I don't have zlib.dll to test, but what is the value of lKey at that point?

(david)
 
G

Guest

The value of lkey is "1415330369" at the point of the error.
Sorry, I really don't understand why the code is doing what it is doing.

should compressing and uncompressing be as simple as passing the name
of the file to the function in the .DLL ???

Scott
 
D

david epsom dot com dot au

Scott Burke said:
The value of lkey is "1415330369" at the point of the error.
Sorry, I really don't understand why the code is doing what it is doing.

should compressing and uncompressing be as simple as passing the name
of the file to the function in the .DLL ???

Scott

That is 1.4GB

I'm not surprised you are getting an out-of-memory error.

I don't have a copy of zlib.dll, but the code looks like it
is for compressing the data in a string variable - not for
compressing a file. You would have to read the file, uncompress
it, then write the data out to a new file.

(david)
 
G

Guest

Well…
I obviously have no ideal what I am doing.

I think I will go look for that site again.
Do you have functions that will compress a file in WinZip format? Maybe
using windows zip DLL?

I am looking to zip/unzip files in WinZip format. There will be one file
per zip.

Thanks again David.
Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top