Drawing a Themed textbox under Vista

bandi
09-30-2009, 05:40 PM
Hi All,

I'm currently trying to replicate the look of a Vista textbox in a user control, but am unable to reproduce the effect for some reason. I'm not trying to create a new textbox... just a label control that looks like one (long story :) )

I'm using UXTheme.dll and DrawThemeBackground, which works great for other control types (eg frames, tabs and command buttons), but is not producing the desired effect for a textbox.

Instead, it seems to produce a textbox that matches a textbox under XP correctly, but only draws a simple grey border under Vista.

The code in UserControl_Paint is as follows (just dealing with the basic state, so not worried about hot/disabled etc at this point)...


Const EP_EDITTEXT = 1
Const ETS_NORMAL = 1

Dim hTheme As Long
Dim hdc As Long
Dim tcr As RECT
Dim pcr As RECT

hTheme = OpenThemeData(UserControl.hWnd, StrPtr("Edit"))
hdc = GetDC(UserControl.hWnd)

tcr.Left = 0
tcr.Top = 0
tcr.Bottom = ScaleHeight
tcr.Right = ScaleWidth

'Not sure if I need this call
DrawThemeParentBackground UserControl.hWnd, UserControl.hdc, tcr

DrawThemeBackground hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, tcr, tcr

'Tidy up
ReleaseDC UserControl.hWnd, hdc
hTheme = CloseThemeData(hTheme)


I've tried a lot of different values for Part and State but haven't found any combinations to give the desired effect. I've also trawled through the web trying to establish if the class is actually "Edit" but haven't come up with anything that is pointing me in the right direction.

I've downloaded a Theme explorer application from another site but it doesn't have anything that matches the vista look either. I've attached an image that shows the results I'm getting.

Has anyone had any experience with drawing a themed text box under Vista or have any ideas I could try?

EDIT: The bottom right textbox in the attachment is the drawn textbox under Vista, not XP. Oops!

Thanks,
Anthony

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum