Announcement

Collapse
No announcement yet.

Colour of label

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

  • Colour of label

    Not a problem, but possibly of interest: in the case %WM_CTLCOLORSTATIC
    I had "Select case CbCtl" and that did not work (the control remained
    the default silver grey). As coded below, it works.
    '______________________________________________________________________

    Code:
    CallBack Function EstMnuCallback
    
     Select Case CbMsg
    
     Case %WM_CTLCOLORLISTBOX
      SetBkMode CbWparam, %TRANSPARENT
      SetTextColor CbWparam, %BLACK
      SetBkColor CbWparam, %Cream
      Function = CreamBrush&
    
     Case %WM_CTLCOLORSTATIC
      SetBkMode CbWparam, %TRANSPARENT
      Ci&=GetDlgCtrlID (CbLparam)
    
      Select Case Ci&
    
      Case %PromptLbl
       SetTextColor CbWparam, %Black
       SetBkColor CbWparam, %Cream
       Function = CreamBrush&
       End Select
      End Select
     End Function      '(EstMnuCallback)
    '______________________________________________________________________

    ------------------

  • #2
    None of the %WM_CTLCOLORxxx messages hold the ID of the control in the low-order word of WPARAM (from whence CBCTL is derived).

    This is normal operation for any callback that processes these messages.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      This works to change the grey background to a white background in a STATIC (label) control..

      Dialog is created with the DialogBox API call.

      (Highlights only...)


      Code:
      FUNCTION VsamDialogProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                        BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG      ' no need to EXPORT
          STATIC CurrentDialog AS CurrentDialogSelectionsType
          LOCAL  VSAMParms AS VSAMParametersType
          LOCAL  I AS LONG, J AS LONG, hCtrl AS LONG, szLiteral AS ASCIIZ * 1024
          DIM Stat AS LONG, NotifyCode AS LONG
          DIM Wtext AS STRING
          STATIC hBrush AS LONG
      
      
          SELECT CASE wMsg
             CASE %WM_DESTROY          ' get this both from EndDialog and system close key
                   DeleteObject hBrush ' delete the object prior to exit
      
             CASE  %WM_INITDIALOG
                  InitCommonControls
                  hBrush = GetStockObject (%WHITE_BRUSH)   ' Create the brush for the labele
                  LoadDefaultParameters VSAMParms, CurrentDialog
                  LoadDialogLists hwnd, CurrentDialog
                  ' set up the dialog with current values highlited/selected
                  SetDialogCurrentValues  hWnd, VSAMParms
      
              '....   LOTS EDITED OUT HERE
      
              CASE %WM_CTLCOLORSTATIC
                   ' intercept the WM_CTLCOLORSTATIC message, set the background brush
                   ' Wparam contains the DC into which the brush must be selected
                   ' Lparam is handle to control (its hwnd)
      
                   IF GETDlgCtrlId (lParam) = %IDD_OUTPUT_BOX THEN
                      FUNCTION = hBrush
                      EXIT FUNCTION
                   END  IF
      
      
      END FUNCTION

      According to the help file, if using DDT, CBLPARAM should be same as lparam.

      MCM

      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment

      Working...
      X