Statistics

Members: 1925
News: 293
Web Links: 1
Visitors: 3825248

Who's Online

We have 1 guest online
Damn Vulnerable LinuxDamn Vulnerable Linux (DVL) is a Linux-based (modified Damn Small Linux) tool for IT-Security & IT-Anti- Security and Attack & Defense. [CLICK HERE FOR MORE INFOS! ]

Featured Conference Video

T16-Recon2006-Joe_Stewart-OllyBonE.gif OllyBone - Semi-Automatic Unpacking on IA-32. View the conference video here!
Home arrow Articles - Programming arrow Assembly arrow Creating a User-Friendly Interface
Creating a User-Friendly Interface
User Rating: / 0
PoorBest 
Written by S Sirajudeen   


Now a days, a programmer of any language has to include user friendly features in his commercial software, since users desire user friendliness for easy use. For example, Windows is the most popular OS due to its Graphical User Interface.

For an assembly language programmer who tries to develop a DOS-based program, it is drudgery and challenging to incorporate even a few basic features of graphical interface like that of Windows.

Sometimes, in assembly language, the time taken to develop the core of a software may be very less than writing code for its user interface. For instance, assume that we're writing an addition program which displays a dialog box to input two numbers and displays result in a dialog box. Here,the dialog box is the user interface. What we have to do in this program is,

  • Displaying a dialog box.
  • Receiving the numbers to be added as string.
  • Checking the string whether it contains alphabets and graphics characters. If so, prompting the user to reenter the numbers.
  • Converting the ASCII digits into binary form.
  • Performing binary multibyte addition..
  • Converting sum which is binary into ASCII digits.
  • Displaying sum in a dialog box. Our intention is only the addition of two numbers. But we have to spend more time in the user interface design than for addition.

As I say these things, you may become frustrated and decide to skip user interface design. Still, in developing utilities or packages for commercial purpose, a programmer will have to do these things to accomodate users. This is why I present this article.

This article will focus on user friendly features in DOS text mode. In DOS text mode, user friendly means features such as menus, message box, dialog box, list box, text window, radio button, status bar, mouse support etc.

In this article, I will cover only an about message box and a dialog box. However, knowledge of interrupts (for screen and mouse handling) is essential, even for a C/C++ programmer, to incorporate user friendly features in a DOS based program.

GETTING STARTED:

Before going on, some things must be cleared.

i) A text can be displayed in one of the following ways

  1. Direct access of video memory
  2. Using INT 21h
  3. Using INT 10h In the examples of this article, I have used the function 0Eh of INT 10h to display text.

ii) To make the example programs as straightforward, I have used |, -

and + as the box characters in the dialog box, since actual box characters are EXTENDED ASCII characters which are not allowed in a text article.

The content of dialog box is labeled as DIALOG_BOX_TEXT.

Before compiling this program, in the content of the dialog box, PLEASE REPLACE the characters |, - and + with the BOX CHARACTERS which are specified below.


ASCII code Description

179 | Vertical bar

196 -- Horizontal bar

218 | Upper left corner

191 | Upper right corner

192 |_ Lower left corner

217 _| Lower right corner


EXAMPLE 1:

First of all, we're going to put a zooming message box in our program. It is an introduction to second example.

You may be seen that some utlities such as Norton Utilities display zooming message box to alert users.

What this program does is

  • n boxes of different size, are continously displayed one after another for n seconds each. In this case, each time a box which is larger than previous one is displayed. It seems like the box is zooming.
    LOGIC
    Assume that displaying boxes which are larger than previously displayed box, means enalarging/zooming the previously displayed box. i) Zoom box by n rows ii) Zoom box by n columns iii) Zooming box for n times
  • It displays horizontal and vertical shadows for the box
  • Finally displays text within the box

What you will learn:

       i) Screen handling using BIOS interrupt 10h
ii) An introduction to learn the second example.

Below is the source code of our simple program. ;; +------------------------------------------------------------------------+

;; | Program   : MSGBOX.ASM                                                 |
;; | Purpose   : Demonstration program about Message Box                    |
;; | Assembler : TASM                                                       |

;; +------------------------------------------------------------------------+

;; MACROS in this program : @SetTextMode, @Cursor, @Display, @Window, @Delay ;; PROCEDURES in this program: Message_box, Window ;;///////////////////////////////////////////////////////////////////////;; .386
MODEL USE16 TINY ;; @Always must be TINY model

