|
|
You mean using the move function? I don't want to use that. I want to reset the form position.
<italic>Work hard, Work effectively.
|
|
|
|
|
to reset to where ???? the initial place ?
i think you'll have to store those values first to recall them then...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Open first form position ( 0,0)
open second form (100,100)
third form (200,200)
close all form
open fourth form, it will be (300,300), but I want it to be reset, into (0,0). Got it?
<italic>Work hard, Work effectively.
|
|
|
|
|
Have you looked at the Top and Left properties of your child form?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
Have you looked at the Top and Left properties of your child form?
Yes, what do I have to do with it? The form position it self,when it's opened. I think the parent form must be the one, which calculate the position automatically, like the cascade. How to reset the child position remembered by the parent form?
<italic>Work hard, Work effectively.
|
|
|
|
|
The parent form doesn't remember anything about the child form, other than it exists. Windows picks the default position of the form unless you set the properties of it before you show it.
Dim newChildForm As New Form2()
... other MDI setup stuff
newChildForm.Top = whatever
newChildForm.Left = whatever
newChildForm.Show()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm using VB6 Dave. Like I said before, when I open a form the position will be (0,0), when another from is opened, position will be (100,100), just like the cascade. When I close those two form , and open a new one, the position will be (200,200) not (0,0) (which I want it to be). I gave up, I think there's no way for that. Maybe the only solution is to manually position the form like you said.
<italic>Work hard, Work effectively.
|
|
|
|
|
So...? Nothing changes! All you do is create an instance of your child for, set its position to what you want, then show it. What's problem?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What I want?
Form 1 open (0,0)
Form 2 open (100,100)
form 3 open (200,200)
form 2 close
form 4 open (100,100) <- this is want I want, but the application automatically sets the position to (300,300).
<italic>Work hard, Work effectively.
|
|
|
|
|
What part of "just set the Top and Left properties of the child form before you show it" don't you understand????
Dim newChildForm As New Form2
... other MDI setup stuff
newChildForm.Top = 100
newChildForm.Left = 100
newChildForm.Show()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I understand the Top and Left properties. What I don't understand is the calculation of position, when it is (100,100), when it is (200,200), when (400,400). In other words, what is the position will I put the form. I want the form to be showed like cascade.
<italic>Work hard, Work effectively.
|
|
|
|
|
You'll have to remember the positions of all the child forms, keeping them in an array. Create an array and initialize each element to -1, -1. When you want to add a new child form, you'll have to search through the collection looking for a free "slot", which is represented by -1, 1. Calculating the child form positions isn't hard since each is a constant offset from the previous position. So, if your free "slot" is in array index 2, you just need to multiply that by the X and Y (Top and Left) offsets to get the position of the form. In your example, by 100. Put that position in the array at that index. When a form is closed, you'll have to reset that position in the array to -1, -1.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yeah, I know I can do it. I was just hoping there's a simpler way. Thank you Dave.
<italic>Work hard, Work effectively.
|
|
|
|
|
Does anybody know how I could use a TreeView structure to create a file structure?
In other words, I want to write my TreeView out to a specified location on my C:\ drive and build folders that mimic my TreeView.
…and to make matters even more complicated, each of my folders contains files that need to be moved.
Here is what I have:
I read and existing file structure from my computer drive into a TreeView. I then rearrange the file structure in the TreeView. Now, I need to files to be moved (with their contents) to the new locations.
Thanks
Brad
|
|
|
|
|
I was thinking of something along the lines of:
When a node is selected, write its full path to originalPosition. When a destination is selected, write its full path to newPosition and:
IO.File.Copy(originalPosition, newPosition)
Is there a way to copy/move a file and its contents (including subfolders)?
Thanks
Brad
|
|
|
|
|
I've made a little more progress but now I'm stuck on a drag/drop problem.
Does anybody know how to store the fullpath of a selected node during a drag and drop procedure?
Here is what I have tried (in every variation that I can think of):
Dim originalPosition As String
Private sub [tried several methods]
originalPosition = TreeView1.SelectedNode.FullPath [...tried multiple properties]
End sub
At the start of the drag/drop the original path is stored in originalPosition but after the drag/drop is complete, originalPosition has changed to the new full path.
I don’t understand how this is happening. Does anybody understand the drag/drop procedures enough to see what is going on?
Here is the code that I'm using for the drag/drop:
Public Sub TreeView1_ItemDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TreeView1.ItemDrag
DoDragDrop(e.Item, DragDropEffects.Move)
End Sub
Public Sub TreeView1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragEnter
If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", True) Then
e.Effect = DragDropEffects.Move
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub TreeView1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragOver
If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", True) = False Then Exit Sub
Dim selectedTreeview As TreeView = CType(sender, TreeView)
Dim pt As Point = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y))
Dim targetNode As TreeNode = selectedTreeview.GetNodeAt(pt)
If Not (selectedTreeview Is targetNode) Then
selectedTreeview.SelectedNode = targetNode
Dim dropNode As TreeNode = CType(e.Data.GetData("System.Windows.Forms.TreeNode"), TreeNode)
Do Until targetNode Is Nothing
If targetNode Is dropNode Then
e.Effect = DragDropEffects.None
Exit Sub
End If
targetNode = targetNode.Parent
Loop
End If
e.Effect = DragDropEffects.Move
End Sub
Private Sub TreeView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragDrop
If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", _
True) = False Then Exit Sub
Dim selectedTreeview As TreeView = CType(sender, TreeView)
Dim dropNode As TreeNode = _
CType(e.Data.GetData("System.Windows.Forms.TreeNode"), _
TreeNode)
Dim targetNode As TreeNode = selectedTreeview.SelectedNode
dropNode.Remove()
If targetNode Is Nothing Then
selectedTreeview.Nodes.Add(dropNode)
Else
targetNode.Nodes.Add(dropNode)
End If
dropNode.EnsureVisible()
selectedTreeview.SelectedNode = dropNode
End Sub
|
|
|
|
|
Why dont you store the original full path to TreeNode.Tag (when you are creating the node)?
|
|
|
|
|
|
Well ...
Have a WinApp ... I use a shared function in another class-project to write logs... Same Namespace ofcource.
The thing is I want to write down some properties in log. I want the properties to be VERY global =)) Can I declare some properties wich I can access even from referenced assemblies.
I can pass some arguments to my Log-function but If i can avoid it I'll be happy. Those properties are used all over my app/namespace.
Thnaks for your help //Maw
|
|
|
|
|
MaWeRic wrote:
The thing is I want to write down some properties in log. I want the properties to be VERY global =)) Can I declare some properties wich I can access even from referenced assemblies.
I have no idea what you're trying to say here.
All I can figure out is you have a shared function in a class that writes stuff to a log. Beyond that, I have no idea what your trying to do.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
MaWeRic wrote:
I want the properties to be VERY global =))
If you're using VB.NET, then you can't have globals. Global variables are a disaster, and a hallmark of bad programming. If you want something visible from everywhere, make it static, public, and put it on a class, which is your only option now that VB.NET makes VB an actual OO language, thus dragging it into the 1990's ( kicking and screaming, from what I can see ).
MaWeRic wrote:
I can pass some arguments to my Log-function but If i can avoid it I'll be happy.
If you don't pass them, how will they get there ? Surely you don't want to through away your class structure ( in terms of information hiding ) so that this class can grab whatever it likes from your entire application ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
so that this class can grab whatever it likes from your entire application
Heads on =)) That exactluy what. Make sure that sahred function can get information from MainApp whthout passing them ....
Soo?
//Maw
|
|
|
|
|
If you don't pass anything to the function, how on earth is it going to know what you want?
In order for this to work, EVERYTHING in your app that you want logged would have to be public and static. This is turning into a really bad idea.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, I have to disagree here. It's quite possible to acces private members of other classes using the System.Reflection namespace. Go look it up in the MSDN.
I can also sympathise with the intent of this question. For example, it would be handy if you could just call some kind of Save() function, and have every persistent variable (whether public or private) in your application saved out into an INI file. Then, call Load() and it all gets read in again.
I know it's possible because I've done it.
|
|
|
|
|