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





Article #17445: Command Enabling

 Question and Answer Database
FAQ2445C.txt Command Enabling
Category :VCL
Platform :All
Product :C++Builder 3.x
Question:
What is a good way to implement command enabling in the VCL?
Answer:
You might put command enabling in the OnClick event of the parent window.
Which gets called before displaying the menu. So if you want to enable/disable paste
and the menu option is on the edit menu then in the onclick event for the
edit menu check to see if there is anything on the clipboard
//--------------------------------------------------------------------------
-
Body is a TMemo*
void __fastcall TMainForm::EditMenuClick(TObject *Sender)
{
EditUndoItem->Enabled = (Body->CanUndo);
EditPasteItem->Enabled = Clipboard()->HasFormat(CF_TEXT);
EditCopyItem->Enabled = (Body->SelLength> 0);
EditCutItem->Enabled = (Body->SelLength> 0);
EditDeleteItem->Enabled = (Body->SelLength> 0);
}
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99