;;///////////////////////////////////////////////////////////////////////;; DATASEG ;; Initialize variables

RED EQU 4fh ;; @Color values
BLACK EQU 0fh
BLUE EQU 1fh

screen                EQU BLUE
shadow_colour         EQU BLACK 

box_background_colour EQU RED

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; nl EQU 0Dh,0Ah
label dialog_box_text
db nl

db nl,'      +-------------------------+--------------------------------------+'
db nl,'      | ::/ \::::::.            |  Program to Display a Message Box    |'
db nl,'      | :/___\:::::::.          |                                      |'
db nl,'      | /|    \::::::::.        |     Written  By  S.SIRAJUDEEN.       |'
db nl,'      | :|   _/\:::::::::.      |   E-Mail: {
 This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
 }   |'
db nl,'      | :| _|\  \::::::::::.    |                                      |'
db nl,'      | :::\_____\::::::::::.   |       Published in ASMJOURNAL        |'
db nl,'      | ::::::::::::::::::::::. | Internet: asmjournal.freeservers.com |'
db nl,'      |      AsmJournal         |                                      |'
db nl,'      +-------------------------+--------------------------------------+'
db nl,'      |  # If you have any comments or suggestions then please email me|'
db nl,'      |    at {
 This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
 }                                 |'
db nl,'      +----------------------------------------------------------------+'

db nl,nl,nl,nl
count dw $-offset dialog_box_text

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; upper_x equ 08 ;; Upper left corner of the box to be zoomed upper_y equ 37

lower_x equ 08 ;; Lower right corner of the box to be zoomed lower_y equ 39

left_x db upper_x ;; Variables to hold the UPPER LEFT coordinates of the left_y db upper_y ;; next box to be displayed

right_x db lower_x ;; Variables to hold the LOWER RIGHT coordinates of the right_y db lower_y ;; next box to be displayed

shadow_vertical_left_x db upper_x+1 ;; Don't Change! shadow_vertical_left_y db lower_y+1 ;; Coordinates to display the VERTICAL shadow_vertical_right_x db lower_x+1 ;; shadow of message box. shadow_vertical_right_y db lower_y+2

shadow_horizontal_left_x db lower_x+1 ;; Don't Change! shadow_horizontal_left_y db upper_y+2 ;; Coordinates to display the HORIZONTAL shadow_horizontal_right_x db lower_x+1 ;; shadow of message box shadow_horizontal_right_y db lower_y+2

;;//////////////////////////////////////////////////////////////////////;; UDATASEG

DW 100H DUP (?)
MyStack LABEL WORD

;;--------------------------< @SetTextMode >------------------------;; @SetTextMode MACRO

             mov ax,0003h
int 10h
ENDM  ;;End of macro

;;----------------------------< @Cursor >---------------------------;; ;;PURPOSE : Macro to move cursor
;;SYNTAX : @Cursor <row>, <col>

@Cursor MACRO ROW,COL

        mov ah,02        
mov bh,00        
mov dh,ROW
mov dl,COL
int 10h
ENDM    ;;End of macro

;;----------------------------< @Display >---------------------------;; ;;PURPOSE: Macro to display a text
;;SYNTAX : @DISPLAY <text width>, <text address>

@Display MACRO xcount, address

        LOCAL display_text
mov cx, xcount          ;; Number of characters to be displayed
mov bx, offset address
display_text:
mov ah,0Eh              ;; Display the text
mov al,byte ptr [bx]
push bx
mov bh,00
mov bl,07h
int 10h
pop bx
inc bx                  ;; Point to next character
loop far ptr cs:display_text
ENDM    ;;End of macro

;;-----------------------------< @Window >----------------------------;; ;;PURPOSE : Macro to display a window with a given color as background ;;SYNTAX : @window <bacground color>,

;;                  <Upper letf row of user window>, <Upper left column>,
;;                  <Lower right row of user window>, <Lower right column>

@window MACRO color, lrow, lcol, rrow, rcol

        mov ah,06
mov al,00
mov bh, color     ;; Background Color
mov ch, lrow
mov cl, lcol
mov dh, rrow
mov dl, rcol
int 10h
ENDM    ;;End of macro

;;-----------------------------< @Delay >-----------------------------;; @delay MACRO

        mov ah,86h       ;; Execute a time delay
mov dx,4500h ;;9000
mov cx,0000h
int 15h
ENDM    ;;End of macro

