From: Mike S on
On 6/20/2010 10:00 PM, mp wrote:
> "GS"<gesansom(a)netscape.net> wrote in message
> news:hvmq3m$quu$1(a)news.eternal-september.org...
>> Mark,
>> You don't have to duplicate anything! You can just expand on the sample I
>> gave you for processing the 3 UDTs I use in every project, on an 'as
>> needed' basis. So, unless Larry comes up with some way to pass the UDT
>> ByRef to the class, you'll have to settle for using the array of variants.
>>
>> --
>> Garry
>>
>> Free usenet access at http://www.eternal-september.org
>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>
>>
>
> I'm clear that there are two ways to store the data, udt or class.
> I've tried them both and like them both.
> I'm trying the class for now and am reading and writing the values to disk,
> but the form is not taking it's last saved position for some reason.
> start program
> class reads values from disk (top, left, height, width)
> form assigns it's properties to those values
> this should put it where it was when last closed, but it never moves, always
> appears in default position...don't know what i'm doing wrong
> guess this is evolving into a different thread?
> 'in form initialize
> Private Sub Form_Initialize()
> 'snip error trapping and logging calls
> Set FormSettings = New cFormSettings
> FormSettings.Filename = App.Path& "FormSettings.txt"
>
> 'read former form position and size from file
> FormSettings.ReadFile
>
> 'this should make the form move to where it was before, but it doesn't
> Me.Left = FormSettings.Values(eSettings.FormLeft)
> Me.Top = FormSettings.Values(eSettings.FormTop)
> Me.Width = FormSettings.Values(eSettings.FormWidth)
> Me.Height = FormSettings.Values(eSettings.FormHeight)
>
> ExitHere:
> 'Form_Initialize = bSuccess
>
> ProcEnd ProcName
> On Error GoTo 0
> Exit Sub
>
> Form_Initialize_Error:
> LogError , ProcName
> Resume ExitHere
>
>
> End Sub
> 'in form resize
> Private Sub Form_Resize()
> ResizeFolderViews'adjust controls
>
> 'get new form location values into class
> FormSettings.Values(FormLeft) = Me.Left
> FormSettings.Values(FormWidth) = Me.Width
> FormSettings.Values(FormHeight) = Me.Height
> FormSettings.Values(FormTop) = Me.Top
>
> End Sub
>
> 'in form terminate
> Private Sub Form_Terminate()
> 'leaving out error trapping and logging code
> FormSettings.WriteFile 'class writes values to file
> Set FormSettings = Nothing
> ExitHere:
> Unload Me
> On Error GoTo 0
> Exit Sub
> End Sub

What do you have the Form StartupPosition set to?

From: mp on

"mp" <nospam(a)Thanks.com> wrote in message
news:%23q$zt6PELHA.588(a)TK2MSFTNGP06.phx.gbl...
>
> "GS" <gesansom(a)netscape.net> wrote in message
> news:hvmq3m$quu$1(a)news.eternal-september.org...
>> Mark,
>> You don't have to duplicate anything! You can just expand on the sample I
>> gave you for processing the 3 UDTs I use in every project, on an 'as
>> needed' basis. So, unless Larry comes up with some way to pass the UDT
>> ByRef to the class, you'll have to settle for using the array of
>> variants.
>>
>> --
>> Garry
>>
>> Free usenet access at http://www.eternal-september.org
>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>
>>
>
> I'm clear that there are two ways to store the data, udt or class.
> I've tried them both and like them both.
> I'm trying the class for now and am reading and writing the values to
> disk,
> but the form is not taking it's last saved position for some reason.
> start program
> class reads values from disk (top, left, height, width)
> form assigns it's properties to those values
> this should put it where it was when last closed, but it never moves,
> always appears in default position...don't know what i'm doing wrong
> guess this is evolving into a different thread?
> 'in form initialize
> Private Sub Form_Initialize()
> 'snip error trapping and logging calls
> Set FormSettings = New cFormSettings
> FormSettings.Filename = App.Path & "FormSettings.txt"
>
> 'read former form position and size from file
> FormSettings.ReadFile
>
> 'this should make the form move to where it was before, but it doesn't
> Me.Left = FormSettings.Values(eSettings.FormLeft)
> Me.Top = FormSettings.Values(eSettings.FormTop)
> Me.Width = FormSettings.Values(eSettings.FormWidth)
> Me.Height = FormSettings.Values(eSettings.FormHeight)
>
> ExitHere:
> 'Form_Initialize = bSuccess
>
> ProcEnd ProcName
> On Error GoTo 0
> Exit Sub
>
> Form_Initialize_Error:
> LogError , ProcName
> Resume ExitHere
>
>
> End Sub
> 'in form resize
> Private Sub Form_Resize()
> ResizeFolderViews'adjust controls
>
> 'get new form location values into class
> FormSettings.Values(FormLeft) = Me.Left
> FormSettings.Values(FormWidth) = Me.Width
> FormSettings.Values(FormHeight) = Me.Height
> FormSettings.Values(FormTop) = Me.Top
>
> End Sub
>
> 'in form terminate
> Private Sub Form_Terminate()
> 'leaving out error trapping and logging code
> FormSettings.WriteFile 'class writes values to file
> Set FormSettings = Nothing
> ExitHere:
> Unload Me
> On Error GoTo 0
> Exit Sub
> End Sub
>

ok, now it seems to be starting to respond, except that Form_Resize()
doesn't appear to get called when i drag a form around with the mouse...it
only fires if i change the size...
how to detect form movement if the size doesn't change?


From: Larry Serflaten on

