รู้ไหม MessageBox ใน Delphi มีมากกว่า 1 อย่าง?

Piyanat Nimkhuntod
2 min readApr 21, 2022

Delphi เท่าที่ผมรู้มีการแสดงกล่องโต้ตอบหรือ MessageBox มีหลายแบบ ยกตัวอย่างที่พบเจอบ่อยๆ ดังนี้

1. procedure showmessage ( const Text : string ) ; (อ้างอิง)

ตัวอย่าง

showmessage(‘Hello’);

2. function messagedlg ( const Message : string; DialogType : TMsgDlgType; Buttons : TMsgDlgButtons; HelpContext : Longint ) : Integer; (อ้างอิง)

ตัวอย่าง

MessageDlg(‘Hello’,mtInformation,[mbOK],0);

ในส่วนนี้จะพิเศษหน่อย ตรงที่เราสามารถเลือก เพราะมี Icon ให้เลือก
mtWarning Displays a exclamation symbol
mtError Displays a red ‘X’
mtInformation Displays an ‘i’ in a bubble
mtConfirmation Displays an question mark
mtCustom Displays just the message

และรูปแบบ ปุ่มโต้ตอบ ให้เลือก

mbYes Displays a ‘Yes’ button
mbNo Displays a ‘No’ button
mbOK Displays an ‘OK’ button
mbCancel Displays a ‘Cancel’ button
mbAbort Displays an ‘Abort’ button
mbRetry Displays a ‘Retry’ button
mbIgnore Displays an ‘Ignore’ button
mbAll Displays an ‘All’ button
mbNoToAll Displays a ‘No to all’ button
mbYesToAll Displys a ‘Yes to all’ button
mbHelp Displays a ‘Help’ button

อ้างอิง

3. function MessageBox(const Text, Caption: PChar; Flags: Longint = MB_OK): Integer; (อ้างอิง1 , อ้างอิง2)

ตัวอย่าง

Application.MessageBox(‘Hello’,’Title’,MB_YESNOCANCEL Or MB_ICONQUESTION) ;

4. raise Exception.Create(‘Missing parameter’) (อ้างอิง)

ตัวนี้เป็นการแจ้ง Error

และยังมีอีกหลายแบบที่ไม่ได้เอามาแสดงให้ดูนะครับไว้ว่างๆจะมาเล่าให้ฟัง

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response

More from Piyanat Nimkhuntod