Solar OS API - Articles

Hello... Hello...
Is there anybody "in" there?.


Solar OS Hello World

Requirements: How simple is "simple"?

First of all let us define what an typical hello world application should do:

here is the code


;-------------------------------------------
; define strings that will be used below
;-------------------------------------------
app_hello_world_sz_caption	db	"Hello World",0
app_hello_world_sz_msg		db	"Welcome to the Hello World Application!",0

;-----------------------------
; Initialize the Application
;-----------------------------
App_Hello_World_Init PROC STDCALL
	USES	esi
	LOCAL	@@wnd_handle:dword
	
	;------------------------------------
	; 1) Create Main App Window
	;------------------------------------
	mov	eax,FLAG_WND_ALPHA+FLAG_WND_MINI
	Call	API_Window_Create STDCALL,[desk_crt],132,105,240,112,eax,WND_TYPE_TOP
	mov	[@@wnd_handle],eax

	;-------------------------------
	; 2) set callback and caption
	;-------------------------------
	Call	API_Window_Set_Callback STDCALL,[@@wnd_handle],OS_CALL_AFTER,offset App_Hello_World_Main_Callback
	Call	API_Window_Set_Caption STDCALL,[@@wnd_handle],offset app_hello_world_sz_caption

	;--------------------------------------------
	; 3)The End
	;--------------------------------------------
	ret
ENDP

;-------------------------------------------------
; Callback routine for application's main Window
;-------------------------------------------------
App_Hello_World_Main_Callback PROC STDCALL
	USES	ebx,esi
	ARG	@@wnd_handle:DWORD,@@wnd_action:DWORD,@@wnd_param1:DWORD,@@wnd_param2:DWORD	

	;--------------------------------------
	; a case based on message/event value
	;--------------------------------------
	.IF [@@wnd_action]==ACT_PAINT_CHILD
		;----------------------------------------------
		; Wnd::On_Paint -> here we draw our string
		;----------------------------------------------
		Call	API_Text_Draw STDCALL,[@@wnd_handle],16,32,offset app_hello_world_sz_msg,01fff00h
		
	.ELSEIF [@@wnd_action]==ACT_LEFT_DOWN_CHILD
		;--------------------------------------------------------
		; Wnd::ON_Mouse_Left_Down --> todo: add click code here
		;--------------------------------------------------------

	.ELSEIF [@@wnd_action]==ACT_LEFT_UP_CHILD
		;---------------------------------------------------------
		; Wnd::ON_Mouse_Left_Up --> todo: add click code here
		;---------------------------------------------------------

	.ELSEIF [@@wnd_action]==ACT_KEY_CHILD
		;----------------------------------------------------
		; Wnd::ON_Key --> todo: add keyboard code here
		;----------------------------------------------------

	.ELSEIF [@@wnd_action]==ACT_CLOSE_CHILD
		;--------------------------------------------------
		;Wnd::Destructor --> todo:add code here
		;--------------------------------------------------

	.ENDIF

	;----------------------------------------
	; by convention you must return zero 
	; or the parent will terminate you
	;----------------------------------------
	xor	eax,eax
	ret
ENDP

;-------------------------------------
; End of hello world application
;-------------------------------------

Remarks:

This can be used as a start-up template for writtiong your own SOL_OS applications.

Honestly this is very simple, all you have to do is:

See also: