About hwnd

  • Thread starter Thread starter Baz
  • Start date Start date
B

Baz

There is no equivalent. Access is not VB6 (despite a superficial
resemblance) and although VB6 code can often be easily made to compile as
VBA code, the VB6 and Access object models are very different. Whatever the
code does, it will need to be rewritten to work with the Access object model
instead of the VB6 object model. If you explain the functionality of the
code, then doubtless someone here will tell you whether it is possible to
replicate it in Access, and if so, how.
 
Hello All
I Got A Code In VB6 It Mainly Use A Command Button Like This
Command1.hwnd
but In Access There Is No Property For The Command Button Or Other Controls
Named hwnd
So Can Any One Tell Me What Is The Equivalant Property For hwnd In Access XP

Thanks For All
 
Developer said:
Hello All
I Got A Code In VB6 It Mainly Use A Command Button Like This
Command1.hwnd
but In Access There Is No Property For The Command Button Or Other
Controls Named hwnd
So Can Any One Tell Me What Is The Equivalant Property For hwnd In Access
XP

Thanks For All

As Baz noted, there are differences between the two object models which
would need to be accounted for, but in fact Access controls _do_ have a hWnd
behind the scenes at the windows api level, but (and that's a BIG but) only
when the control has focus.

Access controls are 'painted' onto forms and only become true windows when
they have the focus.

Access doesn't expose the property, but you can call the windows api
function GetActiveWindow (at that point) to return the 'temporary' hWnd. In
practise this proves to be awkward to implement. You have to ensure the
control still has focus every time you want to use the hWnd to manipulate it
somehow. And there's also the chance that the user will hit the tab key or
click elsewhere while your code is executing, which immediately invalidates
the hWnd.

Anyhow, if you want to try this, here's the declaration you need:

Declare Function GetActiveWindow Lib "user32" () As Long
 
Hi Stuart,
here is a snip from a previous post of mine on this issue.

Certain controls such as List, Combo and Ole Frame control's have a
permanent hWnd but get rendered onto a pool of temporary Device Contexts(DC)
before making it onto the Access Screen.

Many Access control's(and the form/window itself) are heavily subclassed
versions of the standard API CreateWindow controls, such as you see over in
VB land. Others such as the ListBox, Datasheet etc. are built from private
Access window classes. Spy++ is a required tool in understanding Access
Forms and Controls. You'll quickly gain an understanding of which control's
are merely Bitmaps until they have the "focus", which controls are Bitmaps
only and never have/require "focus" , and which controls have permanent
hWnds but not a permament DC.


Lightwight controls are required for Access Forms in Continuous or Datasheet
view simply because of resource and performance considerations.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Stephen Lebans said:
Hi Stuart,
here is a snip from a previous post of mine on this issue.

Certain controls such as List, Combo and Ole Frame control's have a
permanent hWnd but get rendered onto a pool of temporary Device
Contexts(DC) before making it onto the Access Screen.

Many Access control's(and the form/window itself) are heavily subclassed
versions of the standard API CreateWindow controls, such as you see over
in VB land. Others such as the ListBox, Datasheet etc. are built from
private Access window classes. Spy++ is a required tool in understanding
Access Forms and Controls. You'll quickly gain an understanding of which
control's are merely Bitmaps until they have the "focus", which controls
are Bitmaps only and never have/require "focus" , and which controls have
permanent hWnds but not a permament DC.


Lightwight controls are required for Access Forms in Continuous or
Datasheet view simply because of resource and performance considerations.

Thanks for the info. Yes I've used Spy++ for this purpose some time ago, but
not as comprehensively as you obviously have. Which controls do you consider
'safe' to work with?
 
Stuart, the ToolTips class on my site demonstrates which control's hWnd can
be used for the length of the current Access session.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Stuart, the ToolTips class on my site demonstrates which control's hWnd
can be used for the length of the current Access session.

Thanks Stephen. I'll take a look. I have a healthy appreciation for your
work. I'm sure I'll learn something.
 
Back
Top