"GS" <gesansom(a)netscape.net> wrote
> Hi Larry,
> I think the simplicity the OP is talking about is that the UDT values
> are read into the UDT OR written from the UDT is a single process. I
> believe what Mark find perplexing is the additional complexity that
> bringing an array into the process causes. Basically, the array has to
> be looped to put the values into the UDT, AND the UDT has to be llooped
> (somehow) to put the values into the array. It sounds to me like he
> doesn't want to do that.

The class method doesn't use a UDT, the values are kept in the array.
see my first post from 6/20/2010. Plus, the message you responded to
here shows that he can access the disk in one line of code.

The way I see it, his objection is about restraining from using variants
and their evil type conversion problems. But the Variant is a versatile
tool in the tool box if you realize what your getting into.

Take, for example, VB's own Collection. In order for the collection
to accept any kind of variable it has to be a collection of Variants
(or similar). So again, when used appropreately, the Variant can be
put to good use. I have to wonder if the OP has objections to using
Collections for the same reason?

LFS


From: mp on
"Larry Serflaten" <serflaten(a)gmail.com> wrote in message
news:hvnkcb$b03$1(a)news.eternal-september.org...
>
> "GS" <gesansom(a)netscape.net> wrote
>> Hi Larry,
>> I think the simplicity the OP is talking about is that the UDT values
>> are read into the UDT OR written from the UDT is a single process. I
>> believe what Mark find perplexing is the additional complexity that
>> bringing an array into the process causes. Basically, the array has to
>> be looped to put the values into the UDT, AND the UDT has to be llooped
>> (somehow) to put the values into the array. It sounds to me like he
>> doesn't want to do that.
>
> The class method doesn't use a UDT, the values are kept in the array.
> see my first post from 6/20/2010. Plus, the message you responded to
> here shows that he can access the disk in one line of code.
>
> The way I see it, his objection is about restraining from using variants
> and their evil type conversion problems. But the Variant is a versatile
> tool in the tool box if you realize what your getting into.
>
> Take, for example, VB's own Collection. In order for the collection
> to accept any kind of variable it has to be a collection of Variants
> (or similar). So again, when used appropreately, the Variant can be
> put to good use. I have to wonder if the OP has objections to using
> Collections for the same reason?
>
> LFS
>

:-)
no i object to using collections because Olaf's cSortedDictionary is so much
better!
<g>
hey...I only learned that variants and ETC were to be avoided from you and
the other experts here over the years.
(vbg)
mark


From: mp on

"Mike S" <mscir(a)yahoo.com> wrote in message
news:hvmsk4$1be$1(a)news.eternal-september.org...
> On 6/20/2010 10:00 PM, mp wrote:
>> "GS"<gesansom(a)netscape.net> wrote in message
>> news:hvmq3m$quu$1(a)news.eternal-september.org...
>>> Mark,
>>> You don't have to duplicate anything! You can just expand on the sample
>>> I
>>> gave you for processing the 3 UDTs I use in every project, on an 'as
>>> needed' basis. So, unless Larry comes up with some way to pass the UDT
>>> ByRef to the class, you'll have to settle for using the array of
>>> variants.
>>>
>>> --
>>> Garry
>>>
>>> Free usenet access at http://www.eternal-september.org
>>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>>
>>>
>>
>> I'm clear that there are two ways to store the data, udt or class.
>> I've tried them both and like them both.
>> I'm trying the class for now and am reading and writing the values to
>> disk,
>> but the form is not taking it's last saved position for some reason.
>> start program
>> class reads values from disk (top, left, height, width)
>> form assigns it's properties to those values
>> this should put it where it was when last closed, but it never moves,
>> always
>> appears in default position...don't know what i'm doing wrong
>> guess this is evolving into a different thread?
>> 'in form initialize
>> Private Sub Form_Initialize()
>> 'snip error trapping and logging calls
>> Set FormSettings = New cFormSettings
>> FormSettings.Filename = App.Path& "FormSettings.txt"
>>
>> 'read former form position and size from file
>> FormSettings.ReadFile
>>
>> 'this should make the form move to where it was before, but it doesn't
>> Me.Left = FormSettings.Values(eSettings.FormLeft)
>> Me.Top = FormSettings.Values(eSettings.FormTop)
>> Me.Width = FormSettings.Values(eSettings.FormWidth)
>> Me.Height = FormSettings.Values(eSettings.FormHeight)
>>
>> ExitHere:
>> 'Form_Initialize = bSuccess
>>
>> ProcEnd ProcName
>> On Error GoTo 0
>> Exit Sub
>>
>> Form_Initialize_Error:
>> LogError , ProcName
>> Resume ExitHere
>>
>>
>> End Sub
>> 'in form resize
>> Private Sub Form_Resize()
>> ResizeFolderViews'adjust controls
>>
>> 'get new form location values into class
>> FormSettings.Values(FormLeft) = Me.Left
>> FormSettings.Values(FormWidth) = Me.Width
>> FormSettings.Values(FormHeight) = Me.Height
>> FormSettings.Values(FormTop) = Me.Top
>>
>> End Sub
>>
>> 'in form terminate
>> Private Sub Form_Terminate()
>> 'leaving out error trapping and logging code
>> FormSettings.WriteFile 'class writes values to file
>> Set FormSettings = Nothing
>> ExitHere:
>> Unload Me
>> On Error GoTo 0
>> Exit Sub
>> End Sub
>
> What do you have the Form StartupPosition set to?
>

er, uh, well...I dont'...what ever the default is i guess, will look into
that
:-)
fwiw a few tests finally started saving size and location if i resized form,
just not if i moved it by dragging...think i'll start a new thread for that
maybe
mark