Delphi - Event 만들기

Programming/Delphi 2009.08.25 10:36 Posted by 파란크리스마스

1. 이벤트 핸들러 생성

Type
  TAddConnectionInfoEvent = procedure(AConnInfo : TConnectionInfo) of object;

2. 이벤트 속성으로 정의

Type
  TERDModel=class
  private
    fOnAddConnectionInfo : TAddConnectionInfoEvent;
  public
    procedure AddConnectionInfo(aConnectionInfo : TConnectionInfo);
    property OnAddConnectionInfo : TAddConnectionInfoEvent read fOnAddConnectionInfo write fOnAddConnectionInfo;
  end;

3. 이벤트 호출

procedure TERDModel.AddConnectionInfo(aConnectionInfo : TConnectionInfo);
begin
  if Assigned(OnAddConnectionInfo ) then OnAddConnectionInfo(aConnectionInfo);
end;

4. 호출될 이벤트 구현

Type
  TErdMainFm=class(TLocalForm)
  private
    procedure ERDModelAddConnection(AConnInfo : TConnectionInfo);
  end;

implementation

procedure TErdMainFm.ERDModelAddConnection(AConnInfo : TConnectionInfo);
begin
  ShowMessage('나 호출되었어요.');
end;

5. 이벤트 등록

procedure TErdMainFm.FormCreate(Sender: TObject);
var
  ERDModel : TERDModel;
begin
  ERDModel := TERDModel.Create();
  ERDModel.OnAddConnectionInfo := ERDModelAddConnection;
end;

신고
TAG Delphi, event

Delphi - VirtualTree

Programming/Delphi 2009.05.31 15:30 Posted by 파란크리스마스

다운받는곳 : Soft Gems Homepage (http://www.soft-gems.net/)

속성

VT.TreeOptions.SelectionOptions := [toDisableDrawSelection,toExtendedFocus,toMiddleClickSelect,toMultiSelect,toRightClickSelect{,toCenterScrollIntoView}];

이벤트

OnFocusChanged

procedure Xxx.VTFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
var
  Data: PAlignData;
begin
  // Data := Sender.GetNodeData(Node);
end;

OnGetImageIndex

procedure Xxx.VTGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind;
  Column: TColumnIndex; var Ghosted: Boolean; var Index: Integer);
var
  Data: PAlignData;
begin
  if Kind in [ikNormal, ikSelected] then begin
    Data := Sender.GetNodeData(Node);
    Index := Data.ImageIndex;
  end;
end;

OnGetNodeDataSize
OnGetText

Node 찾기

function TTreeWorkspace.FindSubNode(ParentNode : PVirtualNode; name : String): PVirtualNode;
var
  Run: PVirtualNode;
  NodeData : PWorkspaceData;
begin
  Result := nil;

  Run := ParentNode.FirstChild;
  while Assigned(Run) do begin
    NodeData := PWorkspaceData(Self.GetNodeData(Run));
    if (NodeData.Title=name) then begin
      result := Run;
      Exit;
    end;
    Run := Run.NextSibling;
  end;
end;

정렬하기

호출
  Self.Sort(TeamNode, 0, Self.Header.SortDirection, true);

constructor TTreeWorkspace.Create(AOwner: TComponent; aImageList : TImageList);
begin
  inherited Create(AOwner);
  Self.OnCompareNodes := TreeCompareNodes;
end;

procedure TTreeWorkspace.TreeCompareNodes(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex;
    var Result: Integer);
var
  NodeData1 : PWorkspaceData;
  NodeData2 : PWorkspaceData;
begin
  NodeData1 := Sender.GetNodeData(Node1);
  NodeData2 := Sender.GetNodeData(Node2);
  Result := 0;
  if NodeData1.Title > NodeData2.Title then
    Result := 1;
end;


 

신고

Delphi Tip

Programming/Delphi 2009.05.19 10:01 Posted by 파란크리스마스

- 움직이는 Form
출처 : http://delphi.about.com/od/windowsshellapi/a/dragnocaption.htm

procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer) ;
begin
   ReleaseCapture;
   SendMessage(Form1.Handle, WM_SYSCOMMAND, 61458, 0) ;
end

- 현재 디렉토리


procedure TSimpleListDemoDataDM.DataModuleCreate(Sender: TObject);
var
  ExeFileName : String;
  ExePath : String;
