LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   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

Peter T wrote:
Well hello again Karl!

As Rick says it's -
hWnd = FindWindow("ThunderDFrame", Me.Caption)

That's good for Excel 2000+ and AFAIK all Office 2000 or later with VBA6.


Good to know!

If you want to cater for anyone still using Office97 (most don't but I do) -


Ewww, no. Not anymore, thanks. :-)

If Val(Application.Version) = 9 Then
sClassName = "ThunderDFrame"
Else
sClassName = "ThunderXFrame"
End If


Still, a good nugget to have.

instead of checking the app version you could do
#If VBA6 ... #Else If ... #End IF
but will need a bit more for 2010/64bit


As I recall, and this is a very dim memory, that constant is predefined in VBA,
right? So I can use it in normal VB6 code, and it'll only come into play if the
code is sucked into VBA? I keep forgetting that. It's an incredibly useful tidbit!

If there's any possibility a form with a similar caption could be showing
elsewhere, even in another instance, best to temporarily change the caption
to something unique.


Yep. That's one of the reasons I tended against the FindWindow approach, as well.
But the GetActiveWindow approach is going to work pretty well, I think.
--
..NET: It's About Trust!
http://vfred.mvps.org




 
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 11:07 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"