Const WM_CTLCOLOREDIT = &H133
Сообщение WM_CTLCOLOREDIT посылается родительскому окну текстового поля перед своей прорисовкой. При обработке сообщения, родительское окно может установить цвет текста и фона текстового поя, используя указанный дескриптор контекста устройства
' меняем цвет фона в текстовом поле ' Добавьте в проект модуль ' Module1.bas Declare Function CallWindowProc Lib "user32" Alias _ "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As _ Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As _ Long) As Long Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Declare Function SetBkMode Lib "gdi32" _ (ByVal hdc As Long, ByVal nBkMode As Long) As Long Public Const WM_CTLCOLOREDIT = &H133 Public Const TRANSPARENT = 1 Public Const OPAQUE = 2 Public Const GWL_WNDPROC = -4 Global lpPrevWndProc As Long Global gHW As Long Public Sub Hook() lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _ AddressOf WindowProc) End Sub Public Sub Unhook() Dim temp As Long temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc) End Sub Function WindowProc(ByVal hw As Long, ByVal uMsg As _ Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim i As Long If uMsg = WM_CTLCOLOREDIT Then i = SetBkMode(wParam, TRANSPARENT) End If WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, _ lParam) End Function
Private Sub Form_Load() gHW = Me.hwnd Text1.BackColor = &HC0E0FF Hook End Sub Private Sub Form_Unload(Cancel As Integer) Unhook End Sub