begin
  ExeFileName := Application.ExeName;
  ExePath := ExtractFilePath(Application.ExeName);

  Database.Connected := false;
  Database.Params.Clear;
  Database.Params.Add('PATH=' + ExePath + '..\..\Data');
  Database.Params.Add('DEFAULT DRIVER=PARADOX');
  Database.Params.Add('ENABLE BCD=FALSE');
  Database.Connected := true;

  tblCars.Open;
end;

신고

Delphi - Coco/R DCocoR 로 간단한 계산기 만들기

Programming/Delphi 2009.05.14 18:24 Posted by 파란크리스마스

출처 - http://cc.embarcadero.com/Item/26667

DCocoR 예제를 간단하게 수정하여 만들어 보았습니다.


ExprUnit.atg
----------------------------------------
COMPILER ExprUnit

FRAME "delphi.frm"

header = (.
.)

uses = (.SysUtils,Variants,StrUtils.)

private = (.
.)
protected = (.
.)
public = (.
  function Evaluate(const str: String): integer;
.)
publicProps = (.
.)

precreate = (.
.)

implementation =
(.
function TExprUnit.Evaluate(const str: String): integer;
var rez: Variant;
begin
  SetSource(str);
  _expr(rez);
  //Result := Successful and rez;
  Result := rez;
end;
.)

END

IGNORECASE

CHARACTERS
letter="ABCDEFGHIJKLMNOPQRSTUVWXYZ_".
digit="0123456789".
hexdigit = digit + "ABCDEF".
special = "+-*/=<>[].,():;^@{}$#".
ctrl=CHR(1)..CHR(31).
tab=CHR(9).
eol=CHR(13).
lf=CHR(10).
noquote=ANY-"'" -ctrl.

TOKENS
ident = letter{letter|digit}.
number = digit{digit} | digit { digit } CONTEXT ( ".." ).
string = ("'" {noquote}"'"| "#"(digit{digit}|"$"hexdigit{hexdigit}))
         {"'" {noquote}"'"| "#"(digit{digit}|"$"hexdigit{hexdigit})}.
float = digit{digit}
        (  "." {digit}
           [ "E"
            ["+" |"-"]
            digit{digit}
           ]
          |"E"["+"|"-"]digit{digit}
        ).
hexnumber = "$" hexdigit {hexdigit}.
eq    = '='.
gr    = '>'.
les   = '<'.
lesEq = '<='.
grEq  = '>='.
noeq  = '<>'.

add = "+". 
sub = "-". 
or  = "OR".
xor = "XOR".

mult = "*"  .
divd = "/"  .
div  = "DIV".
mod  = "MOD".
and  = "AND".
shl  = "SHL".
shr  = "SHR".

IGNORE tab+lf+eol

PRODUCTIONS

ExprUnit
(. var rez: Variant; .)=
 expr<rez>
.

expr<var Value: Variant>
(. var v2: Variant; sign: Integer; AddOp: Integer; .) =
  (.sign := 1;.)
  ['+' | '-' (.sign := -1;.) ]
  Term<Value> (. if sign<0 then value := -value;.)
  {
   ( "+" | "-" | "OR" | "XOR" )
   (. AddOp := Symbols[0]^.id; .)
    Term<v2>
   (. case AddOp of
      addSym: Value := Value +   v2;
      subSym: Value := Value -   v2;
      orSym : Value := Value or  v2;
      xorSym: Value := Value xor v2;
      end;
   .)
  }
.

Term<var Value: Variant>
(. var v2: Variant; MulOp: Integer; .) =
 Factor<Value>
 {
  ("*" | "/" | "DIV" | "MOD" | "AND" | "SHL" | "SHR" )
  (. MulOp := Symbols[0]^.id; .)
  Factor<v2>
   (. case MulOp of
      multSym: Value := Value *   v2;
      divdSym: Value := Value /   v2;
      divSym:  Value := Value div v2;
      modSym:  Value := Value mod v2;
      andSym:  Value := Value and v2;
      shlSym:  Value := Value shl v2;
      shrSym:  Value := Value shr v2;
      end;
   .)
 }
.

Factor<var Value: Variant> =
 | Number<Value>
.

Number<out Value: Variant> =
   number     (. Value := StrToInt(LexString); .)
 | float      (. Value := StrToFloat(LexString); .)
 | hexnumber  (. Value := StrToInt(LexString); .)
.

END ExprUnit.
----------------------------------------

