Re: Setting textbox colour
Well, you'll have to use the SendMessageA API function and, the WM_SETFONT as the message :)
Cheers,
RyanJ
Re: Setting textbox colour
Thanks for the prompt reply. How do I use this?
Using:
VB Code:
Debug.Print SendMessage(Text1.hwnd, WM_GETFONT, 0&, 0&)
Debug.Print SendMessage(Text2.hwnd, WM_GETFONT, 0&, 0&)
gives 889851594 and 889851594 where Text1 has black text and Text2 has red text.
Could you give me a simple example of just changing the forecolour to red?
EDIT:
Just reading around a bit, and it seems like there is no colour associated with font. If I were to use SetTextColor, how do I get the device context of the TextBox?
EDIT 2:
Reading around further, came up with the following:
VB Code:
Dim lngMainTexthDC As Long
lngMainTexthDC = GetDC(txtMainText.hwnd)
SetTextColor lngMainTexthDC, RGB(255, 0, 0)
However, this does not work. Still not sure why...
Re: Setting textbox colour
Quote:
Originally Posted by olamm2k
EDIT:
Just reading around a bit, and it seems like there is no colour associated with font. If I were to use SetTextColor, how do I get the device context of the TextBox?
I do not think the Textbox has one, if it does then it will be Text1.hdc.
If it is not set then you'd have to creaqte your own.
Cheers,
RyanJ
Re: Setting textbox colour
How do I do this? There's the CreateDC function, but how would I use that to create a device context for an object outside my application?
VB Code:
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA"
(ByVal lpDriverName As String, _
ByVal lpDeviceName As String,
ByVal lpOutput As String,
lpInitData As DEVMODE) As Long
Re: Setting textbox colour
Outside your application? I have no idea at all how you could do it.
I'll see if I can find some code / a tutorial that will help or, hopefuly someone that can answer this will reply before then :)
Cheers,
RyanJ
Re: Setting textbox colour
Okay, thanks.
Just to amend my second post,
VB Code:
Dim lngMainTexthDC As Long
lngMainTexthDC = GetDC(txtMainText.hwnd)
SetTextColor lngMainTexthDC, RGB(255, 0, 0)
does work, but only when you then use TextOut to write onto the TextBox, which isn't very helpful.