;;///////////////////////// MAIN PROGRAM /////////////////////////////;;

CODESEG                  ;; This marks the start of executable code
STARTUPCODE
mov sp,offset MyStack
push cs          ;; Initialize segment registers.
pop ds
push cs
pop ss
mov ah,0Bh       ;; Display screen border in WHITE color
mov bx,0007h
int 10h
call message_box ;; Display the message box
mov ax,4C00h     ;; Terminate the program.
int 21h

;;//////////////////////////// Message_box ///////////////////////////;; Message_box PROC

        @SetTextMode
@cursor 00,00                  ;; Position cursor at 00,00.
@window screen,00,00,24,79     ;; @Clear screen

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;;

mov cx,0008h ;; Don't change! Calculate how many times to zoom. zoom:

        push cx       ;; @@Display a window which is zooming.
call window
pop cx
loop zoom

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;;

@display count, dialog_box_text

ret
Message_box ENDP

;;/////////////////////////// Window ///////////////////////////////;; Window PROC
;;Display a window with BLUE colour as background.

@window box_background_colour, left_x, left_y, right_x, right_y

       dec byte ptr left_x
sub cl,5
mov byte ptr left_y,cl
inc byte ptr right_x
add dl,5
mov byte ptr right_y,dl

;;---------------------------------------------------------------------;; ;;Display a horizontal shadow.

       @window shadow_colour,shadow_vertical_left_x,shadow_vertical_left_y,
shadow_vertical_right_x,shadow_vertical_right_y
dec byte ptr shadow_vertical_left_x
add cl,5 
mov  byte ptr shadow_vertical_left_y,cl
inc byte ptr shadow_vertical_right_x
add dl,5
mov  byte ptr shadow_vertical_right_y,dl

;;--------------------------------------------------------------------;; ;;Display a horizontal shadow.

       @window shadow_colour,shadow_horizontal_left_x, shadow_horizontal_left_y,
shadow_horizontal_right_x,shadow_horizontal_right_y
inc byte ptr shadow_horizontal_left_x
sub cl,5
mov byte ptr shadow_horizontal_left_y,cl
inc byte ptr shadow_horizontal_right_x
add dl,5
mov byte ptr shadow_horizontal_right_y,dl

;;--------------------------------------------------------------------;;

@delay

ret
Window ENDP

END
;;////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\;;

EXAMPLE 2:

Well, next we're going to put a DIALOG BOX in our program.

What it does is:

  • Displays a dialog box with YES and NO buttons
  • Supports button selection using mouse

    (i) Checks for mouse installation (ii) Shows mouse pointer (iii) Captures button click of the left mouse button

  • Checks for keyboard input (i) Checks whether EXTENDED keys has pressed (ii) Checks whether ENTER or TAB key has pressed
  • Toggles button selection, on presssing TAB, LEFT ARROW key or RIGHT ARROW key.
  • On pressing ENTER key or clicking OK/YES button, displays different messages according to button selection and terminates.

What we will learn from this example is:

       (i) Mouse handling
(ii) Screen handling using BIOS interrupt 10h
(iii) Key board handling using BIOS interrupt 16h
(iv) Idea of user interface design

I made the following program very straightforward and ignored code optimization to reduce complexity.
;; +-------------------------------------------------------------------------+ ;; | Program : DLGBOX.ASM | ;; | Purpose : Demonstration program about Dialog Box with YES & NO button |

;; | Features  : Supports mouse for button selection                         |
;; | Assembler : TASM                                                        |
;; | Required Knowledge: INT 21h, INT 10h, INT 16h, INT 33h & Scan Code      |

;; +-------------------------------------------------------------------------+

;; MACROS in this program : @Cursor, @Display, @window, @Yes & @No ;; PROCEDURES in this program: Dialog_box ;;///////////////////////////////////////////////////////////////////////;; .386
MODEL USE16 TINY ;; @Always must be TINY model

;;///////////////////////////////////////////////////////////////////////;; DATASEG ;; Initialize variables

mouse db 'n' ;; Flag to indicate the availability of mouse

mouse_x db 0 ;; Keep track of position of mouse cursor mouse_y db 0

m_x dw 00
m_y dw 00

left_mouse_button db 0 ;; Flag updated on clicking the left mouse button

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; RED EQU 4fh ;; @Color values
CYAN EQU 3fh
BLACK EQU 0fh
BLUE EQU 1fh
WHITE EQU 7fh

