-
Some TextBox questions:
1. How do you check the TextBox's Appearance and BorderStyle, without checking the Appearance and BorderStyle properties? (With the API) The problem is, that the WS_EX_CLIENTEDGE is turned on only when both are set to 1. Also, when I create an edit field using CreateWindowEx with the "Edit" ClassName, how do I set this?
2. How do you get/set the TextBox's BackColor without using the built in property? I've tried to subclass the form and return a handle to a colorful brush (CreateBrushIndirect) when I catch a WM_CTLCOLOREDIT message, but the result was interestingly colorful: The background color of the TextBox did become the color I wanted, except behind the text! (???)
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
-
You can only really get the Appearance Property as the BorderStyle Property doesn't register unless the Appearence property is True - Don't know why.
So to check a Textboxes Appearance using the API you would do this:
b3D = GetWindowLong(Text1.Hwnd, GWL_EXSTYLE) And SW_EX_CLIENTEDGE
Also, to create a Textbox with the API and set the Appearance and/or the Border Style can be done in the same call, eg.
lHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "Default Text", WS_BORDER Or WS_CHILD Or WS_VISIBLE, 0, 0, 81, 25, hwnd, 0, 0, 0)
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
And for your 2nd question:
You would have to use SetBkMode API.
So, after you intercept the WM_CTLCOLOREDIT message, use this:
Private Const TRANSPARENT = 1
Call SetBkMode(EditDC, TRANSPARENT)
Note: EditDC is your DeviceContext of the Edit box.
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
[This message has been edited by Serge (edited 11-03-1999).]
-
Aaron: Thanks, but the problem with the WS_EX_CLIENTEDGE is that it is only active when both the Appearance and BorderStyle properties are 1. For example, if Appearance is 1 (3D) and BorderStyle is 0 (None), the WS_EX_CLIENTEDGE extended-style is inactive (meaning Appearance = 0? Not really...)
Serge: Thanks! It worked only part of the time though... But I found another solution:
1. Intercept the WM_CTLCOLOREDIT message.
2. Use SetBkColor with the color you want. (wParam = hDC)
3. Create a brush in the color I want, and return the handle to it.
4. Exit Function, without processing the message using CallWindowProc (of course).
Weird, but works!
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
[This message has been edited by Yonatan (edited 11-05-1999).]