Article View: borland.public.cppbuilder.nativeapi
Article #16499Re: BorderIcon Question
From: JD
Date: Sun, 11 May 2003 14:27
Date: Sun, 11 May 2003 14:27
58 lines
3390 bytes
3390 bytes
"Jim" <junk1@imperialstar.com> wrote:
> It is mandatory that I run a function whenever the user
> clicks on the BorderIcon Restore Down button.
You are aware that the BorderIcon isn't the only way for the user to restore down right? What exactly are your requirements for executing the function?
If the forms BorderStyle is bsSingle for a non-sizable form (user can not drag the border to resize the form) you can handle the function with the forms OnResize event by checking the forms WindowState property.
If the function is executed only when the user clicks the BorderIcon, the first thing that you have to do is subclass the forms WindowProc so that you can recieve notice of when the button is clicked:
// in header
private: // User declarations
TWndMethod OldWindowProc;
void __fastcall NewWindowProc( TMessage& );
public: // User declarations
__fastcall TForm1(TComponent* Owner);
__fastcall TForm1::~TForm1();
};
//-------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
OldWindowProc = WindowProc;
WindowProc = NewWindowProc;
}
//-------------------------------------------------
__fastcall TForm1::~TForm1()
{
WindowProc = OldWindowProc;
}
//-------------------------------------------------
void __fastcall TForm2::NewWindowProc( TMessage& Message )
{
switch( Message.Msg )
{
// test here for your manditory function
// you'll need to decide what message you'll
// test for. You could look only for WM_NCLBUTTONUP
// and determine if the click release was in the Restore
// down button but I think that there is a better message
// available to test for. Look at the win32.hlp file
// If you process the message yourself (don't want the
// restore down to happen) set Message.Result to the value
// indicated in the help file for the selected message
// if the help says to set the result. if you are only
// going to add to the restore down functionality, then
// be sure to call the old WindowProc before or after you
// perform your function.
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP:
case WM_SIZE:
case WM_SIZING:
default: OldWindowProc( Message );
}
}
//-------------------------------------------------
~ JD
Technical Details
Message-ID:
<3ebe5dda$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ebe3c36@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,75b9b16b9fc71b77 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-11 07:34:50 PST From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: BorderIcon Question Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 172.164.170.157 172.164.170.157 References: <3ebe3c36@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.65 Message-ID: <3ebe5dda$1@newsgroups.borland.com> Date: 11 May 2003 07:27:38 -0700 X-Trace: newsgroups.borland.com 1052663258 207.105.83.65 (11 May 2003 07:27:38 -0700) Lines: 59 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!216.166.71.14.MISMATCH!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail