API FillColor,Forecolor etc..

How can I change a device context fore back and fill colour just using API's.

Thanks
sircsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
JustinBConnect With a Mentor Commented:
Here are the API calls

' This sets the back colour
ret = SetBkColor(hdc, Colour)
i.e. to set to black you would call
ret = SetBkColor(form.hdc, RGB(0,0,0))

' This sets the Fore colour
ret = SetTextColor(hdc, Colour)

I am not to sure what you mean by fill colour though.
There is no API to set the fill colour. If you want to fill
something with a colour using api calls you would create a
brush of that color and use the fill rect api.

Here are the declares for the api calls
Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Public Declare Function FillRect Lib "user32" Alias "FillRect" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long

Public Declare Function SetTextColor Lib "gdi32" Alias "SetTextColor" (ByVal hdc As Long, ByVal crColor As Long) As Long

Public Declare Function SetBkColor Lib "gdi32" Alias "SetBkColor" (ByVal hdc As Long, ByVal crColor As Long) As Long

Hope that tells you all you need

0
All Courses

From novice to tech pro — start learning today.