ExprApp.dpr
----------------------------------------
program ExprApp;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  CocoAncestor,
  FileLoader,
  ExprUnit in 'ExprUnit.pas';

var
  comp: TExprUnit;
  meth: TMethod;
  errProc: TErrorEvent absolute meth;
  int1: String;
  rez: Variant;

procedure ErrorHandler(this: TExprUnit; Sender: TObject; ErrorType,ErrorCode, line,col: Integer; const Msg, data: string);
begin
  WriteLn(Format('Error in "%s"(%d,%d): %s',[int1,Line,Col,Msg,data]));
end;

begin
  try
    if (ParamCount=0) then begin
      WriteLn(Format('Usage: %s "1 + 2"',[ChangeFileExt(ExtractFileName(ParamStr(0)),'')]));
      Exit;
    end;
    comp := TExprUnit.Create(nil);
    try
      meth.Data := comp;
      meth.Code := @ErrorHandler;
      comp.OnError := errProc;

      int1 := ParamStr(1);
      WriteLn(int1);
      rez := comp.Evaluate(int1);
      WriteLn(rez);
    finally
      comp.Free;
    end;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.
----------------------------------------

실행결과

신고

Delphi - 실행시 파라미터 전달

Programming/Delphi 2009.05.13 15:11 Posted by 파란크리스마스
출처 : http://fendee.egloos.com/9909821
http://delphi.about.com/od/delphitips2007/qt/parse_cmd_line.htm

function ParamStr(Pos : Integer): string

- end -
신고

[Delphi] - File

Programming/Delphi 2009.05.12 15:08 Posted by 파란크리스마스

FileCopy

출처 : http://delphi.about.com/od/fileio/a/untypedfiles.htm

procedure FileCopy(const FileFrom, FileTo: string) ;
var
  FromF, ToF: file;
  NumRead, NumWritten: Integer;
  Buffer: array[1..2048] of Byte;
begin
  AssignFile(FromF, FileFrom) ;
  Reset(FromF, 1) ;
  AssignFile(ToF, FileTo) ;
  Rewrite(ToF, 1) ;
  repeat

   BlockRead(FromF, Buffer, SizeOf(Buffer), NumRead) ;
   BlockWrite(ToF, Buffer, NumRead, NumWritten) ;
  until (NumRead = 0) or (NumWritten <> NumRead) ;
  CloseFile(FromF) ;
  CloseFile(ToF) ;
end;

Random access file

출처 : http://www.tek-tips.com/viewthread.cfm?qid=1540019&page=3

type
  recordtype=record
    varLastName   :string[50];
    varFirstName  :string[50];
    varEmail     :string[250];
end;

  qfile:file of recordtype;
  qfileTemp:file of recordtype;
  qrecord:recordtype;
  numrec:integer;
  numtemp:integer;

