win32 : display editbox with black color in text area on windows mobile 5

六月ゝ 毕业季﹏ 提交于 2019-12-12 01:26:59

问题


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.

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

regds Suhail


回答1:


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;

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



来源:https://stackoverflow.com/questions/4328026/win32-display-editbox-with-black-color-in-text-area-on-windows-mobile-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!