Re: Passing structures` flags to WinAPI32 functions from VB(VBA)

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: MikeD (nobody_at_nowhere.edu)
Date: 08/25/04


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



Relevant Pages

  • Re: SIMPLE question [Was: Re: TIP #193: Simple Syntax Help System
    ... the "cmdline" package (command line arguments); ... For each boolean flag in the argument list, ... An argument declaration can specify this field if and only if its ... The system builds the command line options usage string. ...
    (comp.lang.tcl)
  • Re: changevalue and newvalue
    ... You're right - if you declare the flag at the form level, it keeps it's value as long as the form is open. ... Note that the var declaration needs to be placed above the event declaration or it will be cleared each time the event runs. ...
    (comp.databases.paradox)
  • Re: changevalue and newvalue
    ... I forgot to mention initializing it in Init. ... Note that the var declaration needs to be placed above the event ... flag logical ...
    (comp.databases.paradox)
  • Re: changevalue and newvalue
    ... declare the logical flag variable in the var method of the form (or ... Note that the var declaration needs to be placed above the event ...
    (comp.databases.paradox)
  • Re: DocumentChange event: microsoft bug?
    ... For myself I'd try to work with a public variable as a "flag" ... (e.g. declaration in module: Public FlagDBConnected as Boolean). ... Peter ...
    (microsoft.public.word.vba.general)