procedure TfrmDataBase.imgDeleteMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin

  try

    ASSIGNFILE(qfile, Trim(lblFile.Caption));
    Reset(qfile);

    ASSIGNFILE(qfiletemp, ExtractFilePath(application.exename) + '\Database.tmp');
    REWRITE(qfiletemp);

      For numtemp:=0 To filesize(qfile)-1 Do
        begin

          seek(qfile,numtemp);
          read(qfile,qrecord);

          If IntToStr(numtemp + 1) <> Trim(lblPosition.Caption)  Then
            begin
              write (qfiletemp, qrecord);
            end;

        end;

    closefile(qfile);
    closefile(qfiletemp);

    deletefile(Trim(lblFile.Caption));
    renamefile(ExtractFilePath(application.exename) + '\Database.tmp', Trim(lblFile.Caption));

  except
   ShowMessage('Warning: access to file has been denied.' + #10 + #13 + #10 + #13 + 'Make sure the application folder is not read-only.');
   exit;
  end;

end;

신고
TAG Delphi, File

[Delphi] TTreeNode.Data

Programming/Delphi 2009.05.01 10:11 Posted by 파란크리스마스
출처 : http://users.iafrica.com/d/da/dart/zen/Articles/TTreeView/TTreeView_eg05.html

-- end --
신고

Delphi - StrToBin, StringToHex, HexToString

Programming/Delphi 2009.05.01 06:09 Posted by 파란크리스마스

출처 : http://www.xxlinux.com/linux/dev/Delphi/2007-10-30/11392.html
http://dolba.net/old_k2club/bbs/bbs.php3?board=delphi&mode=view&id=345&page=32&recnum=359&keyword=&flag=
http://www.pic16.com/BBS/dispbbs.asp?boardID=31&ID=17357&page=3

function StrToBin(const S: string): string;
const
  BitArray: array[0..15] of string =
      ('0000', '0001', '0010', '0011',
       '0100', '0101', '0110', '0111',
       '1000', '1001', '1010', '1011',
       '1100', '1101', '1110', '1111');
var
  Index: Integer;
  LoBits: Byte;
  HiBits: Byte;
begin
  Result := '';
  for Index := 1 to Length(S) do
  begin
      HiBits := (Byte( S[Index]) and $F0) shr 4;
      LoBits := Byte( S[Index]) and $0F;
      Result := Result + BitArray[HiBits];
      Result := Result + BitArray[LoBits];
  end;
end;

function StringToHex(const S: string): string;
var
  Index: Integer;
begin
  Result := '';
  for Index := 1 to Length(S) do
    Result := Result + IntToHex( Byte( S[Index] ), 2 );
end;

function TransChar(AChar: Char): Integer;
begin
  if AChar in ['0'..'9'] then
  Result := Ord(AChar) - Ord('0')
  else
  Result := 10 + Ord(AChar) - Ord('A');
end;

function HexToString(aHex: String): String;
var
  I : Integer;
  CharValue: Word;
begin
  Result := '';
  for I := 1 to Trunc(Length(aHex)/2) do begin
    Result := Result + ' ';
    CharValue := TransChar(aHex[2*I-1])*16 + TransChar(aHex[2*I]);
    Result[I] := Char(CharValue);
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  ShowMessage(
    '한글'' Hex Code is ' + StringToHex('한글') + chr(13) +
    '한글'' Binary Code is ' + StrToBin('한글') + chr(13) +
    '한글'' HexToString ' + HexToString(StringToHex('한글'))
  );
end;

신고

Delphi - StringToByte, ByteToString

Programming/Delphi 2009.05.01 05:52 Posted by 파란크리스마스

출처 : http://delphi.about.com/cs/adptips2002/a/bltip1002_5.htm

type
  TByteArr = array of byte;

function StringToBytes(aString: String): TByteArr;
var
  i: integer;
begin
  SetLength( Result, Length(aString)) ;
  for i := 0 to Length(aString) - 1 do
    Result[i] := ord(aString[i + 1]) { - 48} ;
end;

function BytesToString(aBytes : TByteArr): String;
begin
  Result := PChar(aBytes);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  buffer : TByteArr;
begin
  buffer := StringToByte(Edit1.Text);
  ShowMessage(ByteToString(buffer));
end;

신고

Delphi Tip - GetSystemPath

Programming/Delphi 2009.04.11 18:50 Posted by 파란크리스마스
출처 : http://www.scalabium.com/faq/dct0106.htm
http://delphi.mylivepage.com/wiki/1380/638

uses
  ShlObj, ActiveX;

function GetSystemPath(Folder: Integer): string;
var
  PIDL: PItemIDList;
  Path: LPSTR;
  AMalloc: IMalloc;
begin
  Path := StrAlloc(MAX_PATH);
  SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL);
  if SHGetPathFromIDList(PIDL, Path) then
    Result := Path;
  SHGetMalloc(AMalloc);
  AMalloc.Free(PIDL);
  StrDispose(Path);
end;

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