box_height EQU 10
box_width EQU 46

left_x EQU 7 ;; Upper left corner of user window left_y EQU 20

right_x EQU left_x+box_height-1 ;; Calculate lower right corner of user window right_y EQU left_y+box_width-1

upper_left_row db left_x
upper_left_col db left_y

box_background_color EQU RED ; Background color of dialog box

nl EQU 0Dh,0Ah ; New line

label dialog_box_text
db '+--------------- USER COMMENT ---------------+' ;Dialog box. The variable

db '|                                            |' ;dialog_box_text contains
db '|         Written By S.Sirajudeen            |' ;10 lines; width of each 
db '|      E-mail: {
 This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
 }      |' ;line is 46 characters.
db '|                                            |' 
db '|       HAVE YOU ENJOYED THIS PROGRAM?       |' ;NOTE: 
db '|                                            |' ;If you edit here, you
db '|              Yes #       No  #             |' ;should UPDATE the
db '|            #######     #######             |' ;text_width and

db '+--------------------------------------------+' ;text_line_count. count dw $-offset dialog_box_text

text_line_count EQU 10 ;; Variable dialog_box_text contains 10 lines text_width EQU 46 ;; and width of each line is 46 characters

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; shadow EQU WHITE ;; color of button shadow

;;NOTE: Width of 'yes' and 'yes_button' should be same.

yes_button      db 17,' Yes ',16  ;; Displayed on YES button has selected
yes             db '  Yes  '

yes_horz_shadow db 7 dup(223)
yes_char_count EQU 7

;;NOTE: Width of 'no' and 'no_button' should be same.

no_button      db 17,'  No ',16   ;; Displayed on NO button has selected
no             db '   No  '

no_horz_shadow db 7 dup(223)
no_char_count EQU 7

vert_shadow db 220

yes_x EQU right_x-2 ;; Coordinate where YES button to displayed yes_y EQU left_y+(box_width/2)-yes_char_count-4 ;;32

no_x EQU right_x-2 ;; Coordinate where NO button to displayed no_y EQU left_y+(box_width/2)+1 ;;44

select EQU BLUE ;; @Background color to highlight the button selection unselect EQU BLACK

button db 'y' ;; @Flag to keep track of the button selection. If the value

;; is 'y', the YES button has selected; 'n' for the NO button.

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;;

label thank_you      ;; Message to be displayed upon YES button has pressed
db 07,'                        Written By S.SIRAJUDEEN',nl
db '4/55,L.M.BUILDING,KUMARESAPURAM,KUTHAPAR(PO),TRICHY-620013,TAMILNADU,INDIA'
db nl,'                      Email: {
 This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
 }'
db nl,nl,'                            Thank you! Good-bye!!'

thank_you_count dw $-thank_you

label suggest        ;; Message to be displayed upon NO button has pressed
db 7h,'        If you have any comments or suggestions, then please mail me at'
db nl,'                               {
 This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
 }'

db nl
suggest_count dw $-suggest

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; ;; -------------+----------- When a key has pressed, it returns a code. ;; |Extended Keys| Scan Code | This code is called SCAN CODE. ;; |-------------+-----------| Alphanumeric keys, tab, space and escape

;; | Left Arrow  |    75     | keys return one byte code. But Extended
;; | Right Arrow |    77     | keys return two bytes code. The first byte
;; | Up Arrow    |    72     | always 0. The second is the actual scan code.
;; | Down Arrow  |    80     | Arrow keys, Home, End, PageUp, Page Down,
;;  -------------+-----------  Insert, Delete, Function keys, Pause/break,
;;                             Scroll Lock & Print Screen are called EXTENDED
;;                             KEYs.
LEFT_ARROW  equ 75  ;; Scan code of LEFT ARROW key is 75
RIGHT_ARROW equ 77  ;;      ,,      RIGHT ARROW keyis 77
TAB_KEY     equ 9   ;; Scan code of TAB key is 9
ENTER_KEY   equ 13  ;;      ,,      ENTER key is 13

;;//////////////////////////////////////////////////////////////////////;; UDATASEG

DW 50H DUP (?)
MyStack LABEL WORD

;;----------------------------< @Cursor >---------------------------;; ;;PURPOSE : Macro to move cursor
;;SYNTAX : @Cursor <row>, <col>

@Cursor MACRO ROW,COL

        mov ah,02        
