Results 1 to 7 of 7

Thread: New ActiveX command button

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Houston, Texas - U.S.A.
    Posts
    84

    Question

    I'm attempting to create a new command button control from the existing command button control that will allow the user to change the color of the font. I've added the ForeColor property and defined its persistence. Obviously I'm missing something - the font color stays black. Here is a part of my code:

    Const m_def_ForeColor = vbBlue
    Dim m_ForeColor As OLE_COLOR

    Public Property Get ForeColor() As OLE_COLOR
    ForeColor = m_ForeColor
    End Property

    Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
    m_ForeColor = New_ForeColor
    PropertyChanged "ForeColor"
    End Property

    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

    cmdGuru.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
    m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
    cmdGuru.Enabled = PropBag.ReadProperty("Enabled", True)
    Set cmdGuru.Font = PropBag.ReadProperty("Font", Ambient.Font)
    m_BackStyle = PropBag.ReadProperty("BackStyle", m_def_BackStyle)
    m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
    cmdGuru.Caption = PropBag.ReadProperty("Caption", "")
    cmdGuru.FontUnderline = PropBag.ReadProperty("FontUnderline", 0)
    m_FontTransparent = PropBag.ReadProperty("FontTransparent", m_def_FontTransparent)
    cmdGuru.FontStrikethru = PropBag.ReadProperty("FontStrikethru", 0)
    cmdGuru.FontSize = PropBag.ReadProperty("FontSize", 0)
    cmdGuru.FontName = PropBag.ReadProperty("FontName", "")
    cmdGuru.FontItalic = PropBag.ReadProperty("FontItalic", 0)
    cmdGuru.FontBold = PropBag.ReadProperty("FontBold", 0)
    Set m_Image = PropBag.ReadProperty("Image", Nothing)
    cmdGuru.MaskColor = PropBag.ReadProperty("MaskColor", 12632256)
    cmdGuru.MousePointer = PropBag.ReadProperty("MousePointer", 0)
    Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
    Set Picture = PropBag.ReadProperty("Picture", Nothing)
    cmdGuru.ToolTipText = PropBag.ReadProperty("ToolTipText", "")
    End Sub

    'Write property values to storage
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

    Call PropBag.WriteProperty("BackColor", cmdGuru.BackColor, &H8000000F)
    Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
    Call PropBag.WriteProperty("Enabled", cmdGuru.Enabled, True)
    Call PropBag.WriteProperty("Font", cmdGuru.Font, Ambient.Font)
    Call PropBag.WriteProperty("BackStyle", m_BackStyle, m_def_BackStyle)
    Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
    Call PropBag.WriteProperty("Caption", cmdGuru.Caption, "")
    Call PropBag.WriteProperty("FontUnderline", cmdGuru.FontUnderline, 0)
    Call PropBag.WriteProperty("FontTransparent", m_FontTransparent, m_def_FontTransparent)
    Call PropBag.WriteProperty("FontStrikethru", cmdGuru.FontStrikethru, 0)
    Call PropBag.WriteProperty("FontSize", cmdGuru.FontSize, 0)
    Call PropBag.WriteProperty("FontName", cmdGuru.FontName, "")
    Call PropBag.WriteProperty("FontItalic", cmdGuru.FontItalic, 0)
    Call PropBag.WriteProperty("FontBold", cmdGuru.FontBold, 0)
    Call PropBag.WriteProperty("Image", m_Image, Nothing)
    Call PropBag.WriteProperty("MaskColor", cmdGuru.MaskColor, 12632256)
    Call PropBag.WriteProperty("MousePointer", cmdGuru.MousePointer, 0)
    Call PropBag.WriteProperty("MouseIcon", MouseIcon, Nothing)
    Call PropBag.WriteProperty("Picture", Picture, Nothing)
    Call PropBag.WriteProperty("ToolTipText", cmdGuru.ToolTipText, "")
    End Sub

    What am I missing?
    Thanks for the help!




  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169

    Wink

    You did the rest, but forgot to actually change the button's colour...
    Code:
    Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR)
    m_ForeColor = New_ForeColor
    cmdGuru.ForeColor = m_ForeColor
    PropertyChanged "ForeColor"
    End Property
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Houston, Texas - U.S.A.
    Posts
    84

    Unhappy

    I tried that before I posted my question but existing command buttons don't have a ForeColor property. I receive a "Method or Data Member Not Found" error for the cmdGuru command button when I try to change the ForeColor property. That's what I'm trying to create but am not having much luck. Thanks for the suggestion.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Fair enough. Seems my brain has resigned...

    In that case, I think there's some tweaking needed. How about sending a message to the button to change its font? Look at the PSDK reference for more details, under User Interface Services.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Houston, Texas - U.S.A.
    Posts
    84

    Lightbulb

    I've decided to create an ActiveX command button from a picture box, lines, and a label. The label has the ForeColor property I'm looking for and the picture box has the BackColor property I need. I basically have to add code to the MouseDown and MouseUp events to handle the line color changes (button shadows) and code up the ReSize event. So far, so good. It's working great! Thanks again for your help.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    As soon as I find it I'll email you a button control that's already been written.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Houston, Texas - U.S.A.
    Posts
    84

    Thumbs up

    Thanks parksie, I appreciate it. My button seems to be working fine. I want the ability to change the ForeColor on a command button because I have an application in which I'm allowing the user to enter numbers from both the keyboard and their mouse from a calculator keypad in the interface. I wanted the BackGround color to be dark grey and the ForeColor to be white. Kind of patterning it after a Hewlitt-Packard calculator. If you want it, I'll send you a copy of my button. Thanks again for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width