typedef enum {
 CSIDL_DESKTOP = 0x0000,
 CSIDL_INTERNET = 0x0001,
 CSIDL_PROGRAMS = 0x0002,
 CSIDL_CONTROLS = 0x0003,
 CSIDL_PRINTERS = 0x0004,
 CSIDL_PERSONAL = 0x0005,
 CSIDL_FAVORITES = 0x0006,
 CSIDL_STARTUP = 0x0007,
 CSIDL_RECENT = 0x0008,
 CSIDL_SENDTO = 0x0009,
 CSIDL_BITBUCKET = 0x000A,
 CSIDL_STARTMENU = 0x000B,
 CSIDL_MYDOCUMENTS = 0x000C,
 CSIDL_MYMUSIC = 0x000D,
 CSIDL_MYVIDEO = 0x000E,
 CSIDL_DESKTOPDIRECTORY = 0x0010,
 CSIDL_DRIVES = 0x0011,
 CSIDL_NETWORK = 0x0012,
 CSIDL_NETHOOD = 0x0013,
 CSIDL_FONTS = 0x0014,
 CSIDL_TEMPLATES = 0x0015,
 CSIDL_COMMON_STARTMENU = 0x016,
 CSIDL_COMMON_PROGRAMS = 0x0017,
 CSIDL_COMMON_STARTUP = 0x0018,
 CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019,
 CSIDL_APPDATA = 0x001A,
 CSIDL_PRINTHOOD = 0x001B,
 CSIDL_LOCAL_APPDATA = 0x001C,
 CSIDL_ALTSTARTUP = 0x001D,
 CSIDL_COMMON_ALTSTARTUP = 0x001E,
 CSIDL_COMMON_FAVORITES = 0x001F,
 CSIDL_INTERNET_CACHE = 0x0020,
 CSIDL_COOKIES = 0x0021,
 CSIDL_HISTORY = 0x0022,
 CSIDL_COMMON_APPDATA = 0x0023,
 CSIDL_WINDOWS = 0x0024,
 CSIDL_SYSTEM = 0x0025,
 CSIDL_PROGRAM_FILES = 0x0026,
 CSIDL_MYPICTURES = 0x0027,
 CSIDL_PROFILE = 0x0028,
 CSIDL_SYSTEMX86 = 0x0029,
 CSIDL_PROGRAM_FILESX86 = 0x002A,
 CSIDL_PROGRAM_FILES_COMMON = 0x002B,
 CSIDL_PROGRAM_FILES_COMMONX86 = 0x002C,
 CSIDL_COMMON_TEMPLATES = 0x002D,
 CSIDL_COMMON_DOCUMENTS = 0x002E,
 CSIDL_COMMON_ADMINTOOLS = 0x002F,
 CSIDL_ADMINTOOLS = 0x0030,
 CSIDL_CONNECTIONS = 0x0031,
 CSIDL_COMMON_MUSIC = 0x0035,
 CSIDL_COMMON_PICTURES = 0x0036,
 CSIDL_COMMON_VIDEO = 0x0037,
 CSIDL_RESOURCES = 0x0038,
 CSIDL_RESOURCES_LOCALIZED = 0x0039,
 CSIDL_COMMON_OEM_LINKS = 0x003A,
 CSIDL_CDBURN_AREA = 0x003B,
 CSIDL_COMPUTERSNEARME = 0x003D,
 CSIDL_FLAG_PER_USER_INIT = 0x0800,
 CSIDL_FLAG_NO_ALIAS = 0x1000,
 CSIDL_FLAG_DONT_VERIFY = 0x4000,
 CSIDL_FLAG_CREATE = 0x8000,
 CSIDL_FLAG_MASK = 0xFF00
} CSIDL Values;

Constants

