USING 'APPLICATION MESSAGE BOXES'
var
nodeNameText: String;
tempNode: TTreeNode;
tempString: String;
begin
if (Sender is TTreeView) then
begin
tempNode := (Sender as TTreeView).Selected;
nodeNameText := GetTreeNodeFullPathName(tempNode, nodeNameText);
tempString := 'This tree nodes full path name is: ' + nodeNameText;
Application.MessageBox(PChar(tempString), ' Tree Node Name', mb_OK);
end;
end;
*******************************************************************
Note that the Forms unit must be your uses clause to use
Application.MessageBox (Windows AND Forms??????????????)
Examples
if OutOfMemory then
begin
Application.MessageBox('Not enough memory -perhaps you need to close down some other applications?', 'Memory Shortage', mb_OK);
end
Here we put a lot of stuff in tempString and then convert it to a PChar
tempString := 'Cannot read ' + uppercase(thisFileName) + '.' + #13 + fileRdStatus + '.';
Application.MessageBox(PChar(tempString), ' Error Reading File', mb_OK);
NOTE THAT SOMETIMES THE COMPILER SEEMS TO GET CONFUSED BY Application.MessageBox
SOLUTION: include both Windows and Forms in the uses clause of that module...
*****************************************************
Sometimes you may want to use a Message Dialog Box, providing the user
with Yes, No and Cancel buttons so that you can perform an action or
actions dependent on the user response. Looks like this:
var
tempString: String;
userResponse: Integer;
begin
if (currFileName = untitledName) then tempString := 'Save changes to unnamed file?'
else tempString := 'Save changes to ' + shortFileName + ' ?';
userResponse := MessageDlg(tempString, mtConfirmation, mbYesNoCancel, 0);
case userResponse of
idYes: FileMenuSaveClick(Self);
{if the response is No or Cancel nothing will happen...}
idNo: ;
idCancel: ;
end;
end;