|
-
Re: It works
Hello Neal,
Thanks for all the suggestions. You pointed me in the right direction.
This morning, I added the following read properties event and now everything
works as expected:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
CommPort = PropBag.ReadProperty("CommPort", 1)
End Sub
Thanks again
"Jerry Bumgarner" <jerry.bumgarner@indramat.com> wrote:
>
>Hello again,
>Thanks for the suggestions. It's almost working now. To troubleshoot,
I
>put Msgbox's in the properties and events of the control and property page
>so that I would now when events and properties were executing.
>
>After adding the control to the test project and right clicking on the property
>page, a message box displays that the commport is 2 (original value set
in
>the mscomm control). When I change the commport to 1 on the property page
>and press okay, I get a message box from the Property Let and shows that
>mscomm.commport =1. Seems to be working.
>However, when I run the test project, the form load event reads the commport
>(label1.caption = activexcontrol.commport). The Property Get event runs
>and returns a setting of 2 - even though the property page changed it to
>1.
>I've checked all my code in the control and nothing else sets the commport.
>
>If I add the following code to the test project,
>activeXcontrol.commport = 1, then the commport is changed but it defeats
>the purpose of the property page.
>
>What am I doing wrong??
>
>Thanks again,
>Jerry
>
>
>"Neal Andrews" <neal@nandrews.freeserve.co.uk> wrote:
>>Hi Jerry
>>
>>Ok so we know that the property page is working Ok because you can access
>>the information when you reopen the property page, but not when the actual
>>control is run, correct!
>>
>>Spotted it!
>>
>>>> Public Property Let CommPort(portnum As Integer)
>>>> MSComm.CommPort = portnum
>>>> End Property
>>
>>You need to call the PropertyChanged method i.e.
>>
>>Public Property Let CommPort(portnum As Integer)
>> MSComm.CommPort = portnum
>> Call PropertyChanged("CommPort")
>>End Property
>>
>>This tells the control that it needs to call the UserControl_WriteProperties
>>so that the value is saved to the property bag.
>>if you haven got any methods in the UserControl_WriteProperties event then
>>they look something like this
>>
>> Call PropBag.WriteProperty(("CommPort", MSComm.CommPort, <Your Default
>>Value for the commport>)
>>
>>Since you are using a class method you could properly dump the whole class
>>to the property bag
>>
>>Also I would recommend passing any property Let members by Val and not
by
>>ref
>>
>>Public Property Let CommPort(ByVal portnum As Integer)
>>
>>Regards
>>Neal
>>
>>
>>
>>"JerryB" <jerry.bumgarner@indramat.com> wrote in message
>>news:396dc9fa$1@news.devx.com...
>>>
>>> Hello Neal,
>>>
>>> Thanks for the reply. I had included those methods already.
>>> In the app where I'm testing the control, I can bring up the property
>page
>>> and change the commport in the text box. If I hit Ok to close the
>>property
>>> page and then open the property page again, the new commport is displayed.
>>> However, if I run the app and put the following code in the form load
>>event,
>>> the old, original commport is read:
>>>
>>> Label2.caption = activexcontrol.commport
>>>
>>> This is my first attempt at property pages. When does the code in the
>>property
>>> page actually run?
>>>
>>> If it calls a method in the ActiveX control, when does that method run?
>>>
>>> Thanks,
>>> Jerry
>>>
>>>
>>> "Neal Andrews" <neal@nandrews.freeserve.co.uk> wrote:
>>> >Hi Jerry
>>> >
>>> >Have you placed the PropertyChanged method in the txtbox for the
>>property?
>>> >Something like...
>>> >
>>> >Private Sub txtBx_Change(Index As Integer)
>>> > if m_fLoaded then
>>> > PropertyPage.Changed = True
>>> > end if
>>> >End Sub
>>> >
>>> >Note:
>>> > m_fLoaded is a private variable set at the end of the
>>> >PropertyPage_SelectionChanged() event.
>>> >
>>> > Private Sub PropertyPage_SelectionChanged()
>>> >
>>> > m_fLoaded = False
>>> >
>>> > 'Load Properties from control into property page.
>>> >
>>> > m_fLoaded = True
>>> > End Sub
>>> >
>>> >Regards
>>> >Neal
>>> >
>>> >"Jerry Bumgarner" <jerry.bumgarner@indramat.com> wrote in message
>>> >news:396c6df8$1@news.devx.com...
>>> >>
>>> >> I've created an ActiveX control that uses the MSComm control to
>>retrieve
>>> >data
>>> >> from a controller and now I want to add property pages to let the
user
>>> >change
>>> >> the Com Port and Baud Rate.
>>> >> The ActiveX control has the following properties:
>>> >>
>>> >> Public Property Let CommPort(portnum As Integer)
>>> >> MSComm.CommPort = portnum
>>> >> End Property
>>> >> Public Property Let BaudRate(baud As Long)
>>> >> MSComm.Settings = Str(baud) & LTrim(",N,8,1")
>>> >> End Property
>>> >>
>>> >> When I add a property page, the following event code is added:
>>> >> Private Sub PropertyPage_ApplyChanges()
>>> >> SelectedControls(0).CommPort = txtCommPort.Text
>>> >> SelectedControls(0).BaudRate = txtBaudRate.Text
>>> >> End Sub
>>> >>
>>> >> This doesn't set the properties of the MSComm control. Any suggestions?
>>> >
>>> >
>>>
>>
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks