 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
sdb Guest
|
Posted: Sun Nov 09, 2003 8:26 pm Post subject: Removing FocusRect |
|
|
Hi,
I found this code in the archives. Can I modify it to remove the focus
rectangle from a (clicked) TBitBtn owned by my TCustomControl-derived
component?
I'm unsure how to intercept messages for owned components. Also, where do
you find a list of these messages (eg CN_DRAWITEM)? I can't locate them in
the help files.
Thank you,
Steve (BCB5/WinXP)
---
You can't modify the TOwnerDrawState from inside the DrawItem() method. As
you already noted, it's passed by value. The only way to do what you're
asking for is to use a MESSAGE_MAP to intercept the CN_DRAWITEM message
directly in yuor component, then you can modify the information before
passing it to TCustomListBox for it's default processing:
class TMyListBox : public TCustomListBox
{
private:
void __fastcall MyCNDrawItem(TWMDrawItem &Message);
public:
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(CN_DRAWITEM, TWMDrawItem, MyCNDrawItem)
END_MESSAGE_MAP(TCustomListBox)
};
void __fastcall TMyListBox::MyCNDrawItem(TWMDrawItem &Message)
{
Message.DrawItemStruct->itemState &= ~ODS_FOCUS;
TCustomListBox::Dispatch(&Message);
}
Gambit
|
|
| Back to top |
|
 |
Todd Brylski Guest
|
Posted: Mon Nov 10, 2003 8:01 am Post subject: Re: Removing FocusRect |
|
|
"sdb" <lkjh12 (AT) hotmail (DOT) com> wrote
| Quote: | remove the focus rectangle from a (clicked) TBitBtn
owned by my TCustomControl-derived component?
|
In your custom control class implement the following:
virtual void __fastcall WMDrawItem( TMessage& Message )
{
if( (HWND)Message.WParam == BitBtnPtr->Handle )
{
((LPDRAWITEMSTRUCT)Message.LParam)->itemState &= ~ODS_FOCUS;
}
TCustomControl::Dispatch(&Message);
}
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DRAWITEM, TMessage, WMDrawItem)
END_MESSAGE_MAP(TCustomControl)
Todd
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 12, 2003 12:25 am Post subject: Re: Removing FocusRect |
|
|
"Todd Brylski" <tbrylski (AT) yyaahhoooo (DOT) com> wrote
| Quote: | "sdb" <lkjh12 (AT) hotmail (DOT) com> wrote
remove the focus rectangle from a (clicked) TBitBtn
owned by my TCustomControl-derived component?
In your custom control class implement the following:
virtual void __fastcall WMDrawItem( TMessage& Message )
{
if( (HWND)Message.WParam == BitBtnPtr->Handle )
{
((LPDRAWITEMSTRUCT)Message.LParam)->itemState &= ~ODS_FOCUS;
}
TCustomControl::Dispatch(&Message);
}
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DRAWITEM, TMessage, WMDrawItem)
END_MESSAGE_MAP(TCustomControl)
Todd
|
Sweet! Thanks Todd. Your code led me to try the following, which also
worked.
void __fastcall TMyComponent::WMDrawItem( TWMDrawItem& Message )
{
if( Message.Ctl == BitBtnPtr->Handle )
{
(Message.DrawItemStruct->itemState &= ~ODS_FOCUS;
}
TCustomControl::Dispatch(&Message);
}
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DRAWITEM, TWMDrawItem, WMDrawItem);
END_MESSAGE_MAP(TCustomControl)
Thanks again,
Steve
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 12, 2003 3:47 am Post subject: Re: Removing FocusRect |
|
|
"Todd Brylski" <tbrylski (AT) yyaahhoooo (DOT) com> wrote
| Quote: | "sdb" <lkjh12 (AT) hotmail (DOT) com> wrote
remove the focus rectangle from a (clicked) TBitBtn
owned by my TCustomControl-derived component?
In your custom control class implement the following:
virtual void __fastcall WMDrawItem( TMessage& Message )
{
if( (HWND)Message.WParam == BitBtnPtr->Handle )
{
((LPDRAWITEMSTRUCT)Message.LParam)->itemState &= ~ODS_FOCUS;
}
TCustomControl::Dispatch(&Message);
}
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DRAWITEM, TMessage, WMDrawItem)
END_MESSAGE_MAP(TCustomControl)
Todd
|
Sweet! Thanks Todd. Your code led me to try the following, which also
worked.
void __fastcall TMyComponent::WMDrawItem( TWMDrawItem& Message )
{
if( Message.Ctl == BitBtnPtr->Handle )
{
Message.DrawItemStruct->itemState &= ~ODS_FOCUS;
}
TCustomControl::Dispatch(&Message);
}
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DRAWITEM, TWMDrawItem, WMDrawItem);
END_MESSAGE_MAP(TCustomControl)
Thanks again,
Steve
|
|
| Back to top |
|
 |
Rodolfo Frino - Macrosoft Guest
|
Posted: Fri Dec 19, 2003 2:57 pm Post subject: Re: Removing FocusRect |
|
|
In addition to what Todd said, have a look at this article:
http://www.geocities.com/rodolfofrino/KillFocus.html
"The Universe, as a whole, is a place without outdoors". Rodolfo, 2003
<sdbeames (AT) hotmail (DOT) com> wrote
| Quote: |
"Todd Brylski" <tbrylski (AT) yyaahhoooo (DOT) com> wrote in message
news:3faf45d1$1 (AT) newsgroups (DOT) borland.com...
"sdb" <lkjh12 (AT) hotmail (DOT) com> wrote in message
news:3faea308 (AT) newsgroups (DOT) borland.com...
remove the focus rectangle from a (clicked) TBitBtn
owned by my TCustomControl-derived component?
In your custom control class implement the following:
virtual void __fastcall WMDrawItem( TMessage& Message )
{
if( (HWND)Message.WParam == BitBtnPtr->Handle )
{
((LPDRAWITEMSTRUCT)Message.LParam)->itemState &= ~ODS_FOCUS;
}
TCustomControl::Dispatch(&Message);
}
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DRAWITEM, TMessage, WMDrawItem)
END_MESSAGE_MAP(TCustomControl)
Todd
Sweet! Thanks Todd. Your code led me to try the following, which also
worked.
void __fastcall TMyComponent::WMDrawItem( TWMDrawItem& Message )
{
if( Message.Ctl == BitBtnPtr->Handle )
{
Message.DrawItemStruct->itemState &= ~ODS_FOCUS;
}
TCustomControl::Dispatch(&Message);
}
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DRAWITEM, TWMDrawItem, WMDrawItem);
END_MESSAGE_MAP(TCustomControl)
Thanks again,
Steve
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|