Home All Groups Group Topic Archive Search About
Author
23 Feb 2006 10:25 PM
Galen Somerville
My vb6 user control used a propertybag. A typical form would use 6 of these
user controls. The setting of one never affected the others.

Now I'm supposed to use serialization to replace the property bag.

But, the examples I have show saving and retrieving from a file. Since the
file is explicitly named, in the samples, how do I keep the instances
separate??

GalenS

Author
24 Feb 2006 1:36 AM
Homer J Simpson
"Galen Somerville" <galen@community.nospam> wrote in message
news:%23RwfHgMOGHA.2124@TK2MSFTNGP14.phx.gbl...

> My vb6 user control used a propertybag. A typical form would use 6 of
> these user controls. The setting of one never affected the others.
>
> Now I'm supposed to use serialization to replace the property bag.

Can't you use collections?

> But, the examples I have show saving and retrieving from a file. Since the
> file is explicitly named, in the samples, how do I keep the instances
> separate??

Path.GetTempPath

My.Computer.FileSystem.GetTempFileName
Author
24 Feb 2006 2:11 AM
Galen Somerville
"Homer J Simpson" <nob***@nowhere.com> wrote in message
news:vqtLf.3759$Cp4.1309@edtnps90...
Show quoteHide quote
>
> "Galen Somerville" <galen@community.nospam> wrote in message
> news:%23RwfHgMOGHA.2124@TK2MSFTNGP14.phx.gbl...
>
>> My vb6 user control used a propertybag. A typical form would use 6 of
>> these user controls. The setting of one never affected the others.
>>
>> Now I'm supposed to use serialization to replace the property bag.
>
> Can't you use collections?
>
>> But, the examples I have show saving and retrieving from a file. Since
>> the file is explicitly named, in the samples, how do I keep the instances
>> separate??
>
> Path.GetTempPath
>
> My.Computer.FileSystem.GetTempFileName
>
>
The following is typed in not copied in.

in CtrlVol_Load
    If File.Exists("CtrlVol.bin") Then
        Dim MyFileStream as Stream = File.OpenRead("CtrlVol.bin")
        Dim deserializer As New BinaryFormatter()
        CtrlVol = CType(deserializer.Deserialize(MyFileStream), CtrlVol)
        MyFileStream,Close()
    End If

and I assume the reverse in CtrlVol_Leave ??

So if I get a TempPath/FileName, how do I code it so that's the one used for
that control.?

If I use a Global variable for filename in the Main app, does the User
Control see it?

GalenS
Author
24 Feb 2006 2:48 AM
Homer J Simpson
Show quote Hide quote
"Galen Somerville" <galen@community.nospam> wrote in message
news:uzjxYeOOGHA.3888@TK2MSFTNGP10.phx.gbl...
>
> "Homer J Simpson" <nob***@nowhere.com> wrote in message
> news:vqtLf.3759$Cp4.1309@edtnps90...
>>
>> "Galen Somerville" <galen@community.nospam> wrote in message
>> news:%23RwfHgMOGHA.2124@TK2MSFTNGP14.phx.gbl...
>>
>>> My vb6 user control used a propertybag. A typical form would use 6 of
>>> these user controls. The setting of one never affected the others.
>>>
>>> Now I'm supposed to use serialization to replace the property bag.
>>
>> Can't you use collections?
>>
>>> But, the examples I have show saving and retrieving from a file. Since
>>> the file is explicitly named, in the samples, how do I keep the
>>> instances separate??
>>
>> Path.GetTempPath
>>
>> My.Computer.FileSystem.GetTempFileName
>>
>>
> The following is typed in not copied in.
>
> in CtrlVol_Load
>    If File.Exists("CtrlVol.bin") Then
>        Dim MyFileStream as Stream = File.OpenRead("CtrlVol.bin")
>        Dim deserializer As New BinaryFormatter()
>        CtrlVol = CType(deserializer.Deserialize(MyFileStream), CtrlVol)
>        MyFileStream,Close()
>    End If
>
> and I assume the reverse in CtrlVol_Leave ??
>
> So if I get a TempPath/FileName, how do I code it so that's the one used
> for that control.?
>
> If I use a Global variable for filename in the Main app, does the User
> Control see it?
>
> GalenS

As long as you don't delete the file it will persist and won't be reused.
You probably want to put it in a specific directory for your application.
You can store the name somewhere - the registry perhaps?

Can't help you much on User Controls
Author
24 Feb 2006 5:47 AM
Peter Huang" [MSFT]
Hi GalenS,

Also here is sample link about Serialization  for your reference.
Basic Serialization Technology Sample
http://msdn2.microsoft.com/en-us/library/s4w7yaw2.aspx

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Author
24 Feb 2006 10:53 PM
Galen Somerville
Show quote Hide quote
""Peter Huang" [MSFT]" <v-phu***@online.microsoft.com> wrote in message
news:18u4XXQOGHA.668@TK2MSFTNGXA01.phx.gbl...
> Hi GalenS,
>
> Also here is sample link about Serialization  for your reference.
> Basic Serialization Technology Sample
> http://msdn2.microsoft.com/en-us/library/s4w7yaw2.aspx
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
It turns out that I don't need a propertybag (serialization). When I leave
the Form I am done with the UserControls that were used. The next time I
load that form, the user controls have to be re-initialized for the new
usage.

But, I have another problem. In the user control there is a PictureBox on
the main user control panel. It is smaller than the panel.

I use the Mouse to determine where to draw a line on the picture box. So
these are picture box mouse events. They are made Public but they are not
seen by the test application.

I have read up on Shadowing and Overides but very confusing. How do I
accomplish this?

GalenS
Author
27 Feb 2006 5:50 AM
Peter Huang" [MSFT]
Hi,

From your description, I understand that you have a usercontrol.
There is a panel on the usercontrol and a picturebox on the user control.
And now you want to handle the mouse event from the user control.
If I have any misunderstanding, please let me know.

Based on my research, the approach to handle the mouse event is same.
Select the picturebox instance from the IDE code view left dropdownbox, and
select the mouse event from the IDE code view right dropdownbox.

BTW: Commonly for a new question, I suggest you open a new thread, so that
the whole post will easier be read.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.