|
-
Sep 25th, 2004, 04:25 PM
#1
Thread Starter
Hyperactive Member
changing the owner of a control [RESOLVED]
I made a new UserControl and it's ControlContainer property is set to True, inside the control there is a picture box.
how can i make each control that is drawn inside my control to be the child of the picture?
anyone?
Last edited by Trojan; Sep 25th, 2004 at 05:06 PM.
-
Sep 25th, 2004, 04:29 PM
#2
VB Code:
Dim c As Control
For Each c In Controls
If Not c Is MyPicturebox Then
Set c.Container = MyPicturebox
End If
Next
That should do it.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 25th, 2004, 04:34 PM
#3
Thread Starter
Hyperactive Member
ok...
now how do I know when the user put a control inside my UserControl?
-
Sep 25th, 2004, 04:34 PM
#4
Just out of curiosity, what about using the SetParent API?
Would that do the same thing in a usercontrol?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 25th, 2004, 05:06 PM
#5
Thread Starter
Hyperactive Member
RobDog888 you Da MAN !!!
Just need to draw the control @ design time & Perfect!
VB Code:
[color="#0000A0"]Private[/color] [color="#0000A0"]Declare[/color] [color="#0000A0"]Function[/color] SetParent [color="#0000A0"]Lib[/color] "user32" ([color="#0000A0"]ByVal[/color] hWndChild [color="#0000A0"]As[/color] [color="#0000A0"]Long[/color], [color="#0000A0"]ByVal[/color] hWndNewParent [color="#0000A0"]As[/color] [color="#0000A0"]Long[/color]) [color="#0000A0"]As[/color] [color="#0000A0"]Long[/color]
[color="#0000A0"]For[/color] I = UserControl.ContainedControls.Count [color="#0000A0"]To[/color] 1 Step -1
SetParent UserControl.ContainedControls.Item(I - 1).hWnd, warea.hWnd
[color="#0000A0"]Next[/color] I
Thanks RobDog888
-
Sep 25th, 2004, 05:15 PM
#6
Thread Starter
Hyperactive Member
Oh... found a bug and fixed it!
Change the code to :
VB Code:
[color="#0000A0"]Private[/color] [color="#0000A0"]Sub[/color] UserControl_Show()
[color="#0000A0"]If[/color] UserControl.Ambient.UserMode = [color="#0000A0"]True[/color] [color="#0000A0"]Then[/color] [color="#00A000"]' so vb wont crash[/color]
[color="#0000A0"]For[/color] I = UserControl.ContainedControls.Count [color="#0000A0"]To[/color] 1 Step -1
[color="#0000A0"]If[/color] GetParent(UserControl.ContainedControls.Item(I - 1).hWnd) <> warea.hWnd [color="#0000A0"]Then[/color]
SetParent UserControl.ContainedControls.Item(I - 1).hWnd, warea.hWnd
UserControl.ContainedControls.Item(I - 1).Left = warea.ScaleWidth - UserControl.ContainedControls.Item(I - 1).Width
[color="#0000A0"]End[/color] [color="#0000A0"]If[/color]
[color="#0000A0"]Next[/color] I
[color="#0000A0"]End[/color] [color="#0000A0"]If[/color]
[color="#0000A0"]End[/color] [color="#0000A0"]Sub[/color]
-
Sep 25th, 2004, 05:40 PM
#7
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|