|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Hi
I have a vb form (VB6 SP5) and I have some code in the _Resize event. Until now its been dynamic (i.e. just called straight from the resize) but I'm wondering if I should change that, because it can be very slow (Its re-drawing a Regis graph) What's the best way to do this? Basically I'd like to be able to resize the form, and see the size/shape of the form, but not re-plot the graph until the user lets go of the mouse button. Any ideas? Cheers Rob Rob Kings wrote:
> I have a vb form (VB6 SP5) and I have some code in the _Resize event. You'll want to subclass the form, and react in response to WM_SIZING (sent as the> Until now its been dynamic (i.e. just called straight from the > resize) but I'm wondering if I should change that, because it can be > very slow (Its re-drawing a Regis graph) > > What's the best way to do this? Basically I'd like to be able to > resize the form, and see the size/shape of the form, but not re-plot > the graph until the user lets go of the mouse button. border is adjusted) and WM_SIZE (sent when resize is complete). Karl
Once again many thanks. Rob Show quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:uY7qivkVFHA.3152@TK2MSFTNGP12.phx.gbl... > Rob Kings wrote: >> I have a vb form (VB6 SP5) and I have some code in the _Resize event. >> Until now its been dynamic (i.e. just called straight from the >> resize) but I'm wondering if I should change that, because it can be >> very slow (Its re-drawing a Regis graph) >> >> What's the best way to do this? Basically I'd like to be able to >> resize the form, and see the size/shape of the form, but not re-plot >> the graph until the user lets go of the mouse button. > > You'll want to subclass the form, and react in response to WM_SIZING (sent > as the > border is adjusted) and WM_SIZE (sent when resize is complete). > -- > Working Without a .NET? > http://classicvb.org/petition > > "Rob Kings" <r**@greeneggsandham.greymouse.co.uk> wrote For those that might for whatever reasons not want to subclass a form, a> I have a vb form (VB6 SP5) and I have some code in the _Resize event. Until > now its been dynamic (i.e. just called straight from the resize) but I'm > wondering if I should change that, because it can be very slow (Its > re-drawing a Regis graph) > > What's the best way to do this? Basically I'd like to be able to resize the > form, and see the size/shape of the form, but not re-plot the graph until > the user lets go of the mouse button. > > Any ideas? simply delay method can be effective.... With a Timer on a new form, paste in the code below; LFS Option Explicit Private ResizeDelay As Long Private Sub Form_Load() Timer1.Interval = 30 End Sub Private Sub Form_Paint() If ResizeDelay = 0 Then Form_Resize End Sub Private Sub Form_Resize() ' Start delay process If ResizeDelay = 0 Then Cls ResizeDelay = 8 Timer1.Enabled = True End Sub Private Sub Timer1_Timer() ' Count down delay counter ResizeDelay = ResizeDelay \ 2 If ResizeDelay = 0 Then ReDrawAll Timer1.Enabled = False End If End Sub Private Sub ReDrawAll() Dim rad As Long If ScaleWidth < ScaleHeight Then rad = ScaleWidth * 0.4 Else rad = ScaleHeight * 0.4 End If DrawWidth = ((rad + 10) ^ 0.45) Circle (ScaleWidth \ 2, ScaleHeight \ 2), rad, vbYellow Line (0, 0)-(ScaleWidth, ScaleHeight), vbBlue Line (ScaleWidth, 0)-(0, ScaleHeight), vbBlue Circle (ScaleWidth \ 2, ScaleHeight \ 2), rad \ 2, vbYellow End Sub Larry
Another useful post. I'd tried Karl's sub-classing idea using some code from http://vbnet.mvps.org/index.html?code/subclass/minmaxinfo.htm but I hit the usual problem. I got stuck in the IDE and then there was no way out. Having said that, debugging with Timers is a pain too. Anyhow, it seems to be working OK. I might try and "optimise" it, by only imposing the delay if I know that the graph is above a certain size which I can detect as I'm plotting from a string of ReGIS commands. Cheers Rob Show quote "Larry Serflaten" <serfla***@usinternet.com> wrote in message news:uL0VB$mVFHA.2768@tk2msftngp13.phx.gbl... > > "Rob Kings" <r**@greeneggsandham.greymouse.co.uk> wrote > >> I have a vb form (VB6 SP5) and I have some code in the _Resize event. >> Until >> now its been dynamic (i.e. just called straight from the resize) but I'm >> wondering if I should change that, because it can be very slow (Its >> re-drawing a Regis graph) >> >> What's the best way to do this? Basically I'd like to be able to resize >> the >> form, and see the size/shape of the form, but not re-plot the graph until >> the user lets go of the mouse button. >> >> Any ideas? > > > For those that might for whatever reasons not want to subclass a form, a > simply delay method can be effective.... > > With a Timer on a new form, paste in the code below; > > LFS > > > Option Explicit > Private ResizeDelay As Long > > Private Sub Form_Load() > Timer1.Interval = 30 > End Sub > > Private Sub Form_Paint() > If ResizeDelay = 0 Then Form_Resize > End Sub > > Private Sub Form_Resize() > ' Start delay process > If ResizeDelay = 0 Then Cls > ResizeDelay = 8 > Timer1.Enabled = True > End Sub > > Private Sub Timer1_Timer() > ' Count down delay counter > ResizeDelay = ResizeDelay \ 2 > If ResizeDelay = 0 Then > ReDrawAll > Timer1.Enabled = False > End If > End Sub > > Private Sub ReDrawAll() > Dim rad As Long > If ScaleWidth < ScaleHeight Then > rad = ScaleWidth * 0.4 > Else > rad = ScaleHeight * 0.4 > End If > DrawWidth = ((rad + 10) ^ 0.45) > Circle (ScaleWidth \ 2, ScaleHeight \ 2), rad, vbYellow > Line (0, 0)-(ScaleWidth, ScaleHeight), vbBlue > Line (ScaleWidth, 0)-(0, ScaleHeight), vbBlue > Circle (ScaleWidth \ 2, ScaleHeight \ 2), rad \ 2, vbYellow > End Sub > > > > Rob Kings wrote:
> Larry Make sure that you put code in such that if you are in the IDE, the> > Another useful post. > > I'd tried Karl's sub-classing idea using some code from > http://vbnet.mvps.org/index.html?code/subclass/minmaxinfo.htm but I > hit the usual problem. I got stuck in the IDE and then there was no > way out. subclassing does not happen. Include this code in the module to check. Private Function InIDE() As Boolean Debug.Assert Not TestIDE(InIDE) End Function Private Function TestIDE(Test As Boolean) As Boolean Test = True End Function -- Regards, Michael Cole |
|||||||||||||||||||||||