lunes, 21 de mayo de 2007

sábado, 12 de mayo de 2007

SQL delete

query1.Close;
query1.SQL.Clear;
query1.SQL.Add('delete from historico where id='+inttostr(id)+' and fecha='+#39+Getfecha+#39);
query1.ExecSQL;

SQL insert

query1.Close;
query1.SQL.Clear;
query1.SQL.Add('insert into historico (proveedor,fecha,articulo,talla,pcoste,pvp) values ('+#39+proveedor+#39+','+#39+Getfecha+#39+','+#39+edit1.text+#39+','+#39+edit2.text+#39+','+#39+floattostr(pcoste)+#39+','+#39+floattostr(pvp)+#39+')');
query1.ExecSQL;

DATETIMEPICKER otras funciones posiblemente interesantes

uses
ComCtrls;

const
DTM_SETFORMAT = $1005;

procedure TForm1.Button1Click(Sender: TObject);
var
sFormat: string;
begin
DateTimePicker1.kind := dtkTime;

// Don't show the seconds, Sekunden nicht anzeigen
SendMessage(DateTimePicker1.Handle, DTM_SETFORMAT, 0, Longint(PChar('hh:mm')));

// To show AM/PM
SendMessage(DateTimePicker1.Handle, DTM_SETFORMAT, 0, Longint(PChar('hh:mm tt')));

// 24-hour clock: Be sure to set Kind to dtkTime
DateTime_SetFormat(DateTimePickerTest.Handle, pChar('H:mm:ss'));

// To show Date and Time, Datum und Zeit anzeigen
// Note that you can only edit the date or the time depending
// on the Kind (dtkTime or dtkDate).
SendMessage(DateTimePicker1.Handle, DTM_SETFORMAT, 0, Longint(PChar('dd/MM/yyyy hh:ss')));

// You could also use the DateTime_SetFormat macro:
DateTime_SetFormat(DateTimePicker1.Handle, PChar('M/d/yyy'));

// Instead of using the DateTime_SetFormat function, you can
// send a message to the control directly:
sFormat := 'dd-MMMM-yyyy';
DateTimePicker1.Perform(DTM_SETFORMAT, 0, DWORD(sFormat));
end;

// Show the Week Number in a TDateTimePicker

procedure DateToWeek(dtDate: TDateTime; var AWeek, AYear: Word);
const
FIRST_WEEKDAY: Integer = 2;
FIRST_WEEKDATE: Integer = 4;
var
wMonth, wDay: Word;
begin
dtDate := dtDate - ((DayOfWeek(dtDate) - FIRST_WEEKDAY + 7) mod 7) + 7 - FIRST_WEEKDATE;
DecodeDate(dtDate, AYear, wMonth, wDay);
AWeek := (Trunc(dtDate - EncodeDate(AYear, 1, 1)) div 7) + 1;
end;

procedure TForm1.DateTimePicker1Change(Sender: TObject);
var
sFormat: string;
wWeek, wYear: Word;
begin
DateToWeek(DateTimePicker1.date, wWeek, wYear);
sFormat := 'dd/MM/yy Week:' + IntToStr(wWeek) + '';
DateTimePicker1.Perform(DTM_SETFORMAT, 0, DWORD(sFormat));
end;

procedure TForm1.FormShow(Sender: TObject);
begin
DateTimePicker1Change(Self);
end;

Pasar de tipo WORD a tipo STRING

procedure TForm1.Button1Click(Sender: TObject);
var
mes, dia, ano :Word;
begin
decodedate(datetimepicker1.date , ano, mes, dia);
datetimepicker1.date := encodeDate(ano, mes, DaysInAMonth(ano, mes));

showmessage(inttostr(ano)); // aqui esta la solucion
end;

DATETIMEPICKER funciones utiles

uses // esto hay que meterlo en el uses
dateutils


//********************** numero del mes de un datetimepicker
monthof(datetimepicker1.date);

showmessage(IntToStr(Integer(monthof(datetimepicker1.date))));




//********************** numero del año de un datetimepicker
yearof(datetimepicker1.date);

showmessage(IntToStr(Integer(yearof(datetimepicker1.date))));





//********************** numero del dia de un datetimepicker
dayof(datetimepicker1.date);

showmessage(IntToStr(Integer(dayof(datetimepicker1.date))));



//################################################################################
inicializar un datetimepicker al dia 1 del mes

procedure TForm1.Button1Click(Sender: TObject);
var
mes, dia, ano :word;

begin
decodedate(datetimepicker1.date, ano, mes, dia);
datetimepicker1.date := encodeDate(ano,mes,1);

end;


// inicializarlo al ultimo dia del mes

procedure TForm1.Button1Click(Sender: TObject);
var
mes, dia, ano :Word;
begin
decodedate(datetimepicker1.date , ano, mes, dia);
datetimepicker1.date := encodeDate(ano, mes, DaysInAMonth(ano, mes));
end;



//###############################################################################
con dos datetimepicker poner 1 a dia 1 de un mes y el otro a ultimo dia de ese mes

DateTimePicker1.Date:=Now-DayOf(now)+1;
DateTimePicker2.Date:=Now+(DaysInMonth(now)-DayOf(now));

poner un string entre QUOTES

showmessage(QuotedStr('hola')); // casaria 'hola'


o tambien


showmessage(#39+'hola'+#39);

Como instalar los componentes SOCKET en delphi 7

Solution:
You will need to add the dclsockets package to the IDE.
To do this go to Component | Install Packages | Add (/bin/dclsockets70.bpl).


Pestaña Internet :)

by elpau

SQL entre fechas

query1.Close;
query1.SQL.clear;

dato:='SELECT * from venta where fecha between :f1 and :f2';
query1.SQL.add(dato);

query1.ParamByName('f1').DataType:=ftdate;
query1.ParamByName('f1').Value:=strtodate('11/04/2007');
query1.ParamByName('f2').DataType:=ftdate;
query1.ParamByName('f2').Value:=strtodate('15/04/2007');


query1.Active:=true;

stringgrid

//******************************************************
procedure TForm11.Button2Click(Sender: TObject);
begin

stringgrid1.rowcount:=30; // numero de filas del grid
//stringgrid1.Row:=10;


//stringgrid1.ColWidths[1]:=10;

stringgrid1.Cells[1,0]:='holaaaaaaaaaaaaaa';
stringgrid1.Cells[1,1]:='holaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
stringgrid1.Cells[2,2]:='holaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
stringgrid1.Cells[3,3]:='hola';
stringgrid1.Cells[4,4]:='hola';
stringgrid1.Cells[5,5]:='hola';
stringgrid1.Cells[6,6]:='hola';
stringgrid1.Cells[7,7]:='holaaaaaaaaaaaaaaaaaaa';
stringgrid1.Cells[8,8]:='hola';


end;



//********

stringgrid1.Visible:=true;
stringgrid1.rowcount:=a;

stringgrid1.Cells[1,0]:='ID';
stringgrid1.Cells[2,0]:='Nombre';
stringgrid1.Cells[3,0]:='Apellido';
stringgrid1.Cells[4,0]:='Turno';


// tamaño de columna
stringgrid1.ColWidths[1]:=10;




//***********
para q no deje editar una celda y las demas si

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin



if (acol = 2) and (arow = 1) then
StringGrid1.Options :=StringGrid1.Options-[goediting]
else
StringGrid1.Options :=StringGrid1.Options+[goediting];

end;

Redondear un float

uses math
---------------------------------------


// truncar

function Redondear(Valor: Real; Redondeo: Integer):Real;
begin
Redondear := Trunc(Valor * Power(10, Redondeo)) / Power(10,Redondeo);
end;

// redondear

function Redondear(Valor: Real; Redondeo: Integer):Real;
begin
Redondear := Round(Valor * Power(10, Redondeo)) / Power(10,Redondeo);
end;

//************************

var
numero,aux: real;
dato: string;
begin


dato:='12,4556';

numero:=strtofloat(dato);

aux:=Redondear(numero; 2);
numero:=aux;

dato:=floattostr(numero);

showmessage(dato);

end;

MessageDlg, (mensaje de dialogo)

procedure TFormPrincipal.SalirClick(Sender: TObject);
var
boton:integer;
begin
boton:=MessageDlg('¿Desea guardar las modificaciones en la Base de Datos?',mtConfirmation,mbYesNoCancel,0);
if boton=6 then
begin
//GUARDA VALORES EN LA BD
Cerrar(Liga);
close;
end
else
if boton=7 then
close;
end;

--------------------


mtWarning A message box containing a yellow exclamation point symbol.
mtError A message box containing a red stop sign.
mtInformation A message box containing a blue "i".
mtConfirmation A message box containing a green question mark.
mtCustom A message box containing no bitmap. The caption of the message box is the name of the application's executable file.

-------------------

mbYes A button with 'Yes' on its face.
mbNo A button the text 'No' on its face.
mbOK A button the text 'OK' on its face.
mbCancel A button with the text 'Cancel' on its face.
mbHelp A button with the text 'Help' on its face
mbAbort A button with the text 'Abort' on its face
mbRetry A button with the text 'Retry' on its face
mbIgnore A button with the text 'Ignore' on its face
mbAll A button with the text 'All' on its face

---------------------

MB_ABORTRETRYIGNORE La ventana contiene tres botones:
Abortar, Reintentar e Ignorar.
MB_ICONEXCLAMATION Aparece un icono de exclamación en la ventana.
MB_ICONINFORMATION Se trata de un icono con una 'i' en un bocadillo.
MB_ICONQUESTION Es un icono con una interrogación.
MB_ICONSTOP Se trata de un icono con un signo de STOP.
MB_OK La ventana contiene un botón de Aceptar.
MB_OKCANCEL La ventana contiene dos botones: Aceptar y Cancelar.
MB_RETRYCANCEL La ventana contiene dos botones: Reintentar
y Cancelar.
MB_YESNO La ventana contiene dos botones: Sí y No.
MB_YESNOCANCEL La ventana contiene tres botones:
Sí, No, y Cancelar.

Si, por ejemplo, queremos una vetana con un icono de exclamación y los botones correspondientes a la constante MB_YESNOCANCEL, pondremos en el parámetro Tipo de la función lo siguiente:


MB_ICONEXCLAMATION + MB_YESNOCANCEL

MessageBeep

The MessageBeep function plays a waveform sound. The waveform sound for each sound type is identified by an entry in the [sounds] section of the registry.

BOOL MessageBeep(

UINT uType // sound type
);


Parameters

uType

Specifies the sound type, as identified by an entry in the [sounds] section of the registry. This parameter can be one of the following values:

Value Sound
0xFFFFFFFF Standard beep using the computer speaker
MB_ICONASTERISK SystemAsterisk
MB_ICONEXCLAMATION SystemExclamation
MB_ICONHAND SystemHand
MB_ICONQUESTION SystemQuestion
MB_OK SystemDefault


Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

After queuing the sound, the MessageBeep function returns control to the calling function and plays the sound asynchronously.
If it cannot play the specified alert sound, MessageBeep attempts to play the system default sound. If it cannot play the system default sound, the function produces a standard beep sound through the computer speaker.
The user can disable the warning beep by using the Control Panel Sound application.

See Also

FlashWindow, MessageBox

Listbox y Findcomponent

cont:=listagrupos.Items.Count; // lineas de un lisbox


for i:=0 to listbox1.Items.Count-1 do
begin

if(listbox1.Selected[i]) then
begin
showmessage(inttostr(i));
end;
end;






sincronizar 4 listbox
/******************

procedure TForm1.ListBox1Click(Sender: TObject);
var
n:byte;
begin
for n:=2 to 4 do
begin
(FindComponent('ListBox'+IntToStr(n))as TListBox).ItemIndex:=
(Sender as TListBox).ItemIndex;
end;
end;


/****************



sincronizar 2 listbox
/******************

procedure TForm1.ListBox1Click(Sender: TObject);
var
n:byte;
begin
for n:=1 to 2 do
begin
(FindComponent('ListBox'+IntToStr(n))as TListBox).ItemIndex:=
(Sender as TListBox).ItemIndex;
end;
end;


/****************

Listar un directorio

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);

procedure RastreaDir(Dir: string);
var
FileSearch: TSearchRec;
begin
chDir (Dir);
FindFirst ('*.*', faDirectory, FileSearch);

while FindNext(FileSearch)=0 do
begin
if (FileSearch.Attr = faDirectory) then
begin
if (FileSearch.Name<>'..') then RastreaDir(Dir+FileSearch.Name+'\');
end else
{Pon aqui lo que quieras hacer con los ficheros encontrados}
{Put here anything to make with the find files}
form1.memo1.lines.add(Dir+FileSearch.Name);
end;
FindClose(FileSearch);
end;

begin
RastreaDir('f:\mp3\viejo\');
end;



end.

ficheros en Delphi

LEER:
~~~~~~~~~~~~~~~~

AssignFile (fic,'hojas.txt');
Reset (fic);
Readln(fic,dato);
CloseFile (fic);



ESCRIBIR:
~~~~~~~~~~~~~~~~

AssignFile (fic,'tac.txt');
Rewrite (fic);
writeln(fic,'fin');
CloseFile (fic);


LEE HASTA FINAL DE FICHERO:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


AssignFile (fic,edit3.text);
Reset (fic);
Readln(fic,dato);


while not EOF(fic) do
begin

showmessage(dato);
Readln(fic,dato);


end;

Fecha y hora del sistema

var

function GetFecha: String;




//************************* fecha y hora
function GetLocalT: String;
var
stSystemTime : TSystemTime;
begin
Windows.GetLocalTime( stSystemTime );
Result := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );
end;
//*************************


//************************* fecha
function GetFecha: String;
var
stSystemTime : TSystemTime;
aux,fecha: string;

begin
Windows.GetLocalTime( stSystemTime );
aux:=DateTimeToStr( SystemTimeToDateTime( stSystemTime ));

fecha:= aux[1]+aux[2]+aux[3]+aux[4]+aux[5]+aux[6]+aux[7]+aux[8]+aux[9]+aux[10];

Result:= fecha;
end;
//*************************

es numero INT un STR ???

function IsStrANumber(NumStr : string) : bool;


//********* comprueba si un combo es numero
function IsStrANumber(NumStr : string) : bool;
begin
result := true;

try
StrToInt(NumStr);
except
result := false;
end;

end;
//****



if IsStrANumber(edit2.Text)=false then
begin
showmessage('El campo UNIDADES debe de ser un número.');
exit;
end;

Imprimir con CANVAS printer

///***************** para hacer lineas

Printer.Canvas.MoveTo(0,0); // punto 1
Printer.Canvas.LineTo(9900,14000); // punto 2


//******************





{
a la hora de imprimir q solo haya trabajado una vez ese dia !!!!!!!!!!
}


unit Unit15;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, DBCtrls, Db, DBTables, ComCtrls, Printers;

type
TForm15 = class(TForm)
Button1: TButton;
Database1: TDatabase;
DataSource1: TDataSource;
Table1: TTable;
DataSource2: TDataSource;
Table2: TTable;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
ComboBox1: TComboBox;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label4: TLabel;
Label5: TLabel;
Button2: TButton;
DBNavigator1: TDBNavigator;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form15: TForm15;
function GetFecha: String;

implementation

uses Unit1;

{$R *.DFM}

//*******************************************************************
procedure TForm15.FormCreate(Sender: TObject);
var
i: integer;
a,b,c,d: integer;
begin

i:=2;
a:=screen.Width;
b:=screen.Height;

form15.left:= (a div i) - form15.width div i;
form15.top:= (b div i) - form15.Height div i;
end;

//**************************************************************
procedure TForm15.Button1Click(Sender: TObject);
begin
form15.hide;
form1.enabled:=true;
form1.show;
end;
//********************************************************
procedure TForm15.FormActivate(Sender: TObject);
var
i: integer;
begin

combobox1.clear;

table1.close;
table1.open;
table1.first;

for i:=0 to Table1.RecordCount-1 do
begin

if table1.Fieldvalues['borrado'] = false then
begin

combobox1.items.add(table1.Fieldvalues['id']);

end; // if

table1.next;

end;

table1.first;

datetimepicker1.date:= strtodate(GetFecha());
datetimepicker2.date:= strtodate(GetFecha());



end;


//*****************************************************************************
procedure TForm15.ComboBox1Change(Sender: TObject);
var
i: integer;
begin

table1.open;
table1.first;


for i:=0 to Table1.RecordCount-1 do
begin

if table1.Fieldvalues['id'] = combobox1.text then
begin
exit;
end; // if

table1.next;

end;

end;


//*************************************************************** fecha
function GetFecha: String;
var
stSystemTime : TSystemTime;
aux,fecha: string;

begin
Windows.GetLocalTime( stSystemTime );
aux:=DateTimeToStr( SystemTimeToDateTime( stSystemTime ));

fecha:= aux[1]+aux[2]+aux[3]+aux[4]+aux[5]+aux[6]+aux[7]+aux[8]+aux[9]+aux[10];

Result:= fecha;
end;
//*************************



//****************************************************************
procedure TForm15.Button2Click(Sender: TObject);
var
aux: string;
veces,x,y,salto,i: integer;
aux2,turno,fechaS,horaE,horaS,llamadas, entrantes, salientes, minutos: string;
begin

veces:=0;
table2.close;
table2.open;
table2.first;

for i:=0 to Table2.RecordCount-1 do
begin

if table2.Fieldvalues['trabajador'] = dbtext1.Field.AsString then
begin

aux2:= datetostr(datetimepicker2.date);

if strtodate(aux2) = table2.Fieldvalues['fechaS'] then
begin

horaE:=table2.Fieldvalues['horaE'];
horaS:=table2.Fieldvalues['horaS'];
fechaS:=table2.Fieldvalues['fechaS'];
llamadas:=table2.Fieldvalues['llamadas'];
entrantes:=table2.Fieldvalues['entrantes'];
salientes:=table2.Fieldvalues['salientes'];
minutos:=table2.Fieldvalues['minutos'];
turno:=table2.Fieldvalues['turno'];
veces:=veces+1;

end;

end;

table2.next;

end;

if (veces=0) then
begin
showmessage('Este empleado no ha trabajado ese día.');
exit;
end;

//showmessage('Imprimiendo ...');


Printer.BeginDoc; // INICIO UN NUEVO DOCUMENTO
With Printer.canvas do //CON EL OBJETO PRINTER.CANVAS HAGO LO SIGUIENTE
Begin
//TITULO QUE APARECE EN LA COLA DE IMPRESION

Printer.Title := 'Impresión de Dia de Trabajo';
Font.Color := ClBlack; //LE ASIGNO UN COLOR A LA LETRA
Pen.Color := ClBlack; //COLOR DE LA LINE DE LOS RECUADROS
Font.Size := 12; //TAMAÑO DE LA LETRA
Font.Name := 'Times New Roman';





aux:= 'Alicante ' + datetostr(datetimepicker1.date);
Printer.Canvas.TextOut(1000,1000,aux);

x:=1500;
y:=2000;

aux:= 'Resumen de Día de Trabajo:';
Printer.Canvas.TextOut(x,y,aux);

x:=1500;
y:=y+800;

aux:= '- ID: ' + dbtext1.Field.AsString;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- NOMBRE: ' + dbtext2.Field.AsString;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- APELLIDOS: ' + dbtext3.Field.AsString + ' ' + dbtext4.Field.AsString;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- DIA: ' + datetostr(datetimepicker2.date);
Printer.Canvas.TextOut(x,y,aux);


y:=y+800;
aux:= '- TURNO: ' + turno;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- HORA ENTRADA: ' + horaE;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- HORA SALIDA: ' + horaS;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- NUM. LLAMADAS: ' + llamadas;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- NUM. LLAMADAS ENTRANTES: ' + entrantes;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- NUM. LLAMADAS SALIENTES: ' + salientes;
Printer.Canvas.TextOut(x,y,aux);

y:=y+300;
aux:= '- NUM. MINUTOS: ' + minutos;
Printer.Canvas.TextOut(x,y,aux);



y:=y+5000;
aux:= 'FIRMA CONFORME:';
Printer.Canvas.TextOut(x,y,aux);

end;

Printer.EndDoc;


end; // fin procedure

end.

crear un UNIT con las funciones globales de todos los formularios

// FORM1

unit Unit1;

interface

uses
(...), unit2; // unit2 es el unit de funciones

(...)

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
a: funciones; // 'a' es el objeto que creamos de la clase funciones

(...)


//**************************************************************
procedure TForm1.Button1Click(Sender: TObject);
begin
a.saludar('pablo'); // funcion de la clase funciones
end;


=========================================================================================================
=========================================================================================================
=========================================================================================================


unit Unit2;

interface


uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, CPort;

type

funciones = class

private
{ Private declarations }
public

procedure saludar(string dato);
procedure timer();
procedure RelojTimer(Sender: TObject);


end;

var
texto: string; // variable global en unit2
Reloj: ttimer;

implementation

//***************************************************************
procedure funciones.saludar(string dato);
begin
showmessage('hola'+dato);
end;

//***************************************************************
procedure funciones.timer();
begin

Reloj := TTimer.Create(Reloj);
Reloj.Interval:=2000; // cada 2 segundos
Reloj.Enabled:=true; // activo el Reloj
Reloj.OnTimer:= RelojTimer; // donde ira cuando pase el tiempo

end;

//***************************************************************
procedure funciones.RelojTimer(Sender: TObject);
begin
showmessage('esto es del reloj');
end;

crear dinamicamente un componente BOTON o TIMER

// boton y timer dinamico


(...)

procedure ClickBoton(Sender: TObject);
procedure RelojTimer(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Boton: TButton;
Reloj: TTimer;

(...)




//*************************************************
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Boton := TButton.Create(Self);
Boton.Parent := Self;
Boton.Left := 100;
Boton.Top := 100;
Boton.Caption:='Pulsame';
Boton.Name := 'Boton';
Boton.OnClick:=ClickBoton;


Reloj := TTimer.Create(Self);
Reloj.Interval:=1000;
Reloj.Enabled:=true;
Reloj.OnTimer:= RelojTimer;
end;


//*************************************************
procedure TForm1.ClickBoton(Sender: TObject);
begin
showmessage('boton pulsado hola');
end;


//*************************************************
procedure TForm1.RelojTimer(Sender: TObject);
begin
showmessage('Reloj');
end;

Caracteres especiales control+Z

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (ssCtrl in Shift) and (chr(Key) in ['Z', 'z']) then
ShowMessage('Ctrl-Z');
end;


//********** para mandar Control-Z en un socket seria
socket.send('hola'+^z)

Combobox

combobox1.Items.Clear; // vacia el combobox

combobox1.items.Add('hola'); // añade una linea al combo

combobox1.items.Count; // numero de lineas en el combo



para que el combo no se pueda editar a mano:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
poner la propiedad STYLE del combo a: opDownList

Apagar el ordenador

//***********
function MyExitWindows(RebootParam: Longword): Boolean;

//********** funcion que apagar el pc
function tform1.MyExitWindows(RebootParam: Longword): Boolean;
var
TTokenHd: THandle;
TTokenPvg: TTokenPrivileges;
cbtpPrevious: DWORD;
rTTokenPvg: TTokenPrivileges;
pcbtpPreviousRequired: DWORD;
tpResult: Boolean;
const
SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
tpResult := OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
TTokenHd);
if tpResult then
begin
tpResult := LookupPrivilegeValue(nil,
SE_SHUTDOWN_NAME,
TTokenPvg.Privileges[0].Luid);
TTokenPvg.PrivilegeCount := 1;
TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
cbtpPrevious := SizeOf(rTTokenPvg);
pcbtpPreviousRequired := 0;
if tpResult then
Windows.AdjustTokenPrivileges(TTokenHd,
False,
TTokenPvg,
cbtpPrevious,
rTTokenPvg,
pcbtpPreviousRequired);
end;
end;
Result := ExitWindowsEx(RebootParam, 0);
end;


//***********************************
procedure TForm1.Button1Click(Sender: TObject);
begin
MyExitWindows(EWX_POWEROFF or EWX_FORCE);
end;