At the moment I have quite a few controls that are children of an IDE drawn rectangle. So far this has worked great. I’m able to position the controls within, then move the rectangle, and all moves with it, as it should.
The rectangle was only ever meant to be a “placeholder” for visual and positional purposes. Now I’ve reached the point in my program where it needs to be replaced by a bitmap image which will be drawn underneath on the main window in the paint event using PixmapShape - along with a few other images that are already there.
I’m hoping that somehow in code, I can “un-parent” the rectangle, make it invisible (but not the controls within) and therefore show the image underneath and retain the rectangle for it’s positioning purposes for the IDE only.
Mostly I do read the documentation Markus - and also search the forum. That’s why I haven’t posted a question on this forum for the last few weeks or so. Everything with my software is coming along just great, but unfortunately sometimes you have to interact with the humans. Also, I was being lazy. Sorry.
When you do program then you should have the documentation open too. First thing to do when having a question about the parent property is to look at the documentation for that property. I have a VERY bad memory, so I flick backwards and forward between the IDE and the documentation all the time. Quite often the documentation also gives me ideas on how to do things better. That being said I still use the old documentation as I absolutely hate the new one.
You could do something like this in the Open event of the window…
for i as integer = 0 to self.ControlCount-1
dim c as Control = self.Control(i)
if c = rectangle1 then Continue
if c isa RectControl then
dim rc as RectControl = RectControl(c)
if rc.Parent = rectangle1 then
rc.Parent = nil
I’ve written this to be rather verbose so it’s clear what’s going on. Rectangle1 being the name of your Rectangle control.
Well now that’s indeed getting into the “nitty gritty” of it all :).
So when you say the Open event of the window, you mean the window that contains all the controls - my rectangle1 and any other controls.
Your code then interrogates “all” the controls within that window, and if they are a child of my rectangle1 then they are released, ie. rc.Parent = Nil. Much quicker than individual code for each control.
I think I get it. It’s getting late here now, I’ll check back and test tomorrow.
Your code works perfectly. In my view it’s really a quite powerful piece of code. I did do some reading ie. Parent = Nil, ControlCount and RectControl and then made an effort to understand your code, I do get it mostly. Just wanted to let it be known that I didn’t just cut & paste.
I would have been blundering around for who knows how long and just ended up manually doing it. I can see potential in using this method - always.