Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > Algorithms

LinkBack Thread Tools
Old 03.02.2002, 08:06   #1
Join Date: 01 2002
Location: the Silver Castle
Posts: 8
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post Win/OCX


Sorry maybe this question is offtopic of this forum, but I just did not find any forum about PROGRAMMING ITSELF. So the prob goes::

<BLOCKQUOTE><font size="1" face="MS Sans Serif, Verdana, Helvetica, sans-serif">code:</font><HR><pre><BR>'+----------------------------------------------------+<BR>'| FriendsList OCX control source code - © XP SiLVER. |<BR>'| SMCV12SB Working Model ed. project file |<BR>'+----------------------------------------------------+

Const m_def_BackColor = 0<BR>Const m_def_ForeColor = 0<BR>Const m_def_Enabled = 0<BR>Const m_def_BorderStyle = 1<BR>Const m_def_Online = 0<BR>Const m_def_Nickname = "Nickname"

Dim m_BackColor As Long<BR>Dim m_ForeColor As Long<BR>Dim m_Enabled As Boolean<BR>Dim m_Font As Font<BR>Dim m_BorderStyle As Integer<BR>Dim m_Online As Boolean<BR>Dim m_Nickname As String

Event Click()<BR>Event DblClick()<BR>Event KeyDown(KeyCode As Integer, Shift As Integer)<BR>Event KeyPress(KeyAscii As Integer)<BR>Event KeyUp(KeyCode As Integer, Shift As Integer)<BR>Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

'MemberInfo=8,0,0,0<BR>Public Property Get BackColor() As Long<BR> BackColor = m_BackColor<BR>End Property

Public Property Let BackColor(ByVal New_BackColor As Long)<BR> m_BackColor = New_BackColor<BR> picFrame.BackColor = New_BackColor<BR> PropertyChanged "BackColor"<BR>End Property

'MemberInfo=8,0,0,0<BR>Public Property Get ForeColor() As Long<BR> ForeColor = m_ForeColor<BR>End Property

Public Property Let ForeColor(ByVal New_ForeColor As Long)<BR> m_ForeColor = New_ForeColor<BR> lblNickname.ForeColor = New_ForeColor<BR> PropertyChanged "ForeColor"<BR>End Property

'MemberInfo=0,0,0,0<BR>Public Property Get Enabled() As Boolean<BR> Enabled = m_Enabled<BR>End Property

Public Property Let Enabled(ByVal New_Enabled As Boolean)<BR> m_Enabled = New_Enabled<BR> PropertyChanged "Enabled"<BR>End Property

'MemberInfo=6,0,0,0<BR>Public Property Get Font() As Font<BR> Set Font = m_Font<BR>End Property

Public Property Set Font(ByVal New_Font As Font)<BR> Set m_Font = New_Font<BR> Set UserControl.Font = New_Font<BR> Set lblNickname.Font = m_Font<BR> Call UserControl_Resize<BR> PropertyChanged "Font"<BR>End Property

'MemberInfo=7,0,0,0<BR>Public Property Get BorderStyle() As Integer<BR> BorderStyle = m_BorderStyle<BR> If BorderStyle < 2 And BorderStyle >= 0 Then picFrame.BorderStyle = BorderStyle<BR>End Property

Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)<BR> m_BorderStyle = New_BorderStyle<BR> PropertyChanged "BorderStyle"<BR>End Property

'MemberInfo=5<BR>Public Sub Refresh()<BR> <BR>End Sub

'MemberInfo=0,0,0,0<BR>Public Property Get Online() As Boolean<BR> Online = m_Online<BR> If Online = True Then Status = "Online" Else Status = "Offline"<BR> imgIcon.Picture = LoadPicture(App.Path & "\..\Msgr\images\" & Status & ".gif")<BR>End Property

Public Property Let Online(ByVal New_Online As Boolean)<BR> m_Online = New_Online<BR> PropertyChanged "Online"<BR>End Property

'MemberInfo=13,0,0,Nickname<BR>Public Property Get Nickname() As String<BR> Nickname = m_Nickname<BR> lblNickname.Caption = Nickname<BR>End Property

Public Property Let Nickname(ByVal New_Nickname As String)<BR> m_Nickname = New_Nickname<BR> PropertyChanged "Nickname"<BR>End Property

Private Sub UserControl_InitProperties()<BR> m_BackColor = m_def_BackColor<BR> m_ForeColor = m_def_ForeColor<BR> m_Enabled = m_def_Enabled<BR> Set m_Font = Ambient.Font<BR> m_BorderStyle = m_def_BorderStyle<BR> m_Online = m_def_Online<BR> m_Nickname = m_def_Nickname<BR> lblNickname.Caption = m_Nickname<BR>End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

m_BackColor = PropBag.ReadProperty("BackColor", m_BackColor)<BR> m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)<BR> m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)<BR> Set m_Font = PropBag.ReadProperty("Font", Ambient.Font)<BR> m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)<BR> m_Online = PropBag.ReadProperty("Online", m_def_Online)<BR> m_Nickname = PropBag.ReadProperty("Nickname", m_Nickname)<BR>End Sub

Private Sub UserControl_Resize()<BR> picFrame.Width = UserControl.Width<BR> picFrame.Height = UserControl.Height<BR> imgIcon.Top = picFrame.Height / 2 - imgIcon.Height / 2 - 10<BR> lblNickname.Top = picFrame.Height / 2 - imgIcon.Height / 2 - 10<BR> 'lblNickname.Width = picFrame.Width - lblNickname.Left<BR>End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)<BR> Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)<BR> Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)<BR> Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)<BR> Call PropBag.WriteProperty("Font", m_Font, Ambient.Font)<BR> Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)<BR> Call PropBag.WriteProperty("Online", m_Online, m_def_Online)<BR> Call PropBag.WriteProperty("Nickname", lblNickname.Caption, Ambient.DisplayName)<BR>End Sub


<BR>Need 2 create an OCX control on VB, which will include:: Picture box, Label and Image box. And few custom properties - 'Enabled' [if TRUE, the imagebox takes one image, if no - another] and 'Caption' [Customizes the label's text]. So what's the problem - I create it, and on form at the design-time it works perfect, but when I execute the program, Label and Enabled state again come to their default values. What's up??

Reply With Quote

Thread Tools

На правах рекламы:

All times are GMT. The time now is 21:15.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.