单选按钮Ownerdraw [英] Radio Button Ownerdraw

查看:72
本文介绍了单选按钮Ownerdraw的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从CButton派生的类创建了一组四个单选按钮.创建时,我将样式设置为"WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_OWNERDRAW | BS_AUTORADIOBUTTON | WS_GROUP",其余的我将样式设置为"WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_OWNERDRAW | BS_AUbrADIOB 我在按钮类中重写了DrawItem函数,但是在执行程序时绘制了按钮,但是我无法选择任何按钮,因此根本无法选择它们.
这是我正在使用的代码行

DrawFrameControl(&rect,DFC_BUTTON,DFCS_BUTTONRADIO |(((lpDrawItemStruct-> itemState&ODS_SELECTED)?DFCS_CHECKED:0));

请告诉我是否缺少任何内容.

I have created a group of four radio buttons from a class derived from CButton. While creating, I am setting the styles as "WS_CHILD | WS_VISIBLE | WS_TABSTOP |BS_OWNERDRAW | BS_AUTORADIOBUTTON | WS_GROUP" for first radio and for rest i am setting "WS_CHILD | WS_VISIBLE | WS_TABSTOP |BS_OWNERDRAW | BS_AUTORADIOBUTTON"
I have overridden the DrawItem function in the button class, but when the program is executed the buttons are drawn, but i can not select any button, they are not getting selected at all.
this is the codeline i am using

DrawFrameControl(&rect, DFC_BUTTON,DFCS_BUTTONRADIO | ((lpDrawItemStruct->itemState & ODS_SELECTED)?DFCS_CHECKED : 0));

Please tell me if i am missing anything.

推荐答案

我不知道您的代码有什么问题,但请尝试与该代码进行比较:
自定义绘制按钮&一个更聪明的分组框 [^ ]
这个人正在绘制所有者绘制单选按钮,您可以下载他的代码并将其与您的代码进行比较.您也许会在这里找到答案.
I don''t know what is wrong in your code, but try to compare with this one:
Custom Draw Buttons & A Smarter Groupbox[^]
This guy is drawing owner draw radio buttons, you can download his code and compare it to yours. You will maybe find an answer there.


这篇关于单选按钮Ownerdraw的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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