Unidad UpdownEdit; La interfaz utiliza Windows, sysutils, clases, controles, stdctrls, comctrls, mensajes; escriba tupdownedit = class (tcustomControl) privado {Declaraciones privadas} Updown: tupdown; Editar: tedit; Fmin: entero; Fmax: entero; Fonchange: tnotifyEvent; Fposition: entero; procedimiento wmsize ( var msg: twmsize); mensaje wm_size; procedimiento setMax (valor const : entero); procedimiento setmin (valor const : entero); procedimiento EDITCHANGE (remitente: tobject); Procedimiento EditKeyPress (remitente: tobject; var key: char); Procedimiento UpdownClick (remitente: tobject; botón: tudBtntype); procedimiento setPosition (valor const : entero); protegido {Declaraciones protegidas} público {Declaraciones públicas} constructor create (Awner: tComponent); anular ; destructor destruir; anular ; publicado {Declaraciones publicadas} Propiedad Max: Integer Read Fmax Write setMax; Propiedad min: Integer Leer fmin write setmin; Posición de la propiedad : Integer Read fposition Write SetPosition; propiedad Onchange: tnotifyEvent lea fonchange escribir fonchange; fin ; registro de procedimientos ; registro de procedimientos de implementación ; Comenzar registroComponents ('Standard', [TUPDAWNEDIT]); fin ; {TupdownEdit} constructor tupdownedit.create (Alowner: tComponent); Comience Herited Crear (Awner); SetBounds (0, 0, 57, 21); Editar: = tedit.create (self); Editar.left: = 0; Editar.top: = 0; Editar.Width: = 40; Editar.align: = Alleft; Editar.Parent: = self; Editar.text: = '0'; // setwindowlong (edit.handle, gwl_style, getwindowlong (edit.handle, gwl_style) o es_number); Updown: = tupdown.create (self); Updown.Height: = altura; // 20; Updown.width: = 14; Updown.left: = edit.width + 1; Updown.Parent: = self; Fmin: = 0; Fmax: = 100; Editar.onchange: = editchange; Edit.OnKeyPress: = editKeyPress; Updown.Onclick: = updownClick; fin ; Destructor Tupdownedit.DestrOY; comenzar edit.free; Updown.Free; heredado ; fin ; procedimiento tupdownedit.editchange (remitente: tobject); Begin updown.position: = strTointDef (edit.text, 0); Fposition: = updown.position; si se asigna (fonchange) entonces fonchange (self); fin ; procedimiento tupdownedit.editkeyPress (remitente: tobject; var key: char); var s: conjunto de char; I: entero; Str, texto: cadena ; begin s: = [#8, '0' .. '9']; if key = #8 entonces salga; Si no (clave en s) , entonces comience la tecla: = #0; Salida; fin ; //控制输入数字的大小if tedit (remitente) .sellength> 0 luego comience texto: = tedit (remitente) .Text; Str: = copy (texto, 1, tedit (remitente) .selstart - 1) + clave + copia (texto, tedit (remitente) .selstart + tedit (remitente) .sellength + 1, longitud (texto)); i: = strtoint (str); Si i> fmax , comience la tecla: = #0; Salida; fin ; Fin a lo otra si strToint (tedit (remitente) .Text + tecla)> fmax luego comience la tecla: = #0; Salida; Finalice más si strToint (tedit (remitente) .Text + tecla) <fmin luego comience la tecla: = #0; Salida; fin ; fin ; procedimiento tupdownedit.setMax (valor const : entero); comenzar fmax: = valor; Updown.max: = fmax; Si strTointdef (edit.text, 0)> fmax luego comience a updown.position: = fmax; Edit.text: = intToStr (fmax); Fposition: = updown.position; fin ; fin ; procedimiento tupdownedit.setmin (valor const : entero); comenzar fmin: = valor; Updown.min: = fmin; if strTointdef (edit.text, 0) <fmin luego comience updown.position: = fmin; Edit.text: = intToStr (fmin); Fposition: = updown.position; si se asigna (fonchange) entonces fonchange (self); fin ; fin ; procedimiento tupdownedit.setPosition (valor const : entero); BEGIN if (valor> = fmin) o (valor <= fmax) luego comience fposition: = value; Updown.Position: = fposition; Edit.text: = intToStr (fposition); si se asigna (fonchange) entonces fonchange (self); fin ; fin ; procedimiento tupdownedit.updownClick (remitente: tobject; botón: tudbtntype); Comience si max = 0 luego comience max: = 100; Updown.max: = max; fin ; Updown.min: = min; Edit.text: = intToStr (updown.position); Editar.setfocus; Editar.selectall; si se asigna (fonchange) entonces fonchange (self); Fposition: = updown.position; fin ; procedimiento tupdownedit.wmsize ( var msg: twmsize); comenzar edit.Width: = ancho - 15; Updown.left: = edit.width + 1; Updown.Height: = altura; heredado ; fin ; fin .