how would i set the background color and text of a pushbutton WITH ONLY API!!!!!!! has to be api becuase i need it for a nother project that isnt vb.
Printable View
how would i set the background color and text of a pushbutton WITH ONLY API!!!!!!! has to be api becuase i need it for a nother project that isnt vb.
Is it C++? You'll have to subclass your window (change its procedure to your own) and then you'll recieve a WM_CTLCOLORBTN message where you can return the background colour (as HBRUSH) to change the background colour to whatever you want.
BTW, you'll already be handling your window's messages in C++.
asm actully, if youy can give me some vb code to do this i can convert it to asm.
You can try this (did work for me in VB but works in C++):
VB Code:
'IN THE MODULE Option Explicit Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong 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 CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) 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 Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Public Const GWL_WNDPROC = (-4) Public Const WM_CTLCOLORBTN = &H135 Public oldwndproc As Long Dim hbrush As Long Public Function Subclass(hwnd As Long) 'Red background colour hbrush = CreateSolidBrush(vbRed) 'Subclass the window oldwndproc& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndProc) End Function Public Function Unsubclass(hwnd As Long) 'Remove the subclassing SetWindowLong hwnd, GWL_WNDPROC, oldwndproc& 'Delete the background brush DeleteObject hbrush End Function 'Subclassed procedure Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If Msg = WM_CTLCOLORBTN Then 'Change the background colour of the button WndProc = hbrush End If WndProc = CallWindowProc(oldwndproc&, hwnd&, Msg&, wParam&, lParam&) End Function 'IN THE FORM Private Sub Form_Load() Subclass Me.hwnd End Sub Private Sub Form_Unload(Cancel As Integer) Unsubclass Me.hwnd End Sub