MAC MessageBox-1 StandardAlert

Posted on Updated on

AlertStdAlertParamRec SARecord;

SARecord.filterProc = nil;
SARecord.movable = false;
SARecord.helpButton = false;
SARecord.defaultText = “pYes";; // right most button text
SARecord.otherText = “pNo";; // center button text
SARecord.cancelText = “pCancel";; // left mose button text
SARecord.defaultButton = kAlertStdAlertOKButton;
SARecord.cancelButton = kAlertStdAlertCancelButton;
SARecord.position = kWindowDefaultPosition;

ConstStr255Param chTitle = “pWarning";
ConstStr255Param chMessage = “pNo Device Found.";
SInt16 sBottonPressed = 0;
StandardAlert(kAlertStopAlert,chTitle,chMessage,&SARecord,&sBottonPressed);

if SARecord.otherText is set to NULL, the button wouldn’t appear, so does cancelText

kAlertStopAlert:
picture-2.png

kAlertNoteAlert:
picture-3.png

kAlertCautionAlert:
picture-4.png

kAlertPlainAlert:
picture-5.png

Notice:
the primary and secondary messages are sent as Pascal strings.
http://forums.macosxhints.com/showthread.php?t=85925

Pascal strings are unsigned. They can be 256 characters in length (0-255), and this length is stored in the first (zeroth) byte of the string. Adding \p to the beginning of the string handles this, but you still need to declare it as the correct type, which you didn’t do, either. (So really, you get 255 characters, since the zero byte is reserved for the string length.)

廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s