mov bh,00        
mov dh,ROW
mov dl,COL
int 10h
ENDM    ;;End of macro

;;----------------------------< @Display >---------------------------;; ;;PURPOSE: Macro to display a text
;;SYNTAX : @DISPLAY <text width>, <text address>

@Display MACRO xcount, address

        LOCAL display_text
mov cx, xcount          ;; Number of characters to be displayed
mov bx, offset address
display_text:
mov ah,0Eh              ;; Display the text
mov al,byte ptr [bx]
push bx
mov bh,00
mov bl,07h
int 10h
pop bx
inc bx                  ;; Point to next character
loop far ptr cs:display_text
ENDM    ;;End of macro

;;----------------------------< @window >-----------------------------;; ;;PURPOSE : Macro to display a window with a given color as background ;;SYNTAX : @window <bacground color>,

;;                  <Upper letf row of user window>, <Upper left column>,
;;                  <Lower right row of user window>, <Lower right column>

@window MACRO color, lrow,lcol, rrow, rcol

        mov ah,06
mov al,00
mov bh, color  ;;Background Color
mov ch, lrow
mov cl, lcol
mov dh, rrow
mov dl, rcol
int 10h
ENDM    ;;End of macro

;;------------------------< @button_shadow >--------------------------;; ;;PURPOSE ; Macro to pad the button with horizontal and vertical char to ;; make it as 3D button.
@button_shadow MACRO

@Cursor yes_x+1, yes_y+1 ;; Display horizontal shadow of YES button @Display yes_char_count, yes_horz_shadow

@Cursor yes_x, yes_y+yes_char_count ;; Display vertical shadow @Display 1, vert_shadow

@Cursor no_x+1, no_y+1 ;; Display horizontal shadow of NO button @Display no_char_count, no_horz_shadow

@Cursor no_x, no_y+no_char_count ;; Display vertical shadow @Display 1, vert_shadow

ENDM

;;-----------------------------< @Yes >-------------------------------;; ;;PURPOSE : Macro to select the YES button. ;; In other words, a window which is used as YES button is displayed

@Yes MACRO

mov button, 'y' ;; DON'T CHANGE! ; Update flag @window select, yes_x, yes_y, yes_x, yes_y+(yes_char_count-1) @window unselect, no_x, no_y, no_x, no_y+(no_char_count-1)

@Cursor yes_x,yes_y ;; Move cursor to YES button @Display yes_char_count,yes_button ;; Display label of YES

    @Cursor no_x,no_y                   ;; Move cursor to NO button
@Display no_char_count, no          ;; Display label of NO button

ENDM ;;End of macro

;;-----------------------------< @No >--------------------------------;; ;;PURPOSE : Macro to select the NO button ;; In other words, a window which is used as NO button is displayed

@No MACRO

mov button, 'n' ;; DON'T CHANGE! ; Update flag @window unselect,yes_x, yes_y, yes_x, yes_y+(yes_char_count-1) @window select, no_x, no_y, no_x, no_y+(no_char_count-1)

@Cursor yes_x,yes_y
@Display yes_char_count, yes
@Cursor no_x,no_y
@Display no_char_count, no_button

ENDM ;;End of macro

;;//////////////////////// MAIN PROGRAM /////////////////////////////;;

CODESEG                   ;;This marks the start of executable code
STARTUPCODE             
mov sp,offset MyStack
push cs           ;;Initialize segment registers.
pop ds
push cs
pop ss

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;;

@window BLACK, 00, 00, 24, 79 ;;@Clear screen

call Dialog_box ;;Display the dialog box

display thank u

cmp button,'y' ;; Check whether YES button has pressed/clicked jne display_suggestion

        @Display thank_you_count, thank_you
jmp _end
display_suggestion:       ;; NO button has pressed/clicked
@Display suggest_count, suggest

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; _end:

        mov ax,4C00h       ;; Terminate the program.
int 21h

;;/////////////////////////// Dialog_box ////////////////////////////;; Dialog_box PROC

     mov ax,0003 ;; Don't change! Set text mode in 3. Changing this mode
int 10h     ;; causes different resolution. Mouse movement is converted
;; into rows and columns based on the resolution of text mode.
mov ax,00   ;; Reset mouse
int 33h
cmp ax,00   ;; Check for error
je start
mov ax,01   ;; Show mouse pointer
int 33h
mov mouse, 'y'

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; start:

