Attached is the source code that I wrote as an example of my understanding of making a component. It's a text or edit box that accepts only numbers, and only accepts one decimal point.
I'm sure everyone can improve on it.
The dll code is :
*******************************************************
#DIM ALL
#COMPILE DLL "V6NOBOX.DLL"
#INCLUDE "C:\ezgui50pro\includes\ezgui50.inc"
#IF NOT %DEF(%WINAPI)
#INCLUDE "win32api.inc" 'add win32api if not already added
#ENDIF
FUNCTION LIBMAIN (BYVAL hInst&, BYVAL FReason&, BYVAL lpR&) AS LONG
SELECT CASE FReason&
CASE 0 ' %DLL_PROCESS_DETACH
CASE 1 ' %DLL_PROCESS_ATTACH
CASE 2 ' %DLL_THREAD_ATTACH
CASE 3 ' %DLL_THREAD_DETACH
CASE ELSE
END SELECT
FUNCTION=1
END FUNCTION
' Component include file!
#INCLUDE "C:\ezgui50pro\components\V99frmNo.bas"
SUB EZ_InitComponent(BYVAL CMPPrefix$) EXPORT
EZ_NOBOX_InitComponent CMPPrefix$
END SUB
***************************************************
The component code is as follows:
' *************************************************************************************
' Code Generated by EZGUI Professional Visual Designer 5.0
' Portions: Copyright Christopher R. Boss, 2003 to 2011 All Rights Reserved !
' Registered EZGUI 5.0 users may use generated code Royalty Free !
' *************************************************************************************
'
' -----------------------------------------------------------------------------------------
' WARNING ! Do Not Modify any code WITHIN Protected Sections !
' You can add code (Sub,Function,etc.) BEFORE any Protected Routine by using the following
' CODE TAGS: '<<SAVE>> '<<END>> and the Designer will not remove it.
' -----------------------------------------------------------------------------------------
'
' ======================================
' [PROTECTED CODE] Do NOT Edit !
' ======================================
DECLARE SUB EZ_NOBOX_InitComponent(BYVAL CMPPrefix$)
DECLARE SUB EZ_NOBOX_Design()
DECLARE SUB EZ_NOBOX_ParseEvents(CID&, CMsg&, CVal&, Cancel&)
DECLARE SUB NOBOX_Events(CID&, CMsg&, CVal&, Cancel&)
%NOBOX_Width = 50
%NOBOX_Height = 2
' ------------------------------------------------
%NOBOX_TXTNO = 100
DECLARE SUB NOBOX_TXTNO_Events(MyID&, CMsg&, CVal&, Cancel&)
DECLARE SUB NOBOX_TXTNO_SubClass(BYVAL CVal&, Cancel&)
'<<BEGINFORM>> "NOBOX"
' ======================================
' [PROTECTED CODE] Do NOT Edit !
' ======================================
SUB EZ_NOBOX_InitComponent(BYVAL CMPPrefix$) ' (PROTECTED)
EZ_DefComponent CMPPrefix$+"NOBOX", "||NOBOX.bas", CODEPTR(EZ_NOBOX_Design), CODEPTR(EZ_NOBOX_ParseEvents)
END SUB
SUB EZ_NOBOX_Design() ' (PROTECTED)
LOCAL CText$
EZ_Color-1,-1
EZ_UseFont 4
EZ_SubClass 2
EZ_Text %NOBOX_TXTNO, 0, 0, 20, 2, "", ">EST"
EZ_SubClass 0
' -----------------------------------------------
END SUB
SUB EZ_NOBOX_ParseEvents(CID&, CMsg&, CVal&, Cancel&) ' (PROTECTED)
SELECT CASE CID&
CASE %EZ_Window
NOBOX_Events CID&, CMsg&, CVal&, Cancel&
CASE %NOBOX_TXTNO
NOBOX_TXTNO_Events CID&, CMsg&, CVal&, Cancel&
IF CMsg&=%EZ_SubClass THEN
NOBOX_TXTNO_SubClass CVal&, Cancel&
END IF
CASE ELSE
NOBOX_Events CID&, CMsg&, CVal&, Cancel&
END SELECT
END SUB
' ======================================
' [USER ACCESSABLE CODE] You may Edit !
' ======================================
SUB NOBOX_Events(CID&, CMsg&, CVal&, Cancel&)
SELECT CASE CID&
CASE %EZ_Window
SELECT CASE CMsg&
CASE %EZ_Loading
CASE %EZ_Loaded
CASE %EZ_Started
CASE %EZ_Close
CASE ELSE
END SELECT
CASE ELSE
END SELECT
END SUB
SUB NOBOX_TXTNO_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
CASE %EZ_KeyPress
CASE %EZ_Focus
CASE %EZ_Sizing
CASE ELSE
END SELECT
END SUB
SUB NOBOX_TXTNO_SubClass(BYVAL CVal&, Cancel&)
DIM NoOfDP AS LONG
DIM AText AS STRING
DIM SelStart AS LONG
DIM SelEnd AS LONG
AText = ""
LOCAL hCtrl&, Msg&, wParam&, lParam&
EZ_GetSubClass CVal&, hCtrl&, Msg&, wParam&, lParam&
SELECT CASE Msg&
CASE %EZ_KEYDOWN
CASE %WM_CHAR
SELECT CASE wParam&
AText = EZ_GetText ("{ME}",100)
NoOfDP = TALLY(AText,".")
IF NoOfDP > 1 THEN
AText = MID$( AText,1 TO LEN(AText)-1)
SelStart = LEN(AText)
SelEnd = LEN(AText)
EZ_SetText "{ME}", 100, AText
EZ_SendMessage("{ME}",100, %EM_SETSEL, SelStart, SelEnd)
Cancel& = 1
EXIT SUB
END IF
CASE 48 TO 57, 45, 46, 8, 13 'only allow 0 to 9, 8,13 minus, period
CASE ELSE
Cancel& = 1
EXIT SUB
END SELECT
CASE %WM_LBUTTONDOWN
CASE ELSE
END SELECT
END SUB
'<<END ALL FORMS>> UnKnown Routines follow:
#IF %EZ_NOSKIPCODE
#ENDIF 'PARSE END
************************************************************
Hopefully, people can play around with this and improve it.
I have to say, EZGUIPRO makes component design easy.
Chris