I suck at explaining, I will delete the video once i have an answer, but can someone tell me what it is im doing wrong?
im using the new clipboard item from docs
Dim c As New Clipboard
MsgBox Me.Text
c.Text =me.Text
c.Close
except, its not working as intended.
The inner window is a container, instantiated everytime the user double clicks a client name, so theres no past properties used, no global variables that would save last seen data…yet its somehow reverting back
Me.Text is not the current text. It is the text contained in the owning Control (the control where the code - above - reside).
So, you store the Text of a Control (TextField/TextArea or Label ?), probably not what you want.
You got two message boxes the second time. It’s not reverting, it’s happening more than once.
If you try a third contact, do you get three message boxes?
It could be that you’re not closing the previous container, and the click is going through to the one no longer in view.
I checked youtube and the only box i didn’t mark was that content never aired on US television - Distribution set to everywhere. Sorry, my loss I guess.
@Tim Parnell - Yes, 3 boxes appear.
OK. So, I assume I’m not closing the container. But can someone explain why that matters here?
So, I’ve been learning about how to dynamically draw and embed things into a canvas. It’s allowed me to really make things flexible and less cluttered.
this container is an embedded container. Not actually added to the window.
dim cc as new containername
canvas1.embed(cc)
how do I programatically close the previous container when its not a global variable? I thought when you “Dim” something as “NEW” with the same name that it overwrites it…
I’m guessing that it does overwrite it, but the canvas had it embedded before, so that means It’s still embedded even though a new instance of the same name is embedded.
ALL my containers are embedded by the name “cc”
Yet that makes no sense to me. If I dim something as new with the same name and embed it - why wouldn’t it just overwrite whatever was there to begin with?
OK so maybe I don’t need to “close” the cc… since it overwrites in program.
Its the canvas I have to worry about right? how do I refresh the canvas as a clean slate?
As I put the cursor towards the top of the window, I see the resize column icon appear even though no list-box is there. So it is confirmed, the canvas always has whatever was embedded last on it. New embeds just overlap it. EVEN if what you embed on the canvas has the same name.
so Why is this the case?
and How do I clear the canvas?
You’re using MouseDown, so since the control still exists underneath it’s MouseDown event is still firing. You need to close the containers when they’re not in view, you’re wasting the memory for each container opened and then not closed.
Maintain a reference to the ContainerControl you’re instancing and embedding. When the user navigates away from the detail view, close the container.
Yes.
Not so close. The instance that’s embedded stays in scope, embedded into the window. The variable you’d used to do so is your last accessible reference to it. You should store that reference before replacing it. If you destroy the reference but not the embedded container you have to reacquire a reference to the container which isn’t as easy as just keeping the reference in the first place.
You need better variable names if you want to understand the code in six months.
When you embed the control into a window, you’re adding the control to a window. What you’re doing is not removing that control from the window. You’re just missing a step.
Yes. You do. It does not get “overwritten” since you’re embedding it.
You need to remove the canvas, and embed properly into the window.
Canvas.Invalidate will cause another Paint event, but it’s likely not what you actually want.
And frankly I’m surprised you’re getting mouse events for a container embedded into a canvas. I would have expected embedding into a canvas to embed as an image, and not usable controls.
You can create scrolling for containers with just a pinch of extra effort. Adjusting the .Top of the container to be scrolled will do the trick. Whether you need a containing container or if it’ll work on the window itself depends on the case. I would be curious if there are system level benefits to doing so.
@Tim Parnell is the one who answered the question, Thank you for the time you spent helping a noob.
If you embed a Container Control in a Canvas, or anywhere dynamically, and you are embedding that container - you have to close it before embedding another in the same place - or risk issues such as code firing multiple times.
Create a global property as Container Control (Ie. ccx | ContainerControl)
Embed, but be sure to assign the embedded container…
Dim cc as new MyContainerControlName // Create a new instance of your Container Control
ccx=cc // Assign your new instance to the ContainerControl Property
cc.EmbedWithin(Canvas1,0,0,Canvas1.width,canvas1.Height) // Embed your Container Control
Now you can call the close event from anywhere… even at the start of your method.
ccx.close()
IF you place the code to close a container at the beginning of a method that loads a number of containers to the same canvas, remember that when the application first starts, no container exists and the close event will result in a NilObjectException.
Create a global property as integer with a default of “0” (Ie. ccx_isopen | 0)
Create an IF statement to check if any container has been created yet…
If ccx_isopen=0 then
ccx_isopen=1
else
ccx.close()
end