Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba,microsoft.public.word.vba.general
external usenet poster
 
Posts: 23
Default Best Practice for Obtaining hWnd

Karl, I have limited experience with such matters, but I'll share my
observations and conclusions:

Some months ago I was attempting to manage position of the Assistant
Balloon in Access (2003).

After many hours of digging around API information I came to the sad
conclusion that with respect to Access, at any rate, I was pursuing a
hopeless cause as to the best of my ability to discover, all internal
Access position information was relative to the user area of the Access
window, *not* the Windows display area (as is hWnd). I believe that it
would be possible to develop routines that would be able to "travel
between the two worlds" but for my purposes it was not worth the effort.

I also understand that VBA UserForms and Access Forms are completely
different, and properties and methods effectively have no correlation
from one to the other.

I have also observed that the Excel and Access Application Objects
handle windows and screens very differently.

Not much to offer, but perhaps of some use to you.

--
Clif

"Karl E. Peterson" wrote in message
...
Hi Folks --

Is there any sort of agreed upon "best practice" for obtaining the
hWnd of VBA UserForms? Something that'll pretty much work wherever
VBA may be found? I seem to generally use some variation of this:

Option Explicit

Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private hWnd As Long

Private Sub UserForm_Activate()
hWnd = GetForegroundWindow()
Debug.Print Hex$(hWnd)
End Sub

But I'm pretty much only working in either Word or Excel, and version
2003 at that. Any reason to think that wouldn't work in PowerPoint,
Access, 2007, 2000, elsewhere, ...? Is there a better (more
universal) way?

Thanks... Karl
--
.NET: It's About Trust!
http://vfred.mvps.org




--
Clif


  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.vba,microsoft.public.word.vba.general
external usenet poster
 
Posts: 6
Default Best Practice for Obtaining hWnd

Hi Clif --

Well, okay, ya made me look. <g I just tried the code I suggested, in Access 2003,
and it worked fine. (It appears Rick's FindWindow call would work, as well, given
the classname for the Access UserForm is the same as Word or Excel.) Note, I'm not
looking at the Access forms, but the VBA UserForms, here.

Thanks... Karl


Clif McIrvin wrote:
Karl, I have limited experience with such matters, but I'll share my
observations and conclusions:

Some months ago I was attempting to manage position of the Assistant
Balloon in Access (2003).

After many hours of digging around API information I came to the sad
conclusion that with respect to Access, at any rate, I was pursuing a
hopeless cause as to the best of my ability to discover, all internal
Access position information was relative to the user area of the Access
window, *not* the Windows display area (as is hWnd). I believe that it
would be possible to develop routines that would be able to "travel
between the two worlds" but for my purposes it was not worth the effort.

I also understand that VBA UserForms and Access Forms are completely
different, and properties and methods effectively have no correlation
from one to the other.

I have also observed that the Excel and Access Application Objects
handle windows and screens very differently.

Not much to offer, but perhaps of some use to you.

--
Clif

"Karl E. Peterson" wrote in message
...
Hi Folks --

Is there any sort of agreed upon "best practice" for obtaining the
hWnd of VBA UserForms? Something that'll pretty much work wherever
VBA may be found? I seem to generally use some variation of this:

Option Explicit

Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private hWnd As Long

Private Sub UserForm_Activate()
hWnd = GetForegroundWindow()
Debug.Print Hex$(hWnd)
End Sub

But I'm pretty much only working in either Word or Excel, and version
2003 at that. Any reason to think that wouldn't work in PowerPoint,
Access, 2007, 2000, elsewhere, ...? Is there a better (more
universal) way?

Thanks... Karl
--
.NET: It's About Trust!
http://vfred.mvps.org


--
..NET: It's About Trust!
http://vfred.mvps.org


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 statusbar hWnd Jamie Collins Excel Programming 6 July 3rd 07 03:54 PM
HWND of Listbox in UserForm in Excel macro Jozsef Bekes Excel Programming 7 November 10th 06 06:45 PM
Getting hWnd for API call or Color choosing dialog Jeff[_31_] Excel Programming 13 June 5th 04 03:18 AM
hWnd of UserForm rsmith Excel Programming 3 February 10th 04 12:32 AM
how to get hwnd from application object? Erwin Kalvelagen Excel Programming 2 December 16th 03 07:12 PM


All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"