Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I found out a cool way to modify a procedure so that you can create your own and add handles a while back after viewing some code on PlanetSourceCode.

 

I used this on one form of my program and honestly I can't say that I care for it.

 

Its a database screen were you're viewing data. When the form is loaded, you disable all of the textboxes so no changes can be made.

 

I had a procedure to do this, with the handle "MyBase.Load"

 

It worked and I did a few more, for the cancel, save and OK buttons.

 

Now I'm starting to realize (after I havn't worked on this particular form for a month) that its really a bear to get everything lined up again, figuring out what went were.

 

I just took out all of the handles and just included calls to the sub procedures instead.

 

Is there one way thats better for some particular reason? Maybe one way has less overhead?

 

I assume its faster/easier for the program to jump directly to the handle than it is to jump to a handle and then to a sub procedure.

Posted

I dont know what you mean when you say "create your own". All the editor does is save you typeing it youself, this is not exactly a new find ;).

 

Whats the difference you say, nothing. You will never notice its such a small command, its probly 1 extra instruction and as your CPU does about 25 million a second im not sure it will care :).

 

In case your interested, just run to the end of the procedure line and add handles me. and you will get a list of all the controls for you to pick from and also classes that are declared globally.

You can actually do some really cool stuff, like move the handle of a control to a different procedure then the one it was defined at designed time. Heres an example.

 

AddHandler Application.ThreadException, AddressOf eh.OnThreadException

 

Also, you can use the same procedure to handle many objectes, ie same event for 2 menus, ones a normal menu, the other is a popup menu.

 

Private Sub mnuDeleteMenu(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mncConnRemove1.Click, mncConnRemove2.Click

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...