win32:在Windows Mobile 5的文本区域中以黑色显示Editbox [英] win32 : display editbox with black color in text area on windows mobile 5

查看:131
本文介绍了win32:在Windows Mobile 5的文本区域中以黑色显示Editbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows Mobile 5上编写简单的UI应用程序,我想在整个编辑框中向用户显示带有背面颜色的编辑框,但是我用任何方法都无法成功.....
我捕获了用于编辑控件的窗口事件并调用setBkColor(),它将仅显示具有给定颜色的文本区域,而不是整个编辑框。

I am writing simple UI application on windows mobile 5, i want to display a editbox to user with back color in whole edit box but i am not successful with any approach........ whenever i catch the window event for edit control and call setBkColor(), it will display only text area with given color not entire edit box.

我希望给定的颜色在显示给用户的窗口时显示给用户,而不是在用户在编辑框中输入数据时显示。

I want the given color to be displayed to the user when the window presented to the user not when user enters the data in the edit box.

请让我知道解决方案,再次以其本机win32应用程序代码而不是MFC

Please let me know the solution , again its native win32 application code not MFC

regds
Suhail

regds Suhail

推荐答案

SetBkColor 仅设置文本的背景色。要更改整个控件的背景,您需要处理 WM_CTLCOLOREDIT 消息,并返回您选择的画笔。您可以像这样在 WndProc 中执行此操作(假设 hEdit 是编辑控件的句柄)

SetBkColor only sets the background colour for the text. To change the background of the entire control, you need to process the WM_CTLCOLOREDIT message and return a brush of your choice. You can do this in your WndProc like this: (assuming hEdit is the handle of your edit control)

case WM_CTLCOLOREDIT:
  if ((HWND)lParam == hEdit) {
    HDC hDC = (HDC)wParam;
    SetBkMode(hDC, TRANSPARENT);
    return (LRESULT)GetStockObject(BLACK_BRUSH); // or any other brush you want
  }
  break;

通过将背景模式设置为透明,您不需要单独的 SetBkColor 调用-文本将在背景上透明地绘制。

By setting the background mode to transparent, you don't need a separate SetBkColor call -- the text will be painted transparently over the background.

这篇关于win32:在Windows Mobile 5的文本区域中以黑色显示Editbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