| View previous topic :: View next topic |
| Author |
Message |
Tomas Vercetti Guest
|
Posted: Tue Jul 26, 2005 1:34 pm Post subject: How use WndProc inside an application? |
|
|
1. I created a new standart application. Is there any way to use WndProc of Form1 to handle messages inside this application itself.
I want to use case statement inside that function to react on messages.
2. Is that way common to other vcl components?
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Jul 26, 2005 4:29 pm Post subject: Re: How use WndProc inside an application? |
|
|
"Tomas Vercetti" <tomasvercetti (AT) r66 (DOT) ru> wrote
| Quote: | 1. I created a new standart application. Is there any way to
use WndProc of Form1 to handle messages inside this
application itself.
|
Please elaborate.
Gambit
|
|
| Back to top |
|
 |
Tomas Vercetti Guest
|
Posted: Tue Jul 26, 2005 6:49 pm Post subject: Re: How use WndProc inside an application? |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
Please elaborate.
I created new BCPP application. Then I created TreeView using CreateWindowEx() and set Form1 as parent for TreeView. A tree-view control sends notification messages to its parent window. So I need to handle those messages. |
When I created windows applications "from a blank page", I used WINAPI MainWndProc to react on messages.
So I want to use WndProc (or WindowProc?) the same way in my BCPP application.
Thank you for your attention.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Jul 26, 2005 6:51 pm Post subject: Re: How use WndProc inside an application? |
|
|
"Tomas Vercetti" <tomasvercetti (AT) r66 (DOT) ru> wrote
| Quote: | I created new BCPP application. Then I created TreeView using
CreateWindowEx() and set Form1 as parent for TreeView.
|
Since you are using the VCL anyway, why not use the TTreeView component
instead of making one manually?
| Quote: | A tree-view control sends notification messages to its parent window. So
I need to handle those messages.
|
If you use the TTreeView component instead, all of that is handled for you
automatically.
Otherwise, TForm does have a virtual WndProc() method that you can override
to handle the messages.
Gambit
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Tue Jul 26, 2005 7:08 pm Post subject: Re: How use WndProc inside an application? |
|
|
Hi,
As Remy said, if you want to overide WndProc(), this is one
way /UNTESTED!!!/:
--- Form1 ( Unit1.h ) ---
// ...
protected: // User declarations
virtual void __fastcall WndProc( TMessage &Message )
// ...
--- Form1 ( Unit1.cpp ) ---
// ...
#define MY_CUSTOM_MESSAGE (WM_USER + 1000)
// ...
void __fastcall TForm1::WndProc( TMessage &Message )
{
switch ( Message.Msg )
{
case MY_CUSTOM_MESSAGE:
// Your custom code here ...
break;
// ...
}
TForm::WndProc( Message );
}
--- Usage (Send a message) ---
// ...
SendMessage( Form1->Handle, MY_CUSTOM_MESSAGE, 0, 0 );
// ...
--
Best regards,
Vladimir Stefanovic
"Tomas Vercetti" <tomasvercetti (AT) r66 (DOT) ru> wrote
| Quote: |
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
Please elaborate.
I created new BCPP application. Then I created TreeView using
CreateWindowEx() and set Form1 as parent for TreeView. A tree-view control
sends notification messages to its parent window. So I need to handle
those messages.
When I created windows applications "from a blank page", I used WINAPI
MainWndProc to react on messages.
So I want to use WndProc (or WindowProc?) the same way in my BCPP
application.
Thank you for your attention.
|
|
|
| Back to top |
|
 |
|