RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TControl.Perform Method (Cardinal, WPARAM, LPARAM)

Responds as if the control received a specified Windows message.

Pascal
function Perform(Msg: Cardinal; WParam: WPARAM; LParam: LPARAM): LRESULT; overload;
function Perform(Msg: Cardinal; WParam: WPARAM; LParam: PChar): LRESULT; overload;
function Perform(Msg: Cardinal; WParam: WPARAM; var LParam: TRect): LRESULT; overload;
C++
__fastcall LRESULT Perform(unsigned Msg, WPARAM WParam, LPARAM LParam);
__fastcall LRESULT Perform(unsigned Msg, WPARAM WParam, const char * LParam);
__fastcall LRESULT Perform(unsigned Msg, WPARAM WParam, TRect LParam);

Call Perform to bypass the Windows message queue and send a message directly to the control's window procedure. 

Perform fills a message record (of type TMessage) with the message ID passed in the Msg parameter, the message parameters passed in WParam and LParam, and a result field of zero. Perform then passes the message record to the WindowProc method for processing.  

C++ Examples: 

 

/*
The following example demonstrates the use of the Perform method
to send a windows message. The EM_SCROLLCARET message scrolls the
caret in the rich edit into view. The caret position is set to the
contents of the mask edit prior to calling Perform.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    RichEdit1->SelStart = StrToInt(MaskEdit1->Text);
    Edit1->Text = IntToStr(RichEdit1->SelStart);
    RichEdit1->Perform(EM_SCROLLCARET, 0, 0);
    RichEdit1->SetFocus();
}

 

Delphi Examples: 

{
The following example demonstrates the use of the Perform method
to send a windows message. The EM_SCROLLCARET message scrolls the
caret in the rich edit into view. The caret position is set to the
contents of the mask edit prior to calling Perform.
}
procedure TForm1.Button1Click(Sender: TObject);
begin
with RichEdit1 do
  Begin
    SelStart := StrToInt(MaskEdit1.Text);
    Edit1.Text := InttoStr(SelStart);
    RichEdit1.Perform(EM_SCROLLCARET, 0, 0);
    RichEdit1.SetFocus;
  end;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!