Главная страница | назад





Article #15929: Window Handles and Object Pointers

 Question and Answer Database

FAQ929C.txt   Window Handles and Object Pointers
Category   :VCL
Platform    :All
Product    :C++Builder  1.x

Question:

I'm calling SendMessage like this:

SendMessage(Form1->Edit1, ED_FMTLINES, true, 0);

and i'm getting compiler errors. What am I doing wrong?

Answer:

Most Windows API functions expect to receive as one
of their parameters a handle to the window on which
they should be operating. The handle is a pointer to
a structure in which Windows stores information it 
needs regarding the window with which it is associated.

Statements like Form1->Edit1 represent the _VCL type_
of a control, not the _Windows handle_ of the control.
To obtain a handle which can be used in the Windows
context, you must query the Handle property of the
VCL object you wish to operate on, like so:

Form1->Edit1->Handle

this will provide Windows with access to the information
it needs to perform the desired operation.

7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99