Code: Select all
kernel_imports \
CreateWindow, 0,\
PutPoint, 1,\
GetKeyCode, 2,\
GetSystemTime, 3,\
PutString, 4,\
ButtonService, 8,\
GetMessage, 10,\ ;wait event
BeginPaint, 12 1,\
EndPaint, 12 2,\
GetButtonId, 17,\
ShutDown, 18 1,\
EndThread, 18 2,\
SetWindowFocus, 18 3,\
GetVersionInfo, 18 13,\
GetSystemColors, 48 3,\
ExitProcess, 0xFFFFFFFF
Code: Select all
include "macros.inc"
include "kernel.inc"
MEOS_APP_START
CODE
GetSystemColors sc, sizeof.system_colors ; get system colors
redraw: ; redraw event handler
call draw_window ; at first create and draw the window
wait_event: ; main cycle
GetMessage
dec eax ; if event = 1
jz redraw ; jump to redraw handler
dec eax ; else if event = 2
jz key ; jump to key handler
button: ; button event handler
GetButtonId ; get button identifier
cmp ah, 1
jne wait_event ; return if button id != 1
ExitProcess ; exit application
key: ; key event handler
GetKeyCode ; get key code
jmp wait_event
draw_window:
BeginPaint ; start drawing
; create and draw the window
; (window_cx)*65536+(window_sx)
; (window_cy)*65536+(window_sy)
mov edx, [sc.work] ; work area color
or edx, 0x33000000 ; & window type 3
; window title
CreateWindow 100*65536+200, 100*65536+100, , ,title
EndPaint ; finish drawing
ret
DATA
title db 'Template program',0
UDATA
sc system_colors
MEOS_APP_END