@window box_background_color,left_x,left_y,right_x,right_y ;;Display a BOX

@Cursor left_x,left_y ;; Move cursor to upper left corner of dialog box

     mov cx, text_line_count           ;; Display n lines as dialog box text
mov bx, offset dialog_box_text    ;; Address of text
next_line:                                     
push bx                           ;; OUTER LOOP
push cx
mov cx,00                   ;; INNER LOOP
mov cl, text_width
display_text:
mov ah,0Eh                  ;; Display the text
mov al,byte ptr [bx]
push bx
mov bh,00
mov bl,07h
int 10h
pop bx
inc bx
loop far ptr cs:display_text ;; INNER LOOP
pop cx
pop bx
mov dx,00               ;; Calculate address of next line
mov dl, text_width
add bx, dx
inc byte ptr upper_left_row
push bx
@Cursor upper_left_row, upper_left_col ;; Move cursor to next line within
pop bx                                 ;; dialog box
loop far ptr cs:next_line              ;; OUTER LOOP
@button_shadow

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; _yes:

@Yes ;; Select the YES button

     cmp left_mouse_button,01
je endproc
jmp mouse_check
no

@No ;;Select the NO button

     cmp left_mouse_button,01
je endproc
mouse check

cmp mouse, 'y' ;; Check whether mouse is available jne key_check

     mov ax,03       ;; Get mouse cursor position
int 33h
mov left_mouse_button,bl
mov word ptr m_x,dx 
mov word ptr m_y,cx 
mouse button

and left_mouse_button, 01 ;; Check whether left mouse button has pressed

     cmp left_mouse_button, 01
jne key_check
mouse row

mov mouse_x,0 ;; Mouse movement is converted into rows and columns

;; to calculate the position of mouse cursor cmp word ptr m_x,00 je mouse_col

     mov ax,word ptr m_x   ;; In the text mode 3, to calculate the current ROW,
mov bl,8              ;; divide the position value for VERTICAL movement
div bl                ;; by 8.
mov mouse_x, al
mouse col

mov mouse_y,0 ;; Mouse movement is converted into rows and columns

;; to calculate the position of mouse cursor cmp word ptr m_y,00 je key_check

     mov ax, word ptr m_y  ;; In the text mode 3, to calculate the current COLUMN,
mov bl,8              ;; divide the position value for HORIZONTAL movement
div bl                ;; by 8.
mov mouse_y, al
mouse yes

mov al, mouse_x cmp al, yes_x ;; Check whether mouse has clicked anywhere on jne mouse_no ;; the row where YES button is displayed

mov al, mouse_y

     cmp al, yes_y
jb mouse_no
cmp al, yes_y+(yes_char_count-1)
ja mouse_no
mov button, 'y'
jmp _yes
mouse no

mov al, mouse_x cmp al, no_x ;; Check whether mouse has clicked anywhere on jne key_check ;; the row where NO button is displayed

mov al, mouse_y

     cmp al, no_y
jb key_check
cmp al, no_y+(no_char_count-1)
ja key_check
mov button, 'n'
jmp _no
key check

mov ah,01 ;; @Check whether any character is in keyboard buffer int 16h jz mouse_check mov ah,08 ;; @Receive character without echoing to screen int 21h

     cmp al, TAB_KEY     ;; Check whether TAB key has pressed
je _left
cmp al,ENTER_KEY    ;; Check whether ENTER key has pressed.
je endproc        ;; Exit program
cmp al,00           ;; @Check whether any Extended Key has pressed.
jne mouse_check
mov ah,08 
int 21h
cmp al, LEFT_ARROW  ;; Check whether LEFT ARROW key  has  pressed
je _left
cmp al, RIGHT_ARROW ;; Check whether RIGHT ARROW key  has  pressed
je _right
jmp  mouse_check

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -; _left:

     cmp button,'y'
je _no
jmp _yes
right

cmp button,'y' je _no jmp _yes

;;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;; endproc:

@Cursor right_x+1, 0 ;; Move cursor below the dialog box

     mov ax,02               ;; Hide mouse cursor
int 33h
RET
Dialog_box ENDP              ;; End of procedure

END ;; End of program
;;////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\;;

Now, we have written a superb user friendly program. If you want to embed the above examples in your work, you may have to heavily change these programs, but the basic principles will be the same.

Please, e-mail me your comments and suggestions at { This e-mail address is being protected from spam bots, you need JavaScript enabled to view it }