🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15352

Re: How to disable a window in this way?

#15352
From: b
Date: Sun, 06 Jul 2003 21:18
133 lines
5128 bytes
Hi Damon, i didn't think it was so hard, now i study your code and i try to
implement it...
Please don't run away, i think after or tomorrow i'll came back to either to
ask you help or to tell tnx it works!



"Damon Chandler (TeamB)" <dmc27@cornell.edu> ha scritto nel messaggio
news:3F0879B3.9E22CB74@cornell.edu...
> Hi,
>   If you want to flash the modal Form2 when the user clicks Form1, there
are
> two things that you need to do: (1) Determine when the user clicks Form1;
> and (2) flash the title bar of Form2.  For the first step, you'll need to
> handle the WM_SETCURSOR message, looking for a hit-test value [specified
via
> LOWORD(lParam)] of 0xFFFE (effective HTERROR), and a mouse-message value
> [specified via HIWORD(lParam)] corresponding to a release of one of the
> mouse buttons.  For the second step, as Bob mentioned, you can use the
> FlashWindow() Win32 function [or the new FlashWindowEx() function if you
> deploy only on systems greater than Win95/NT].  The FlashWindow() function
> needs to be called in a non-blocking, interative fashion.  Here's a rough
> example...
>
> // in header...
> class TForm1 : public TForm
> {
> __published:
>   TButton *Button1;
>   TTimer *Timer1;
>   void __fastcall Button1Click(TObject *Sender);
>   void __fastcall Timer1Timer(TObject *Sender);
>
> public:
>   __fastcall TForm1(TComponent* Owner) :
>     TForm(Owner), ModalForm_(NULL) {}
>
> private:
>   TForm* ModalForm_;
>   MESSAGE void __fastcall WMSetCursor(TMessage& Msg);
>
> public:
> BEGIN_MESSAGE_MAP
>   MESSAGE_HANDLER(WM_SETCURSOR, TMessage, WMSetCursor)
> END_MESSAGE_MAP(TForm)
> };
>
>
> // in source...
> void __fastcall TForm1::Button1Click(TObject* Sender)
> {
>   ModalForm_ = Form2;
>   try
>   {
>     ModalForm_->ShowModal();
>     // ...
>   }
>   __finally
>   {
>     ModalForm_ = NULL;
>   }
> }
>
> void __fastcall TForm1::WMSetCursor(TMessage& Msg)
> {
>   TForm::Dispatch(&Msg);
>   if (ModalForm_ != NULL &&
>       ModalForm_->FormState.Contains(fsModal))
>   {
>     if (LOWORD(Msg.LParam) == 0xFFFE &&
>         (HIWORD(Msg.LParam) == WM_LBUTTONUP ||
>          HIWORD(Msg.LParam) == WM_MBUTTONUP ||
>          HIWORD(Msg.LParam) == WM_RBUTTONUP))
>     {
>       Timer1->Enabled = true;
>     }
>   }
> }
>
> void __fastcall TForm1::Timer1Timer(TObject *Sender)
> {
>   static unsigned char tic = 0;
>   if (++tic < 9 && ModalForm_ != NULL)
>   {
>     try
>     {
>       FlashWindow(ModalForm_->Handle, true);
>     }
>     catch (...)
>     {
>       Timer1->Enabled = false;
>       // reset, but be sure to debug the error condition
>       FlashWindow(ModalForm_->Handle, false);
>       // reset, but be sure to debug the error condition
>       tic = 0;
>       throw;
>     }
>   }
>   else
>   {
>     Timer1->Enabled = false;
>     FlashWindow(ModalForm_->Handle, false);
>     tic = 0;
>   }
> }
>
> Note that you'll need to add more robust error-handling because you don't
> want to re-enable Timer1 in reponse to WM_SETCUROR if an exception is
> (re)thrown within the OnTimer event handler.  Timer1 should be initially
> disabled (e.g., at design time); and you'd set Timer1's Interval property
to
> adjust the pause between flashes (50ms seems about what Windows uses).
>
> Good luck,
> --
> Damon (TeamB)
> BCBCAQ - http://bcbcaq.bytamin-c.com
>
>
> b wrote:
> >
> > Yes, so how is possible to use FlashWindow ??
> >
> > "JD" <nospam@nospam.com> ha scritto nel messaggio
> > news:3f07c2aa$1@newsgroups.borland.com...
> > >
> > > "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> wrote:
> > > > I still do not understand what you are after.
> > >
> > > He wants to launch Form2 from Form1 using Form2->ShowModal();
> > > Then, if the user tries to return to Form1 before Form2 is
> > > closed, he wants to flash Form2 as a visual que to remind the
> > > user to close Form2 first.
Technical Details
Message-ID: <3f08923a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f06bf1c@newsgroups.borland.com> <3f075635$1@newsgroups.borland.com> <3f0766a4$1@newsgroups.borland.com> <3f07c2aa$1@newsgroups.borland.com> <3f07f776$1@newsgroups.borland.com> <3F0879B3.9E22CB74@cornell.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,994be8bc89f21914
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-06 14:40:03 PST
From: "b" <borland.public.cppbuilder.vcl.components.using>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f06bf1c@newsgroups.borland.com> <3f075635$1@newsgroups.borland.com> <3f0766a4$1@newsgroups.borland.com> <3f07c2aa$1@newsgroups.borland.com> <3f07f776$1@newsgroups.borland.com> <3F0879B3.9E22CB74@cornell.edu>
Subject: Re: How to disable a window in this way?
Date: Sun, 6 Jul 2003 23:18:51 +0200
Lines: 135
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 80.180.201.174
Message-ID: <3f08923a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1057526330 80.180.201.174 (6 Jul 2003 14:18:50 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail