Visual Basic - color texto en botones

Life is soft - evento anual de software empresarial
 
Vista:

color texto en botones

Publicado por Juan (21 intervenciones) el 08/07/2001 20:17:14
Hola : necesito urgentemente saber como puedo cambiar en tiempo de ejecucion el color del texto de los commandButton

Gracias.
Juan
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:color texto en botones

Publicado por aLeXiS (35 intervenciones) el 08/07/2001 23:02:04
Se puede, pero hay que usar la API. Inicia un nuevo proyecto e inserta un módulo. Copia y pega este codigo en el apartado General del Modulo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Option Explicit
 
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
 
Private Declare Function GetParent Lib "user32" _
    (ByVal hWnd As Long) As Long
 
Private Declare Function GetWindowLong Lib "user32" Alias _
    "GetWindowLongA" (ByVal hWnd As Long, _
    ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias _
    "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long
Private Const GWL_WNDPROC = (-4)
 
Private Declare Function GetProp Lib "user32" Alias "GetPropA" _
    (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Declare Function SetProp Lib "user32" Alias "SetPropA" _
    (ByVal hWnd As Long, ByVal lpString As String, _
    ByVal hData As Long) As Long
Private Declare Function RemoveProp Lib "user32" Alias _
    "RemovePropA" (ByVal hWnd As Long, _
    ByVal lpString As String) As Long
 
Private 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
 
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (Destination As Any, Source As Any, ByVal Length As Long)
 
'Owner dra
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:color texto en botones

Publicado por aLeXiS (35 intervenciones) el 08/07/2001 23:06:02
Continua.....

\'Owner draw constants
Private Const ODT_BUTTON = 4
Private Const ODS_SELECTED = &H1
\'Window messages we\'re using
Private Const WM_DESTROY = &H2
Private Const WM_DRAWITEM = &H2B

Private Type DRAWITEMSTRUCT
CtlType As Long
CtlID As Long
itemID As Long
itemAction As Long
itemState As Long
hwndItem As Long
hDC As Long
rcItem As RECT
itemData As Long
End Type

Private Declare Function GetWindowText Lib \"user32\" Alias _
\"GetWindowTextA\" (ByVal hWnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
\'Various GDI painting-related functions
Private Declare Function DrawText Lib \"user32\" Alias \"DrawTextA\" _
(ByVal hDC As Long, ByVal lpStr As String, ByVal nCount As Long, _
lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function SetTextColor Lib \"gdi32\" (ByVal hDC As Long, _
ByVal crColor As Long) As Long
Private Declare Function SetBkMode Lib \"gdi32\" (ByVal hDC As Long, _
ByVal nBkMode As Long) As Long
Private Const TRANSPARENT = 1

Private Const DT_CENTER = &H1
Public Enum TextVAligns
DT_VCENTER = &H4
DT_BOTTOM = &H8
End Enum
Private Const DT_SINGLELINE = &H20

Private Sub DrawButton(ByVal hWnd As Long, ByVal hDC As Long, _
rct As RECT, ByVal nState As Long)

Dim s As String
Dim va As TextVAligns

va = GetProp(hWnd, \"VBTVAlign\")

\'Prepare DC for drawing
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar