moonlightcyber
asked on
transferring controls from one form to another
hello...i have 8 pic boxes on my main form, they serve as resizing handles....i need to use these handles on other forms as well, do i have to copy all the controls to the other forms, or is there another way, without having to copy contyrols and paste them on a form..maybe with a class...
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another option is to create a 'UserControl' containing the 8 picture boxes. You can then treat all 8 as one control. Place the control on any form you want. Use events to tell the form when to respond & what to do. All the code for the picture boxes will be encapsulated in the one 'UserControl'. Any modifications made to the 'UserControl' will modify the control you placed on all the forms. For all practical purposes, a 'UserControl' is a visible class. You can easily 'subclass' other controls capabilities & 'encapsulate' all the code written for this visible component in the 'usercontrol'.
Or, as long as your not going to need them on more than one form at a time at runtime you can use setparent api, just make sure before any form that's unloaded doesn't still have these "setparent" controls on them otherwise...your toast
for a=0 to 7
setparent picture1(a).hwnd,newForm.h wnd
next
make sure you reset set them like this before unloading a form that has them on it
for a=0 to 7
setparent picture1(a).hwnd,0
next
PS If you accept this comment as the answer you were looking for, please let me know because I would appreciate the points.
for a=0 to 7
setparent picture1(a).hwnd,newForm.h
next
make sure you reset set them like this before unloading a form that has them on it
for a=0 to 7
setparent picture1(a).hwnd,0
next
PS If you accept this comment as the answer you were looking for, please let me know because I would appreciate the points.
ASKER
thankyou for your answer hddp666, i have made it work now..!!
but i think i am going to create a user control for it...seems mor efficient....thankyou for your comment vbWhiz...
but i think i am going to create a user control for it...seems mor efficient....thankyou for your comment vbWhiz...
ASKER
johnn, i have already given the poiints away...and i think i am going to use your method, saves me having to create a control. because i don't need them on more than one form at a time....
unhfortunately you replied after i had given the points...but i won't forget.
thankyou
unhfortunately you replied after i had given the points...but i won't forget.
thankyou
hope it helps,