CSIDL_DESKTOP Windows desktop-virtual folder that is the root of the name space. 
CSIDL_INTERNET Virtual folder that represents the Internet. 
CSIDL_PROGRAMS File system directory that contains the user's program groups (which are also file system directories). A typical path is C:\Documents and Settings\username\Start Menu\Programs. 
CSIDL_CONTROLS Virtual folder that contains icons for Control Panel applications. 
CSIDL_PRINTERS Virtual folder that contains installed printers. 
CSIDL_PERSONAL File system directory that serves as a common repository for documents. A typical path is C:\Documents and Settings\username\My Documents. This is different from the My Documents virtual folder in the name space. To access that virtual folder, use the technique described in Managing the File System . 
CSIDL_FAVORITES File system directory that serves as a common repository for the user's favorite items. A typical path is C:\Documents and Settings\username\Favorites. 
CSIDL_STARTUP File system directory that corresponds to the user's Startup program group. The system starts these programs whenever any user logs onto Microsoft® Windows NT® or starts Microsoft Windows® 98. A typical path is C:\Documents and Settings\username\Start Menu\Programs\Startup. 
CSIDL_RECENT File system directory that contains the user's most recently used documents. A typical path is C:\Documents and Settings\username\Recent. To create a shortcut in this folder, use SHAddToRecentDocs . In addition to creating the shortcut, this function updates the Shell's list of recent documents and adds the shortcut to the Documents submenu of the Start menu. 
CSIDL_SENDTO File system directory that contains Send To menu items. A typical path is C:\Documents and Settings\username\SendTo. 
CSIDL_BITBUCKET Virtual folder that contains the objects in the user's Recycle Bin. 
CSIDL_STARTMENU File system directory that contains Start Menu items. A typical path is C:\Documents and Settings\username\Start Menu. 
CSIDL_MYDOCUMENTS Virtual folder that contains the objects in the user's My Documents folder.
CSIDL_MYMUSIC File system directory that serves as a common repository for music files. A typical path is C:\My Music. 
CSIDL_MYVIDEO File system directory that serves as a common repository for video files. 
CSIDL_DESKTOPDIRECTORY File system directory used to physically store file objects on the desktop (not to be confused with the desktop folder itself). A typical path is C:\Documents and Settings\username\Desktop 
CSIDL_DRIVES My Computer-virtual folder that contains everything on the local computer: storage devices, printers, and Control Panel. The folder can also contain mapped network drives. 
CSIDL_NETWORK Network Neighborhood-virtual folder that represents the root of the network namespace hierarchy. 
CSIDL_NETHOOD A file system folder that contains the link objects that can exist in the My Network Places virtual folder. It is not the same as CSIDL , which represents the network namespace root. A typical path is C:\Documents and Settings\username\NetHood. 
CSIDL_FONTS Virtual folder that contains fonts. A typical path is C:\WINNT\Fonts. 
CSIDL_TEMPLATES File system directory that serves as a common repository for document templates. 
CSIDL_COMMON_STARTMENU File system directory that contains the programs and folders that appear on the Start Menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu. Valid only for Windows NT systems. 
CSIDL_COMMON_PROGRAMS File system directory that contains the directories for the common program groups that appear in the Start Menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs. Valid only for Windows NT systems. 
CSIDL_COMMON_STARTUP File system directory that contains the programs that appear in the Startup folder for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid only for Windows NT systems. 
CSIDL_COMMON_DESKTOPDIRECTORY File system directory that contains files and folders that appear on the desktop for all users. A typical path is C:\Documents and Settings\All Users\Desktop. Valid only for Windows NT systems. 
CSIDL_APPDATA Version 4.71 . File system directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data. This CSIDL is supported by the redistributable ShFolder.dll for systems that do not have the Microsoft Internet Explorer 4.0 integrated Shell installed. 
CSIDL_PRINTHOOD File system directory that contains the link objects that can exist in the Printers virtual folder. A typical path is C:\Documents and Settings\username\PrintHood. 
CSIDL_LOCAL_APPDATA Version 5.0 . File system directory that serves as a data repository for local (nonroaming) applications. A typical path is C:\Documents and Settings\username\Local Settings\Application Data. 
CSIDL_ALTSTARTUP File system directory that corresponds to the user's nonlocalized Startup program group. 
CSIDL_COMMON_ALTSTARTUP File system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Windows NT systems. 
CSIDL_COMMON_FAVORITES File system directory that serves as a common repository for all user's favorite items. Valid only for Windows NT systems. 
CSIDL_INTERNET_CACHE Version 4.72 . File system directory that serves as a common repository for temporary Internet files. A typical path is C:\Documents and Settings\username\Temporary Internet Files. 
CSIDL_COOKIES File system directory that serves as a common repository for Internet cookies. A typical path is C:\Documents and Settings\username\Cookies. 
CSIDL_HISTORY File system directory that serves as a common repository for Internet history items. 
CSIDL_COMMON_APPDATA Version 5.0 . Application data for all users. A typical path is C:\Documents and Settings\All Users\Application Data. 
CSIDL_WINDOWS Version 5.0 . Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables. A typical path is C:\WINNT. 
CSIDL_SYSTEM Version 5.0 . System folder. A typical path is C:\WINNT\SYSTEM32. 
CSIDL_PROGRAM_FILES Version 5.0 . Program Files folder. A typical path is C:\Program Files. 
CSIDL_MYPICTURES Version 5.0 . My Pictures folder. A typical path is C:\Documents and Settings\username\My Documents\My Pictures. 
CSIDL_PROFILE Version 5.0 . User's profile folder. 
CSIDL_SYSTEMX86 The x86 system directory on Reduced Instruction Set Computer (RISC) systems. 
CSIDL_PROGRAM_FILESX86 The x86 Program Files folder on RISC systems. 
CSIDL_PROGRAM_FILES_COMMON Version 5.0 . A folder for components that are shared across applications. A typical path is C:\Program Files\Common. Valid only for Windows NT and Windows 2000 systems. 
CSIDL_PROGRAM_FILES_COMMONX86 The x86 Program Files Common folder on RISC systems. 
CSIDL_COMMON_TEMPLATES File system directory that contains the templates that are available to all users. A typical path is C:\Documents and Settings\All Users\Templates. Valid only for Windows NT systems. 
CSIDL_COMMON_DOCUMENTS File system directory that contains documents that are common to all users. Typical paths are C:\Documents and Settings\All Users\Documents. Valid for Windows NT systems and Windows 95 and Windows 98 systems with Shfolder.dll installed. 
CSIDL_COMMON_ADMINTOOLS Version 5.0 . File system directory that contains administrative tools for all users. 
CSIDL_ADMINTOOLS Version 5.0 . File system directory used to store administrative tools for an individual user. The Microsoft Management Console (MMC) saves customized consoles to this directory, and it roams with the user. 
CSIDL_CONNECTIONS Virtual folder that contains network and dial-up connections. 
CSIDL_COMMON_MUSIC My Music folder for all users. For more information, see CSIDL . 
CSIDL_COMMON_PICTURES My Pictures folder for all users. For more information, see CSIDL . 
CSIDL_COMMON_VIDEO My Video folder for all users. For more information, see CSIDL . 
CSIDL_RESOURCES System resource directory. A typical path is C:\WINNT\Resources. 
CSIDL_RESOURCES_LOCALIZED Localized resource directory. For more information, see CSIDL . 
CSIDL_COMMON_OEM_LINKS Folder containing links to OEM specific applications for all users. 
CSIDL_CDBURN_AREA File system folder used to hold data for burning to a CD. Typically [User Profile Folder]\Local Settings\Applications Data\Microsoft\CD Burning. 
CSIDL_COMPUTERSNEARME Computers Near Me folder. Virtual folder that contains links to nearby computers on the network. Nearness it is established by common work group membership. 
CSIDL_FLAG_PER_USER_INIT Combine this flag with the desired CSIDL_ value to indicate per-user initialization. 
CSIDL_FLAG_NO_ALIAS Combine this flag with the desired CSIDL_ value to force a non-alias version of the PIDL. 
CSIDL_FLAG_DONT_VERIFY Combine this flag with the desired CSIDL_ value to return an unverified folder path. 
CSIDL_FLAG_CREATE Combine this flag with the desired CSIDL_ value to force the creation of the associated folder. 
CSIDL_FLAG_MASK Mask for all possible CSIDL flag values. 

