手动显示Rect Rect [英] Show Focus Rect manually

查看:128
本文介绍了手动显示Rect Rect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我需要通过手动按"TAB"来设置焦点.
使用功能SetFocus手动切换控制焦点时出现问题.
"Focus Rect"没有显示.
如果使用默认功能,则会绘制焦点矩形".

Hello All.
I need to set the focus by pressing "TAB" manually.
I have a problem when manually switching control focus using function SetFocus.
"Focus Rect" does''t show.
If I use the default function then the "Focus Rect" is drawn.

What should be done to make the "Focus Rect" was painted?

推荐答案

我知道如何为用户控件执行此操作.
我想在任何标准控件(按钮,组合框等)上绘制"Focus rect",而不重新实现绘制功能.
I know how to do this for the user control.
I want to draw "Focus rect" on any standard control(Button, ComboBox etc.) without reimplementing draw function.


HWND SetFocus(HWND hWnd)函数将焦点设置在窗口上,并绘制DRAWITEMSTRUCT结构具有用于项目状态的成员变量.
HWND SetFocus(HWND hWnd) function set the focus at window, and DRAWITEMSTRUCT struct has member variable for item state.
typedef struct tagDRAWITEMSTRUCT {
    UINT CtlType;
    UINT CtlID;
    UINT itemID;
    UINT itemAction;
    UINT itemState;
    HWND hwndItem;
    HDC hDC;
    RECT rcItem;
    ULONG_PTR itemData;
} DRAWITEMSTRUCT;





void CMyControl::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
{
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);

	BOOL bIsFocus = (lpDIS->itemState & ODS_FOCUS);
...



DRAWITEMSTRUCT itemstate [



DRAWITEMSTRUCT itemstate[^]


如果您需要绘制rect矩形,则只需在Google上搜索drawfocusrect并打开第一个链接
If you need to draw focus rect then you just have to google for drawfocusrect and open the first link


这篇关于手动显示Rect Rect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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