Window Form Dilemma

  • Thread starter Thread starter simchajoy2000
  • Start date Start date
S

simchajoy2000

Hi,

I am fairly new to the world of VB.NET form applications and I am
unsure how to approach coding this situation. I have a VB.NET
interface and I need to make it possible for a form, which is from a
separate dll, to popup when the user clicks on a picture in the
interface. I have no idea how to do this.

I am in the process of building the forms which will reside in the
separate dll but I'm not sure how to establish the relationship
between the forms and the interface. Especially since the interface
needs to pass information to the forms and the forms need to pass
information to the interface.

I would love to find an example on the internet that shows how to do
this but any advice would be very helpful. Does anyone have any
ideas??

Thanks!

Joy
 
Ok the word "interface" threw me off for a while, since that means something
different in OO world.

Anyway, what you are trying to do is not that tough.

Your "interface" .. lets call it UI (User Interface), probably is .. nothing
but another form, that displays a picture.

So what is showing the picture? Is it a picturebox? It's gotta be some
control holding the picture. Identify that control first, and then write
code like

AddHandler <<thatcontrol>>.MouseDown, AddressOf(your methodname which will
handle the MouseDownEvent) ..

(NOTE -> The methodname signature must match the delegate .. (I know this is
confusing but intellisense will make it error free .. try it).)

What you just did essentially is that you added a function that will be
called anytime the user clicks on that picture holding control. This method
will most probably have a syntax like MethodName(sender as object, e as
EventArgsDerivedClass)

and e.X, and e.Y will tell you the X and Y positions where the mouse was ..
etc. (should you care to know).

But the main idea is .. "You were able to detect the mouse click and act
upon it" .. GOOD !!

Now popping up the form in a seperate dll -> yes it is possible to put it in
a seperate dll, since a form is nothing but another class.

All you've gotta do in the above MouseHandler function is, create an
instance of that formclass, and do a Form.Show (non-modal), or
Form.ShowDialog (modal).

Thats all there is to it .. and don't forget to dispose the form once you're
done with it .. it really is that simple :)
 
Just add a reference to the dll containing the forms and just call some
code like

Dim s as new OurForm

As for passing information, you can easily do that by passing parameters
to methods in your form class. To get information back, depending on
your architecture, use either ref parameters or delegates
 
I understand that I can pass information back and forth using parameters
however I need the information from the user interface to be displayed
as soon as the form is displayed. So in my mind the best place for that
would be in the New() sub but how would I pass a parameter to the New()
sub??

And I oversimplified my explanation before to try to make it less
confusing - but I basically have a user interface where the user can
drag nodes (which are basically pictures of circles and squares) over to
a document from a palette. And then within the document, the user can
move the nodes around and place them at any point in the user interface.
I can capture the event that takes place when the user clicks on the
node - I just wasn't sure how to make a form that exists in another dll
appear as part of the user interface.

Joy


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Back
Top