Date: 02-16-2022
Return to Index
created by gbSnippets
'Petzold
'Only the push buttons and owner-draw buttons send WM_CtlColorBtn to their parent
'windows, and only owner-draw buttons respond to the parent window processing fo
'the msssage using the brush for coloring the background.
'Chris Boss
'The reason the WM_CTLCOLORBTN message exists is for support of
'colors for Frames, radio buttons and checkboxes, which are all
'the button class, but not for actual buttons.
'The WM_CTLCOLOR message is used in 16-bit versions of Windows to change the
'color scheme of list boxes, the list boxes of combo boxes, message boxes,
'button controls, edit controls, static controls, and dialog boxes.
%WM_CTLCOLOR
wParam handle to display context
lParam handle to child window (control)
'Return value
'If an application processes this message, it returns a handle to a brush.
'The system uses the brush to paint the background of the control.
'Remarks
'The WM_CTLCOLOR message from 16-bit Windows has been replaced by more
'specific notifications. These replacements include the following:
WM_CTLCOLORBTN
WM_CTLCOLOREDIT
WM_CTLCOLORDLG
WM_CTLCOLORLISTBOX
WM_CTLCOLORSCROLLBAR
WM_CTLCOLORSTATIC
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_Button = 500
%IDC_TextBox = 501
%IDC_Listbox = 502
%IDC_ScrollBar = 503
%IDC_Label = 504
%IDC_Frame = 505
%IDC_Line = 506
Global hDlg As Dword, iPos As Long
Function PBMain() As Long
Dim D(0) As String
D(0) = "One"
Dialog New Pixels, 0, "Test Code",300,300,200,220, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button,"Button", 10,10,45,25
Control Add TextBox, hDlg, %IDC_TextBox,"TextBox", 70,10,100,25
Control Add ListBox, hDlg, %IDC_ListBox,D(), 10,50,100,100
Control Add ScrollBar, hDlg, %IDC_Scrollbar,"Statusbar", 130,50,20,100
ScrollBar Set Range hDlg, %IDC_Scrollbar, 0, 100
Control Add Label, hDlg, %IDC_Label,"Label", 10,165,100,15, %WS_Border Or %SS_Notify
Control Add Frame, hDlg, %IDC_Frame,"Frame", 120,165,40,20, %WS_Border Or %SS_Notify
Control Add Line, hDlg, %IDC_Line,"Line", 10,195,100,15, %WS_Border Or %SS_Notify
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_CtlColorBtn : SetColor(Cb.LParam)
Case %WM_CtlColorEdit : SetColor(Cb.LParam)
Case %WM_CtlColorDlg : SetColor(Cb.LParam)
Case %WM_CtlColorListBox : SetColor(Cb.LParam)
Case %WM_CtlColorScrollbar : SetColor(Cb.LParam)
Case %WM_CtlColorStatic : SetColor(Cb.LParam)
Case %WM_CtlColorMsgBox : SetColor(Cb.LParam)
Case %WM_VScroll : Incr iPos : ScrollBar Set Pos hDlg, %IDC_Scrollbar, iPos
End Select
End Function
Sub SetColor(ByVal hWnd As Long)
SetBkColor hWnd, %Blue
SetTextColor hWnd, %Red
Dialog Set Text hDlg, Time$
End Sub
'gbs_01166
'Date: 03-25-2
http://www.garybeene.com/sw/gbsnippets.htm