Jump to content
Xtreme .Net Talk

snarfblam

Leaders
  • Posts

    2156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by snarfblam

  1. Are you looking for something like Environment.GetFolderPath()? The application will run in the bin folder unless you copy the EXE somewhere else. That is your application's folder.
  2. On the mousedown event, I would store a reference to the node returned by TreeView.GetNodeAt(e.X, e.Y), since the node under the mouse cursor is the one that will be selected, then on the context menu handlers (or wherever else you need) use that node you got from TreeView.GetNodeAt(e.X, e.Y) instead of TreeView.SelectedNode(). Sometimes what I do to simplify things is just select the node that they right-click in the mousedown event, i.e. TreeView.SelectedNode = TreeView.GetNodeAt(e.X, e.Y)
  3. To force itself to repaint? You can invalidate the form (i.e. Me.Invalidate or this.Invalidate())
  4. I'm curious. What are other people's memory usage for devenv.exe. I have a good amount of RAM (1 gig), so it wouldn't surprise me to see mine a little higher than average. I am currently workin on an app, though, and devenv.exe starts out at 25 megs (with my solution open). Each time I build and run a debug (windows forms app), the memory usage shoots way up (300+ megs after a few builds). This is causing other memory hungry apps (photoshop for example) to crash, and my PF usage is almost 700 megs.
  5. Careful with that GC.Collect, it can push objects still referenced into a later garbage collection generation. These "survivors" are then about an order of magnitude less likely to be restored to the heap on the next garbage collection. Are you noticing slowdown? Lots of (performance effecting) pf usage? Or just a big number in the task manager? Those big numbers scare me, but we are supposed to trust the garbage collector to do its job and play nice. It's not our job to manage memory (beyond disposing and freeing references); that's left up to the framework. Make sure you are freeing all references, and properly disposing your objects. The memory may not be reclaimed until the GC determines that an app (yours or any other) needs it, so pay more attention to noticable performance issues than numbers in the task manager.
  6. The function takes these parameters? GameStat.ServerInfo.Query(System.Type, String) Or GameStat.ServerInfo.Query(GameStat.GameType, String)
  7. Although you can shadow functions in VB even if they have different signatures or return types, since you aren't overriding them, they are still accessible. If you inherit ArrayList and shadow the methods, you could still do either of the following to access the original methods that allow adding objects: DirectCast(MyInheritedClass, ArrayList).Add(MyObject) or DirectCast(MyInheritedClass, IList).Add(MyObject). I personally stay away from shadowing as much as possible. It makes it very easy to accidentally call the wrong function, and sometimes difficult to dubug. When I've needed strongly typed collections in the past, I've actually made my own classes that manage memory in the same manner as the ArrayList, and I implemented IList and IEnumerable myself.
  8. Have you tried it to see what result you get?
  9. Does the code appear to be exactly equivalent?
  10. Can't you specify working directory in a shortcut? Using an exe in place of a shortcut seems like overkill to me.
  11. Everyone has a right to their own opinion, and I respect yours, but I personally think that spying on employees in such a manner is an invasion of privacy and sets a disconcerting precedent. Not that I don't understand your predicament, but I think it would be better to find a less devious solution. You can use one of the following functions to get an instance of the Process class that might be helpful. System.Diagnostics.Process.GetProcesses() System.Diagnostics.Process.GetProcessesByName() System.Diagnostics.Process.GetProcessById() If you want your app to start when the user opens another app, well I don't know how to do that.
  12. You are not overriding the functions, you are hiding it (in VB its called shadowing, i don't think C# uses this term). In C# the new keyword, when used with a function or property, causes the function or property by the same name and with the same signature in the base class to be hidden. The UserControl.Width and UserControl.Height properties still exist in your user control, but are hidden by your new Width and Height properties. These shadowed, or hidden, properties can still be accessed, however, and the designer is setting the UserControl.Width property instead of the XYZButtonPane.Width property. I don't know if this is the best way to do what you want to do, but you could just resize pnlBorder in a Resize event handler of your base class.
  13. Thats... decompiled to C#. Try this: Sub KillProcesses() Dim Proccesses As System.Diagnostics.Process() = _ System.Diagnostics.Process.GetProcessesByName("IEXPLORE") Try For Each Process As System.Diagnostics.Process In Proccesses Process.Kill() Next Catch Finally For Each Process As System.Diagnostics.Process In Proccesses Try Process.Dispose() Catch End Try Next End Try End Sub
  14. The Items property is readonly, so of course you can't do lv2.Items=lv1.Items. You can't do lv1 = lv2 because then your just setting your variable, lv2, to point to a whole different listview: lv1, not a different set of listview items. This is a way you could copy list view items from one listview to another... 1 'Assuming you have two listviews, named lv1 and lv2... 2 Dim MyItems As ListViewItem() = New ListViewItem(lv1.Items.Count-1) 3 lv1.Items.CopyTo(MyItems) 4 lv1.Items.Clear 'You CANT have a listview item in more than one listview at a time 5 lv2.Items.AddRange(MyItems) Notice line 4. If you want to have the items appear in both listviews simultaneously, as far as I can see, you must iterate through them and clone each one. And if you don't need them in both listviews at once (if, for instance, the listviews are on separate forms and only one is displayed at a time) you could conceivably remove the listview from one form and add it to the other. Another thing you could do is just populate both listviews at the same time. If you can't do any of those, you can always use for loop and slap up a progress bar.
  15. Yes... your program must be running on order to detect that a file has changed using the FileSystemWatcher class. If you need to detect if the file changed between instances of your app, you could concievably copy the file when the app is run and next time it is run, compare the copied file to the origional.
  16. I tried this and did not have the same problem. Did you create the emf? It is possible that your emf contains raster images. If you are certain it does not, perhaps you can store the emf to an image object and when the picturebox control is resized, re-set the image property to a clone of the original emf image object. I'm pretty sure that the picurebox does not rasterize metafiles though.
  17. The System.Environment.GetCommandLineArgs() function returns an array of strings that contain the command line arguments passed to the application. 'VB Example: If System.Environment.GetCommandLineArgs()(0).ToUpper() = "-AUTORUN" Then 'Do what you need to do Else 'Prompt the user for options Endif
  18. "Window list" was the name used in VB6. In .Net it is "MDI list," so I suppose I should have said that. Anyways, if you don't know what I'm talking about, add a new top level menu item to your mdi parent, and set the "MdiList" property to True, run the app, open some mdi children, then click the menu item on the menu bar.
  19. Is there any reason why you can't just use a window list? If so I would have the mdi parent handle child form's close and activate events and handle all the menu functions within the parent form.
  20. Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picSmile.Click 'These two lines of code dont belong here. ' System.Object, ByVal e As System.EventArgs)_ ' Handels(picSmile.Click) picSmile.BorderStyle = _ 'You need a SPACE before a line continuation underscore System.Windows.Forms.BorderStyle.FixedSingle '() 'And the parentheses are a syntax error, as PlausiblyDamp pointed out picFrown.BorderStyle = _ System.Windows.Forms.BorderStyle.None '() picHappy.BorderStyle = _ System.Windows.Forms.BorderStyle.None '() lblMessage.Text = "Hello, world!" End Sub
×
×
  • Create New...