Re: Are VBA userforms always child of Windows desktop?
- From: "Peter T" <peter_t@discussions>
- Date: Sat, 2 Jun 2007 13:23:01 +0100
Hi Bart,
Whenever I've looked, which is not that often, the Userform's window's
parent has always been the Desktop. But to check perhaps -
Private Declare Function FindWindowA Lib "user32" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetAncestor Lib "user32.dll" ( _
ByVal hwnd As Long, ByVal gaFlags As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Const GA_PARENT = 1
Private Sub UserForm_Activate()
Dim hwnMe&, hwnParent&, hwnDesktop&
hwnMe = FindWindowA("ThunderDFrame", Me.Caption)
hwnParent = GetAncestor(hwnMe, GA_PARENT)
hwnDesktop = GetDesktopWindow
MsgBox hwnMe & vbCr & hwnParent & vbCr & hwnDesktop
End Sub
as I know I can alter the parent window of a form.
Do you know if it's possible to make a borderless/captionless VB6 form the
child of a userform, so it will remain withing the userform ?
Regards,
Peter T
"RB Smissaert" <bartsmissaert@xxxxxxxxxxxxxxxx> wrote in message
news:eQzW7SQpHHA.4112@xxxxxxxxxxxxxxxxxxxxxxx
Had a look at some code in the the book of Bullen et Al, ProfessionalExcel
Development.parent
I thought that it was suggested that VBA Userforms are the children of the
Excel
desktop window, but it appears that this is not the case and that these
windows are the
direct children of the Windows desktop.
Is this always the case?
I am interested in this as I need the form's hwnd.
I used to do this with the FindWindow API and this only needs the form's
class name
(ThunderDFrame or ThunderXFrame) and the form's caption.
Possibly it is faster (not tested yet) to get this hwnd with the
FindWindowEx API, but then
I need to know for sure that the Windows desktop is indeed always the
of this form.
This is directly after the window is created as I know I can alter the
parent window of a form.
Thanks for any advice/insight.
RBS
.
- Follow-Ups:
- Re: Are VBA userforms always child of Windows desktop?
- From: NickHK
- Re: Are VBA userforms always child of Windows desktop?
- From: RB Smissaert
- Re: Are VBA userforms always child of Windows desktop?
- From: RB Smissaert
- Re: Are VBA userforms always child of Windows desktop?
- From: Peter T
- Re: Are VBA userforms always child of Windows desktop?
- References:
- Are VBA userforms always child of Windows desktop?
- From: RB Smissaert
- Are VBA userforms always child of Windows desktop?
- Prev by Date: Re: unescape a URL
- Next by Date: Re: Copying VBA Code from one *** to another
- Previous by thread: Are VBA userforms always child of Windows desktop?
- Next by thread: Re: Are VBA userforms always child of Windows desktop?
- Index(es):