Enumerated Type Information
Minimum operating systems Windows 95, Windows NT 4.0, Windows XP

See Also
SHGetFolderLocation, SHGetFolderPath, SHGetSpecialFolderLocation, SHGetSpecialFolderPath

신고

Delphi - Date

Programming/Delphi 2008.06.30 02:06 Posted by 파란크리스마스

출처 :

http://delphi.about.com/od/beginners/l/blrtldatetime.htm
http://wwwi.tistory.com/category/델파이
http://www.zetblog.net/Zcontent_list.php?category_idx=61

CompareDate

uses
  DateUtils;

//# 같으면 0 출력
ShowMessage(IntToStr(CompareDate(StrToDate('2007-04-01'), StrToDate('2007-04-01'))));
//# 오른쪽이 더 크면 -1 출력
ShowMessage(IntToStr(CompareDate(StrToDate('2007-04-01'), StrToDate('2007-04-02'))));
//# 왼쪽이 더 크면 1 출력
ShowMessage(IntToStr(CompareDate(StrToDate('2007-04-02'), StrToDate('2007-04-01'))));




 

신고
TAG Delphi

Delphi - Hotkey

Programming/Delphi 2008.06.23 00:20 Posted by 파란크리스마스

출처 : http://www.swissdelphicenter.ch/torry/showcode.php?id=147

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    id1 : Integer;
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
 if Msg.HotKey = id1 then
   ShowMessage('Ctrl + A 선택!');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  // 키 등록 Ctrl + A 
  id1 := GlobalAddAtom('Hotkey1');
  RegisterHotKey(Self.Handle, id1, MOD_CONTROL, $41); // $41 -> A
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // 키 해제
  UnRegisterHotKey(Handle, id1);
  GlobalDeleteAtom(id1);
end;

end.

신고
TAG Delphi, HotKey


 

티스토리 툴바