Announcement

Collapse
No announcement yet.

Color/Font question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Color/Font question

    I've seen this posted a hundred times easily but can't find a sample that covers waht I am doing..

    I have multiple labels and edit boxes, but I only want %IDLABEL3 to have color, everything else should be the normal system font and black...

    But %IDLABEL3 Has to be blue or red (probably blue)...


    So here I go, but htis paints ALL LABELS blue....(and makes them too big)
    'Most of this is in the STMP example (Reading past posts etc)
    Code:
    'In Dialogproc
    
    Local Lb         As LOGBRUSH
    Local lf         As LOGFONT
    Static hFont1    As Long
    Static hBrush    As Long       
    
    
        Case %WM_INITDIALOG
          '------------------------------------------------------------------
          'COLOR STUFF
          hFont1 = MakeFont("Courier New", 10)
          GetObject hFont1, SizeOf(lf), ByVal VarPtr(lf)
          'Make the text bold font or normal
          lf.lfWeight = %FW_BOLD
          Lb.lbStyle  = %BLACK_BRUSH
          Control Send CbHndl, %IDLABEL3, %WM_SETFONT, hFont1, %TRUE
          hBrush   = CreateSolidBrush(GetSysColor(%COLOR_3DFACE))
          '------------------------------------------------------------------
    
    THIS IS likely the part that is kicking my butt...   I don't understand what it is doing....
    
    
        Case %WM_CTLCOLORSTATIC
                  SelectObject CbWparam, hFont1 'and who is CBWparam at this point?
                  SetBkMode CbWparam, %TRANSPARENT
                  SetTextColor CbWparam, %BLUE
                  Function = hBrush    
    
    
    Function MakeFont(ByVal Font As String, ByVal PointSize As Long) As Long
    
      Local hDC      As Long
      Local CyPixels As Long
    
      hDC = GetDC(%HWND_DESKTOP)
      CyPixels  = GetDeviceCaps(hDC, %LOGPIXELSY)
      ReleaseDC %HWND_DESKTOP, hDC
    
      PointSize = (PointSize * CyPixels) \ 72
    
      Function = CreateFont(0 - PointSize, 0, 0, 0, %FW_NORMAL, 0, 0, 0, _
                %ANSI_CHARSET, %OUT_TT_PRECIS, %CLIP_DEFAULT_PRECIS, _
                %DEFAULT_QUALITY, %FF_DONTCARE, ByCopy Font)
    
    End Function
    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    [This message has been edited by Scott Turchin (edited January 23, 2001).]
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Scott,
    Code:
    Case %WM_CTLCOLORSTATIC
         If GetDlgItem(ghDlg,%IDCLABEL3) = Cblparam then
            '<insert code herer>
         End IF
    Regards,
    Jules
    Best regards
    Jules
    www.rpmarchildon.com

    Comment


    • #3
      Perfect!
      Thanks! Works like a charm!

      Scott


      ------------------
      Scott
      mailto:[email protected][email protected]</A>
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment

      Working...
      X