![]() |
|
QA: Why empty edit box with no border doesn't show caret?
By Alexander Shargin, July 22, 2003.
QuestionI am using an edit box with no border. I noticed that it doesn't show caret when no text is entered to it. This also happens with comboboxes. Why does this happen? How can I fix this? AnswerBackgroundEach edit box internally stores left and right margin sizes. You can change these sizes by sending EM_SETMARGINS to the edit box. EM_GETMARGINS is used to determine current margin sizes. By default, margins are calculated based on the font assigned to edit box (this mode is enabled by EC_USEFONTINFO flag used with EM_SETMARGINS message). But this mode has some problems on Pocket PC. In fact it works for some fonts (e. g. System) but fails with others (e. g. Tahoma) so the problem probably has to do with fonts, not with OS itself. Solution
First obvious solution is to change font of your edit box (or of the
entire dialog containing it). It can be done in resource editor
( In MFC, CEdit::SetMargins method is used instead: What about comboboxes?Drop-down comboboxes internally use borderless edit boxes to edit text. So obviously, they suffer from the same problem and the same solutions apply here. If you want to use second solution, you need to obtain HWND of edit box embedded inside combobox first. Since edit box is a child window of combobox, this is done using GetWindow function: DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||