Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages
Started by Jim
Sun, 11 May 2003 12:03
BorderIcon Question
Author: Jim
Date: Sun, 11 May 2003 12:03
Date: Sun, 11 May 2003 12:03
11 lines
1351 bytes
1351 bytes
Hopefully this is the proper place to post this question. I have a functioning program that I am attempting to add some enhancements. I have run into a problem. It is mandatory that I run a function whenever the user clicks on the BorderIcon Restore Down button. I cannot figure out how to run this function when this button is clicked. Can someone please help me with this? Thank you very much for your time and any help offered. ~ Jim
Re: BorderIcon Question
Author: 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
Re: BorderIcon Question
Author: Jim
Date: Sun, 11 May 2003 17:54
Date: Sun, 11 May 2003 17:54
93 lines
5033 bytes
5033 bytes
The reason all of this came about is because I need to have the maximize
button enabled. (Originally the program had this button not enabled and the
notebook that makes up a majority of this program has many activepages that
all have their dimensions predifined.) Now I have each ActivePage check the
WindowState to see if the program has been maximized, and if so it keeps the
ActivePage maximized and if not it uses the original predifined dimensions.
The problem that has arisen is that when the user presses the Restore Down
button now the program can be on any number of the Notebooks ActivePages and
it resizes to the predifined size of whatever sized page it was on when it
was maximized, which usually has a different predifined dimension than the
actual page that they are on.
So, I need to check when they press the Restore Down button to see which
ActivePage they are on, and then set the Hieght and Width to the size that I
need for that ActivePage. Since I am still pretty new to all of this I
usually have trouble understanding the more technical .hlp files, but I am
looking through there at what I can find out about the WindowProc and
anything else pertaining to catching when one of these BorderIcon buttons
are being used and catching it so I can run a function when the Restore Down
is used.
Thanks for your time.
~ Jim
"JD" <nospam@nospam.com> wrote in message
news:3ebe5dda$1@newsgroups.borland.com...
>
> "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
>
Re: BorderIcon Question
Author: JD
Date: Sun, 11 May 2003 19:20
Date: Sun, 11 May 2003 19:20
23 lines
1582 bytes
1582 bytes
"Jim" <junk1@imperialstar.com> wrote:
> [...] Now I have each ActivePage check the WindowState to see
> if the program has been maximized, and if so it keeps the
> ActivePage maximized and if not it uses the original
> predifined dimensions.
It sounds as if using the forms OnResize event will work nicely
for you. OnResize is fired after the form has been resized.
void __fastcall TForm1::FormResize(TObject *Sender)
{
switch( WindowState )
{
case wsNormal: // set page sizes to normal sizes
break;
case wsMaximized: // set page sizes to maximized sizes
break;
}
}
~ JD
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads