Solar OS API - Articles

Do NOT push my buttons... too much.
I am counting on it.


Specifications:

Let us define what this application should do:

here is the code


;-----------------------------------------------------
; a counter for the number of clicks on the button
;-----------------------------------------------------
btn_click_count			dd	0

;--------------------------------------
; strings we will use for captions
;--------------------------------------
app_test_main_caption		db	"App Test Button",0
app_test_btn_caption		db	"Push Me!",0

;----------------------------
; Application Initialization
;----------------------------
App_Test_Init PROC STDCALL
	USES	esi
	LOCAL	@@main_handle:dword, @@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	[@@main_handle],eax

	;------------------------------------
	; 2) Set main window caption
	;------------------------------------
	Call	API_Window_Set_Caption STDCALL,[@@main_handle],offset app_test_main_caption


	;------------------------------------------------
	; 3) Create a Button as a child of  main window
	;------------------------------------------------
	mov	eax,FLAG_WND_NO_RESIZE+FLAG_WND_NO_MOVE
	Call	API_Window_Create STDCALL,[@@main_handle],32,32,128,22,eax,WND_TYPE_BUTTON
	mov	[@@wnd_handle],eax

	;-----------------------------------------------
	; 4) set callback and caption for the button
	;-----------------------------------------------
	Call	API_Window_Set_Callback STDCALL,[@@wnd_handle],OS_CALL_AFTER,offset App_Test_Btn_Callback
	Call	API_Window_Set_Caption STDCALL,[@@wnd_handle],offset app_test_btn_caption

	;--------------------------------------------
	; 5)The End
	; - return the main window handle
	;--------------------------------------------
	mov	eax,[@@main_handle]
	ret
ENDP



;-------------------------------------------
; The Callback routine for  Button
;-------------------------------------------
App_Test_Btn_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_LEFT_DOWN_CHILD

		;--------------------------------------------------------
		; increment a counter for each button click
		;--------------------------------------------------------
		inc	[btn_click_count]

	.ENDIF

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


;-------------------------------------
; End of application
;-------------------------------------

Remarks: