Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996

Dynamically Positioning Controls at Runtime

Question:
It is easy to use control arrays to load controls inside a container. Now the problem is I do not know how many containers e.g., groups of option buttions, I will have until runtime. So the question seems to be how do you dynamically load a control, say an option button and tell it to belong to a dynamically loaded container, say a frame? Any ideas (other than ugly workaround like draw m (>=n) invisible container/controls at design time and make n of them visible at runtime)?

Answer:
The SetParent API call will let you reparent controls to other containers. All controls have a hWnd property, which uniquely identifies the control within Windows. The SetParent function takes two hWnd arguments: the parent's hWnd, and the new child's hWnd. You can look at the documentation in the Windows SDK help file, and here is the decalare statement:

Declare Function SetParent% Lib "user" (ByVal h%, ByVal h%)
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date