Plot on frm A when frm B is closed

SSb

Member
Joined
Sep 28, 2005
Messages
14
Programming Experience
Beginner
Hi all,
In one of my programs I have a form A which remains maximized throughout. By clikcing on a button on this form another form B comes up (using ShowDialog) covering part of form A. The user enters some data in this form and then clicks "Ok". After which form B closes.

What I would like to do is, when form B closes some plots be made on form A. By passing variables between the two forms I'm able to generate the data and make the plots when the user clicks a button "Plot" on form A.

How can I do this (call the plotting function and make plots) automatically when form B is closed i.e. when user clicks "Ok" on form B, without having the user to click "Plot" on form A?

Thanks,
Saurabh
 
Ok, so what you need to do here is get everything in 'screen' co-ordinates NOT client co-ordinates. A form has a couple of methods for doing this..

VB.NET:
PointToScreen
 
RectangleToScreen


These will either covert the given point in the methods argument into screen co-ordinates. Once you have this its just a matter of placing a 'friend property' in form b to hold the point or rectangle. In your case i would use a rectangle seeing as it's a 'plot' that you want. When you click the button/plot in formB pass the buttons client retangle property to your new property. Then when closing formb set a private variable of the type rectangle to the property in formb....Something like....


VB.NET:
FormB
 
Private _plotRectangle as rectangle = rectangle.empty
 
Friend Readonly Property PlotRectangle as rectangle
Get
Return me._plotRecatngle
End Get
End Property
 
'ButtonClick
 
me._plotrectangle = me.Button.clientrectangle
 
 
FormA
 
Private ScreenPlotRectangle as rectangle = rectangle.empty
 
Dim FrmB as new formb
Frmb.showdialog
Me.ScreenPlotRectangle = me.rectangletoscreen(frmb.plotrectangle)
frmb.dispose
Or something like that.
 
Back
Top