Volte
*Experts*-
Posts
2372 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Volte
-
Use the Type.InvokeMember() method to call a method by name. Here is a sample CallByName replacement function: Private Sub MethodByName(ByVal obj As Object, ByVal method As String, ByVal args As String()) Dim t As Type t = obj.GetType t.InvokeMember(method, Reflection.BindingFlags.InvokeMethod, t.DefaultBinder, obj, args) End SubYou need to retrieve the type of the object (object.GetType()) and use its InvokeMember() method to call a member of it. The 'BindingFlags.InvokeMethod' binding flag tells it to invoke the method, and the DefaultBinder for the type is simply used to find the method you are trying to invoke. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MethodByName(TextBox1, "AppendText", New Object() {"Appended Text!"}) End SubThat would append some text to TextBox1.
-
How do I do a right and left shift in vb.net?
Volte replied to Sylonious's topic in Visual Basic .NET
The / 256 part is right, but you can't do data[position++] in VB. :p ... data(position) / 256 position += 1 -
How do I do a right and left shift in vb.net?
Volte replied to Sylonious's topic in Visual Basic .NET
Divide by two is the same as shifting the bits right once, multiply by two is the same as shifting left once. If you have VB.NET 2003, however, VB has << and >> operators. -
Two threads can run simultaneously, meaning you can have two things happening at one. If you put this code: Dim i As Integer Do i += 1 Loop Until bContinue = Falsein your main program, it would freeze it. If you put it inside a second thread, the main thread would still be free to do other things, so the program would run normally. If you learn to use threading properly, it's a very powerful and useful tool.
-
Well, if you are talking strictly about the code you pasted above, it doesn't look like there are any GDI objects being left in memory. You might try calling ReleaseDC on that dcSource object though. I'm not sure if not releasing DCs will cause Out of Memory errors or not.
-
I doubt what you're talking about it directly possible... You can easily start two more threads and have both of the actions happening at once, but having an action stop in the middle of execution will not be possible I think. You can use Thread.Suspend() to suspend execution of your thread, but only once it gets to a safe-point. That means it won't stop in the middle of doing something, it will stop once it gets finished and not continue untill to start it again. You might look into using the SyncLock keyword in VB, however, as it prevents two threads running the same thread procedure from executing the same bit of code at the same time.
-
It sounds like you are probably not cleaning up all of your GDI objects. Make sure you call DeleteObject on all objects you create (pens, brushes, etc), and DeleteDC on all the DCs that you create (not the ones you get by way of GetDC or whatever, thought you should call ReleaseDC() on those to release them).
-
Nope, no typedef in .NET; really, though, there's no need for it. There are no pointers in C# (usually), so there aren't going to be any LPxxxx typedefs, you've got delegates seperately, so there aren't going to be any WndProc (HWND, UINT, WPARAM, LPARAM) style typedefs... Maybe you could tell us why you need typedefs and we'll tell you if there's another way.
-
1) All menus that are part of an MDI child will be merged with the menu in the MDI parent. 2) No.
-
Are you positive the filename exists? Perhaps you should post some more related code.
-
When a loop is running continuously, your CPU % will most likely jump to near 100%. There really isn't any way to avoid that. It may not affect performance, but it will kick the CPU usage gauge up. You could make a second thread in your application and put the loop code in that. Then you wouldn't require a DoEvents, so it may be quicker.
-
There's no handler to do it, really... I think your way is probably the only decent way to do it (unless you want to try Threading, but I don't think that will be necessary). BTW, those GC.Collect()'s aren't needed. The GC won't collect objects until you are completely done with them, so it won't matter. You need to use the 'Dispose' method of the objects before the garbage collector will touch them (if you don't use it, the GC will pick them up when the object is destroyed).
-
I know that, but C# doesn't even provide those options, so VB.NET can be confusing to newbies who don't know what is considered "correct". I mean, there's nothing wrong with coding in VB.NET as long as you know what you're doing, otherwise you can get bogged down in the "extra" options VB provides you which should generally be avoided.
-
I must admit, I quite dislike VB.NET. I prefer C style syntax I guess. There are other reasons, though: VB.NET provides all kinds of backwards compatability features with VB6 that allows you to do all kinds of messy stuff; C# doesn't have that (that's a good thing, it keeps your code clean :)) C# allows more control over your code structure. VB.NET removes all the excess whitespace from your code, doesn't have block comments and allows you to carry on code with blank lines, while in C# you can lay it out however you like The only thing I don't like about C# is adding events to classes; you need to define both a Handler delegate and a Args class to call an event with custom parameters, where in VB it's a simple Event line. If you are just starting out, or are converting to .NET from VB6, I would really recommend starting with C#; it forces you away from the VB syntax (so bad habits won't persist) and removes you from all those awful compatability functions .NET provides.
-
It's System.Drawing.Font in .NET. Note that the architecture of .NET is totally different than VB6, so it is not the same exact Font class as VB6's. To create public variables, but them in a class as being shared: Class Declarations Public Shared publicVar As Integer End ClassThen, from any form you can access it with 'Declarations.PublicVar'.
-
You can change the Value property to reflect the new date. For exampleDateTimePicker1.Value = DateTimePicker1.Value.AddMonths(1)go to the next month. You can use AddSeconds, AddDays, etc, and if you give it a negative value, it will subtract them. So AddDays(1) and AddDays(-1) is probably what you need.
-
Actually, the better way to do it is this: Process.Start("http://blah")Rather than explicitly starting IEXPLORE. If you "run" a document with Process.Start it will open in the default associated app. You also don't need to create a new instance of a Process, unless you plan to handle its events. Oh, and it's VolteFace. :mad: :D :D
-
Memory leak - drawing images with BitBlt
Volte replied to aewarnick's topic in Graphics and Multimedia
Well, it seems like it should be alright... perhaps using the API so much (I assume you are using it in some sort of loop, meaning calling it very often) it taking its toll on .NET... it is unmanaged afterall. divil would know better than I on this one, I think. -
Memory leak - drawing images with BitBlt
Volte replied to aewarnick's topic in Graphics and Multimedia
That doesn't seem right... paste your code again, let me make sure there are no leaks. -
You can't, but I did an Ownerdrawn menu in my IExtenderProvider example (look in the Code Library for that). You can look at the code and see how to ownerdraw menus (it's for MainMenus, but the MenuItems are the same).
-
You need to modify the constructor of Form2 (that's the New() sub) to accept a form as a parameter. So modify it to look like this:Public Sub New(caller As Form) MyBase.New() InitializeComponent() m_fCaller = caller ' You must define m_fCaller as a class level variable first End SubThen, when you create the form on Form1, do this: Dim f2 As New Form2(Me) f2.Show()When you wish to close both forms, in Form2, do this: m_fCaller.Close() Me.Close()
-
Memory leak - drawing images with BitBlt
Volte replied to aewarnick's topic in Graphics and Multimedia
Yes, that's correct. And also, don't worry about the memory taking awhile to show up; memory allocated within a .NET app probably won't be really free until the Garbage Collector frees it up. -
... VB.NET doesn't use HTML... :confused: Perhaps you would like to use the LinkLabel control? Also, you can use Process.Start("http://www.blah.com")to open the default browser to that page...
-
Memory leak - drawing images with BitBlt
Volte replied to aewarnick's topic in Graphics and Multimedia
Replace the first SelectObject line with the second one, and then remove the second one from the bottom; once you use SelectObject, the handle in the DC changes, so SelectObject() will not return the same thing it did last time you used it. It basically sticks what you tell it to into the DC and returns what used to be there. If you don't do anything with it, you can't get it back later, because the new object is now in the DC, so SelectObject will return that. -
BitBlt draws transparent pieces of Image Blue!!
Volte replied to aewarnick's topic in Interoperation / Office Integration
Ohhh, I see what you mean. No, you can use gradients *behind* the image. A mask just uses white areas for the parts of your sprite image you want transparent and black areas for the solid bits. Read the tutorial, and you'll see. :)