Se está selecionado:
tvwServicos.Focused;
Índice do objeto selecionado:
tvwServicos.Selected.AbsoluteIndex;
Se está selecionado:
tvwServicos.Focused;
Índice do objeto selecionado:
tvwServicos.Selected.AbsoluteIndex;
Function GetCurrentPrinterHandle: THandle; Const Defaults: TPrinterDefaults = ( pDatatype : nil; pDevMode : nil; DesiredAccess : PRINTER_ACCESS_USE or PRINTER_ACCESS_ADMINISTER ); Var Device, Driver, Port : array[0..255] of char; hDeviceMode: THandle; Begin { GetCurrentPrinterHandle } Printer.GetPrinter(Device, Driver, Port, hDeviceMode); If not OpenPrinter(@Device, Result, @Defaults) Then RaiseLastWin32Error; End; { Pega o handle da impressora padrão } { mata todos os trabalhos da impressora } Procedure PurgeJobsOnCurrentPrinter; Var hPrinter: THandle; Begin hPrinter:= GetCurrentPrinterHandle; try If not WinSpool.SetPrinter( hPrinter, 0, nil, PRINTER_CONTROL_PURGE ) Then RaiseLastWin32Error; finally ClosePrinter( hPrinter ); end; End;
Chame utilizando a procedure, assim…
PurgeJobsOnCurrentPrinter;
procedure Imprimir; var iPrinter: TPrinter; PrinterY: Integer; begin iPrinter:= TPrinter.Create; PrinterY:= 0; iPrinter.Title:= 'MEUSISTEMA - Cupom'; //Se a impressora estiver imprimindo, espera While Printer.Printing Do Sleep(100); iPrinter.BeginDoc; iPrinter.Canvas.Font.Name:='Courier'; iPrinter.Canvas.Font.Style:=[fsBold]; iPrinter.Canvas.Font.Size:=13; iPrinter.Canvas.Font.Size:=18; iPrinter.Canvas.TextOut(0,PrinterY,'CUPOM TESTE SISTEMA'); Inc(PrinterY,38); iPrinter.Canvas.Font.Size:=13; iPrinter.Canvas.TextOut(0,PrinterY,'TESTE'); Inc(PrinterY,30); iPrinter.Canvas.TextOut(0,PrinterY,'--------------------'); Inc(PrinterY,30); iPrinter.Canvas.Font.Size:= 18; iPrinter.Canvas.TextOut(0,PrinterY,'OUTRO TESTE'); Inc(PrinterY,50); iPrinter.EndDoc; iPrinter.Free;
function FileSetAttr(const FileName: string; Attr: Integer): Integer;
Exemplo:
FileSetAttr ('C:\logo.sys',0);
Onde Attr:Interger:
0=Sem Atributos;
1=Somente Leitura;
2=Oculto;
3=Somente Leitura e Oculto;
4=Sistema;
5=Somente Leitura e Sistema;
6=Sistema e Oculto;
7=Somente Leitura,Sistema e Oculto;
function ProcessArquivo(const Origem, Destino : string; Operacao, Modo:Integer) : Boolean; // Requer a unit ShellApi na clausula uses da unit Const Aborted : Boolean = False; var shfo : TSHFileOpStruct; begin FillChar(shfo,SizeOf(shfo),$0); with shfo do begin if Operacao > 2 then begin operacao := 2; end; if Modo > 5 then begin modo := 1; end; case operacao of 1: wFunc := FO_MOVE; 2: wFunc := FO_COPY; end; pFrom := Pchar(Origem); pTo := Pchar(Destino); case Modo of 1: fFlags := FOF_SILENT; 2: fFlags := FOF_ALLOWUNDO or FOF_FILESONLY; 3: fFlags := FOF_RENAMEONCOLLISION; 4: fFlags := FOF_NOCONFIRMATION; 5: fFlags := FOF_SIMPLEPROGRESS; end; end; Result := (SHFileOperation(shfo)= 0) and (not Aborted); end;
function TamArquivo(Arquivo: string): Integer; begin with TFileStream.Create(Arquivo, fmOpenRead or fmShareExclusive) do try Result := Size; finally Free; end; end;
Solução enviada por Dennis Göhlert (Berlin/German):
function GetFileSize(const szFile: String): Int64; var fFile: THandle; wfd: TWIN32FINDDATA; begin result := 0; if not FileExists(szFile) then exit; fFile := FindFirstfile(pchar(szFile),wfd); if fFile = INVALID_HANDLE_VALUE then exit; result := (wfd.nFileSizeHigh*(MAXDWORD))+wfd.nFileSizeLow; windows.FindClose(fFile); end;
const Codes64 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/'; function Encode64(S: string): string; var i: Integer; a: Integer; x: Integer; b: Integer; begin Result := ''; a := 0; b := 0; for i := 1 to Length(s) do begin x := Ord(s[i]); b := b * 256 + x; a := a + 8; while a >= 6 do begin a := a - 6; x := b div (1 shl a); b := b mod (1 shl a); Result := Result + Codes64[x + 1]; end; end; if a > 0 then begin x := b shl (6 - a); Result := Result + Codes64[x + 1]; end; end; function Decode64(S: string): string; var i: Integer; a: Integer; x: Integer; b: Integer; begin Result := ''; a := 0; b := 0; for i := 1 to Length(s) do begin x := Pos(s[i], codes64) - 1; if x >= 0 then begin b := b * 64 + x; a := a + 6; if a >= 8 then begin a := a - 8; x := b shr a; b := b mod (1 shl a); x := x mod 256; Result := Result + chr(x); end; end else Exit; end; end;
Sabendo-se que a busca ignorando caracteres NÃO FUNCIONA no Microsoft Access, a solução foi criar múltiplos parametros de busca, utilizando a formula a seguir (desenvolvida em Pascal).
//busca inteligente por nomes strBuscaNome:= '([mensalistas].NomeCliente LIKE "%'+strBusca+'%")'; //áäàãâÁÄÀàstrBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'a','á',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'a','ä',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'a','à',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'a','ã',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'a','â',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'A','Á',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'A','Ä',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'A','À',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'A','Ã',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'A','Â',[rfReplaceAll])+'%")'; //éëèêÉËÈÊ strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'e','é',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'e','ë',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'e','è',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'e','ê',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'E','É',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'E','Ë',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'E','È',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'E','Ê',[rfReplaceAll])+'%")'; //íïìîÍÏÌÎ strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'i','í',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'i','ï',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'i','ì',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'i','î',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'I','Í',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'I','Ï',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'I','Ì',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'I','Î',[rfReplaceAll])+'%")'; //óöòõôÓÖÒÕÔ strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'o','ó',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'o','ö',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'o','ò',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'o','õ',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'o','ô',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'O','Ó',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'O','Ö',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'O','Ò',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'O','Õ',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'O','Ô',[rfReplaceAll])+'%")'; //úüùûÚÜÙÛ strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'u','ú',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'u','ü',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'u','ù',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'u','û',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'U','Ú',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'U','Ü',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'U','Ù',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'U','Û',[rfReplaceAll])+'%")'; //çÇ strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'c','ç',[rfReplaceAll])+'%")'; strBuscaNome:=strBuscaNome+' OR ([mensalistas].NomeCliente LIKE "%'+StringReplace(strBusca,'C','Ç',[rfReplaceAll])+'%")';