Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / April 2008



Tip: Looking for answers? Try searching our database.

GetSaveFileName Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TC - 07 Apr 2008 10:12 GMT
Hey All,

I am using the GetSaveFileName API and I wanted to know if there is a way to
have the 'File Name' textbox show up empty?

For example, in most Windows apps or Office apps for that matter, when one
does a 'Save As', the cursor is placed in the 'File Name' textbox but the
textbox is empty vs. having all of the placeholder character spaces that the
GetSaveFileName defaults to because of the lpstrFile value inside the
OPENFILENAME structure.

Any advice?

Thanks,

TC
PeterD - 07 Apr 2008 13:56 GMT
>Hey All,
>
[quoted text clipped - 12 lines]
>
>TC

Like setting:

 lpstrFile = chr$(0) ' set file name to null length string.

have you tried this?
TC - 07 Apr 2008 14:39 GMT
Hey Peter,

Yes.

The problem with this approach is that it does not leave any space in the
buffer for the new actual filename.

The actual textbox on the FileSave dialog needs to be reset.

Thanks,

TC

>>Hey All,
>>
[quoted text clipped - 20 lines]
>
> have you tried this?
Dave O. - 07 Apr 2008 15:04 GMT
try:

.lpstrFile = vbnullchar & space(259)
.nMaxFile = Len(.lpstrFile)

Regards
Dave O.

> Hey All,
>
[quoted text clipped - 12 lines]
>
> TC
TC - 07 Apr 2008 15:23 GMT
Thanks Dave!

Just what I needed ;-)

> try:
>
[quoted text clipped - 20 lines]
>>
>> TC
Thorsten Albers - 07 Apr 2008 17:15 GMT
TC <getmyemails2@yahoo.com> schrieb im Beitrag
<u7L959ImIHA.1280@TK2MSFTNGP05.phx.gbl>...
> I am using the GetSaveFileName API and I wanted to know if there is a way to
> have the 'File Name' textbox show up empty?
> For example, in most Windows apps or Office apps for that matter, when one
> does a 'Save As', the cursor is placed in the 'File Name' textbox but the

> textbox is empty vs. having all of the placeholder character spaces that the
> GetSaveFileName defaults to because of the lpstrFile value inside the
> OPENFILENAME structure.
> Any advice?

When you have to provide an >empty< buffer to a non-VB function which
(unlike VB) uses NULL terminated strings before passing the buffer to the
function you should initialize it to NULL bytes instead of spaces. I.e.
instead of
 MyBuffer$ = Space$(260)
use
 MyBuffer$ = String$(260, vbNullChar)

This prevents errors on the function's side and makes much more sense
within the context of the function.

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.