BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Removing FocusRect

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
sdb
Guest





PostPosted: Sun Nov 09, 2003 8:26 pm    Post subject: Removing FocusRect Reply with quote



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





PostPosted: Mon Nov 10, 2003 8:01 am    Post subject: Re: Removing FocusRect Reply with quote



"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






PostPosted: Wed Nov 12, 2003 12:25 am    Post subject: Re: Removing FocusRect Reply with quote




"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






PostPosted: Wed Nov 12, 2003 3:47 am    Post subject: Re: Removing FocusRect Reply with quote


"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





PostPosted: Fri Dec 19, 2003 2:57 pm    Post subject: Re: Removing FocusRect Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.