Solved

Using Win16 commdlg.dll API in VB4

Posted on 1998-02-28
4
420 Views
Last Modified: 2008-03-17
I have determined from a previously asked question that under VB4 16-bit enviroment using the CommonDialog control there is no way to determine which file type/extension filter has been selected.  What I'm trying top do is directly access the Win16 commdlg.dll API to give me the ability to determine which file type has been selected so that I can then save a file in that format.  I've been able to successfully display the File Save dialog by writting a  C DLL function that is simply wrapper for the actual API function that I call from my VB program.  My problem is that I have formatted the lpstrFilter member of the OPENFILENAME struct to how it is described in the Win16 SDK but the "List files of type" listbox only shows the first filter name I specfied and it doesn't apply the filter to the file listings.  What am I missing here and is there an better alternative to may approah?
0
Comment
Question by:armg
  • 2
4 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1458150
I think the string must be loaded from a resource file
0
 

Author Comment

by:armg
ID: 1458151
What effect would loading a string from a resource file have that couldn't be achieved otherwise?
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1458152
Just try it, I remember that I had a simular problem and it solved it.
0
 
LVL 8

Accepted Solution

by:
mrmick earned 250 total points
ID: 1458153
armg, you are correct in that a resource file can't make any difference except that a string would automatically be appended with a zero byte at the end.

VB5 automatically appends a zero byte to the end of a string; however, VB4 did not.  When preparing a string to be passed to the API using VB4, you need to add a zero byte to the string as follows:

strStringArg = "Any old string" & chr$(0)

If this doesn't fix the situation - email the DLL source code (if you'd like) and I'll translate and return the equivalent VB.  My email address is: mick@owen.wa.com

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 48
Using "ScreenUpdating" 6 73
Run code from text file in vb 1 71
TT Auto Dashboard 13 95
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question