Trying to get a custom dialogbox to work with the button names weapon1 , weapon2, and cancel. But with this code it is giving error on Result as undefined when i try to compile it
The error message is
[DCC Error] ssClientHost.pas(760): E2003 Undeclared identifier: ‘Result’
The code is :
with CreateMessageDialog('Pick What Weapon', mtConfirmation,mbYesNoCancel) do
try
TButton(FindComponent('Yes')).Caption := Weapon1;
TButton(FindComponent('No')).Caption := Weapon2;
Position := poScreenCenter;
Result := ShowModal;
finally
Free;
end;
if buttonSelected = mrYes then ShowMessage('Weapon 1 pressed');
if buttonSelected = mrAll then ShowMessage('Weapon 2 pressed');
if buttonSelected = mrCancel then ShowMessage('Cancel pressed');
The code posted above has a lot of errors, unless there are parts you are not showing us. For one thing, if there are no string variables
Weapon1andWeapon2, then you cannot refer to such variables! Second, if there is noResultvariable (there is if the code is inside a function, for instance), then that’s an error, too. Also, in your code above,buttonSelectedis a variable, which you might have forgotten to declare as well. Finally, first you talk aboutYesandNo, then you talk aboutYesandYes to all.The following code works (standalone):
Disclaimer: The author of this answer is not fond of weapons.