[AccessD] Resize Event / maximized

Charlotte Foust charlotte.foust at gmail.com
Fri May 6 19:50:19 CDT 2011


Set the variable to False in the Open event, then set it to true in
the resize event.  Test for the value in the resize event and if it's
false, run the code and set it to true. Is that clearer?  I'm assuming
you only want to call this when the form first loads, not if the user
resizes it.

Charlotte Foust

On Fri, May 6, 2011 at 2:17 PM, William Benson <vbacreations at gmail.com> wrote:
> Hi Charlotte ....
> I do not follow you. Since the application is calling the event an
> indeterminate number of times I don't know where to set the variable to
> True. And where to set it to False.
>
> I want the procedures to run once on Form Load and then again only any time
> the user changes the form size by any means EXCEPT merely deactivating and
> reactivating the form.
>
> I have struggled with this for hours. I did have a IgnoreResize variable
> which I would set to true in the Load event.... and then set to False before
> exiting Resize event. but because it passes through resize event up to three
> times when form is maxed then some unwanted repetitions happen.
>
> I think some of my code inside the Resize event that is altering the
> insidewidth, optimizing widths of certain controls, and proportioning
> distances between some controls is causing Resize to get called again. Not
> sure...very hard to debug. For example I use CreateForm to create a hidden
> form with a label that I can SizeToFit to assist with determining the
> optimal width of some controls on my other form that got resized by the user
> or on Load. This causes my main form to be deactivated I suppose, triggering
> the Resize event on the main form. Again ....hard to know what the code is
> doing to form focuses in the runtime because I can't get the same behaviors
> I'm debug mode than when not debugging.
>
> I am soon to skip the whole resize event and add a button for optimizing
> form insidewidth and the position of controls. I am just too inexperienced
> and impatient.
> On May 6, 2011 1:29 PM, "Charlotte Foust" <charlotte.foust at gmail.com> wrote:
>> Resize may fire more than once, because it DOES remember the last
>> window setting but it doesn't go straight to that setting. It passes
>> through other settings to get there. In addition to your unloading
>> variable, you need a resize variable at the form level that you set
>> when you open the form. Test for the variable in the routine where
>> you want to run you code, and only run it if the variable is false.
>> Set the variable to true and your code won't run again until the form
>> is reopened.
>>
>> Charlotte Foust
>>
>> On Fri, May 6, 2011 at 6:51 AM, William Benson (VBACreations.Com)
>> <vbacreations at gmail.com> wrote:
>>> Hi,
>>>
>>> I have been playing with some code which is meant to run when a form is
>>> resized. I have this code, on a test form.
>>>
>>> Option Compare Database
>>> Option Explicit
>>> Dim mbUnloading As Boolean
>>>
>>> Private Sub Form_Load()
>>>     Debug.Print "Load"
>>> End Sub
>>>
>>> Private Sub Form_Resize()
>>>     If mbUnloading Then Exit Sub
>>>     Debug.Print "Resize"
>>> End Sub
>>>
>>> Private Sub Form_Unload(Cancel As Integer)
>>>     Debug.Print "Unloading"
>>>     mbUnloading = True
>>> End Sub
>>>
>>>
>>> The result in the immediate window varies based on the size condition the
>>> form had at last time it was closed. If the form was not maximized, the
>>> resize event is called only once according to the immediate window
> results.
>>> But if the form WAS maximized at the time it was last closed, the word
>>> "Resize" appears 3 times in the immediate window. WOW. That means it is
>>> running my code in that event in triplicate. Any idea why?
>>>
>>> Also, if I put DoCmd.Maximize in the Load event, then whether the form
> had
>>> last been closed maximized or not, the Resize Event is fired three times
> on
>>> form Load. That as opposed to only once if I had DoCmd.Maximize in a
> button
>>> click event and clicked it - then it occurs only once. So, any idea why
>>> Maximizing during the Load event makes Form_Resize be called three times
>>> instead of twice? In fact,  since multiple clicks of the command button
> that
>>> maximizes will not cause the Resize event to fire, it makes no sense to
> me
>>> that when the form had last been closed in Maximized window, Resize
> should
>>> be called any more than ONCE during this procedure:
>>>        Private Sub Form_Load()
>>>             DoCmd.Maximize
>>>        End Sub
>>>
>>> --
>>> AccessD mailing list
>>> AccessD at databaseadvisors.com
>>> http://databaseadvisors.com/mailman/listinfo/accessd
>>> Website: http://www.databaseadvisors.com
>>>
>>
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>




More information about the AccessD mailing list