Re: Passing structures` flags to WinAPI32 functions from VB(VBA)
From: MikeD (nobody_at_nowhere.edu)
Date: 08/25/04
- Next message: MikeD: "Re: Passing structures` flags to WinAPI32 functions from VB(VBA)"
- Previous message: Mike D Sutton: "Re: Trying to rotate a bitmap"
- In reply to: Serg: "Passing structures` flags to WinAPI32 functions from VB(VBA)"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 25 Aug 2004 19:25:27 -0400
"Serg" <Serg@discussions.microsoft.com> wrote in message
news:AF26DFF3-42A0-4BBD-AA6A-AD886519F40B@microsoft.com...
> Dear Sirs,
There ARE Madams that read the newsgroups too. <g>
> I`m trying to pass flags of BROWSEINFO structure from VBA code on
> MsAccess2000.
> In it I should declare each flag as numeric constant with hexanumeric
value
> like this:
>
> Option Compare Database
> Option Explicit
>
> Private Type BrowseInfo
> hOwner As Long
> pIDLRoot As Long
> pszDisplayName As String
> lpszTitle As String
> ulFlags As Long
> lpfn As Long
> lParam As Long
> iImage As Long
> End Type
>
> Private Const BIF_RETURNONLYFSDIRS = &H1
> Private Const BIF_EDITBOX = &.....????
>
> How can I get numeric value to flag BIF_EDITBOX or other flags? In
> documentation of this structure it is not described.
One way to get them is from the C header file (these files have a .h
extension). However, you need a C++ programming tool installed OR you can
download and install the Platform SDK (which also includes the .h files).
Then, copy all the .h files somewhere else and remove the Platform SDK if
you don't want it. The Platform SDK documentation tells you what .h file
you need. For example, for the BROWSEINFO structure, at the very bottom of
the documentation, you'll see this:
Header: Declared in shlobj.h.
So, open that file in Notepad (or whatever you want, preferably something in
which you can do a Find). You'll find this:
#define BIF_EDITBOX 0x0010
In VB, this would be
Const BIF_EDITBOX As Long = &H10
IOW, replace '#define' with 'Const' (optionally, include the Public or
Private keyword). Add the 'As Long' (or whatever the data type should be).
Replace the '0x' with '= &H'. VB will take care of the rest. Note that you
will find some constants that are not expressed in hexadecimal. Do not use
'&H' for these.
There are a couple gotchas to be aware of. For example, you may occasionally
come across this Hex value: 0x0000FFFF. If you follow the steps I've
outlined above, you'd end up with something like this:
Const TEST As Long = &HFFFF
That declaration is incorrect. To VB, this is -1. You need to specifically
cast the hex value to a Long. The As Long doesn't do that. It just defines
the constant to be a Long. This is the correct declaration:
Const TEST As Long = &HFFFF&
This declaration results in the correct value of 65535. What I usually do,
just to be safe, is always end with the &. VB will automatically remove it
if it's not needed. I assume VBA does the same thing. For future reference,
VBA questions are best asked in a VBA newsgroup....in your case, one of the
Access programming newsgroup would have been a little more appropriate.
Alternatively, search VB/VBA-related web sites or VB/VBA newsgroups (easiest
to do both/either at www.google.com). Chances are, you'll find example code
that has the declaration for the constant.
Mike
- Next message: MikeD: "Re: Passing structures` flags to WinAPI32 functions from VB(VBA)"
- Previous message: Mike D Sutton: "Re: Trying to rotate a bitmap"
- In reply to: Serg: "Passing structures` flags to WinAPI32 functions from VB(VBA)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|