728x90

- Query 실행후 동적으로 컬럼 추가

(cxGridDBTableView1.DataController as IcxCustomGridDataController).DeleteAllItems;
(cxGridDBTableView1.DataController as IcxCustomGridDataController).CreateAllItems(true);
cxGridDBTableView1.ApplyBestFit();

- [Enter] 키로 Cell 이동

cxGrid1TableView1.OptionsBehavior.FocusCellOnCycle := true;
cxGrid1TableView1.OptionsBehavior.FocusCellOnTab := true;
cxGrid1TableView1.OptionsBehavior.FocusFirstCellOnNewRecord := true;
cxGrid1TableView1.OptionsBehavior.GoToNextCellOnEnter := true;

- 속성

속성명 자료형 설명
OptionsBehavior.CopyCaptionsToClipboard Boolean 클립보드에 복사할 때 캡션도 복사할지 여부
OptionsSelection.CellMultiSelect Boolean Cell 다중 선택 여부
OptionsSelection.CellSelect Boolean Cell별로 선택 가능 여부
OptionsSelection.MultiSelect Boolean Row 다중 선택 여부

- TcxCustomDataSource

TDatasetFieldModel=class(TcxCustomDataSource)
  private
    DatasetAnalyzer : TDatasetAnalyzer;
  protected
    function GetRecordCount: Integer; override;
    function GetValue(ARecordHandle: TcxDataRecordHandle; AItemHandle: TcxDataItemHandle): Variant; override;
  public
    constructor Create;
    destructor Destroy; override;
  end;

implementation

{ TDatasetFieldModel }

constructor TDatasetFieldModel.Create;
begin
  inherited Create;
  DatasetAnalyzer := TDatasetAnalyzer.Create(TDatasetField);
end;

destructor TDatasetFieldModel.Destroy;
begin
  DatasetAnalyzer.Free;
  inherited Destroy;
end;

function TDatasetFieldModel.GetRecordCount: Integer;
begin
  Result := DatasetAnalyzer.Count;
end;

function TDatasetFieldModel.GetValue(ARecordHandle: TcxDataRecordHandle; AItemHandle: TcxDataItemHandle): Variant;
var
  AColumnId: Integer;
  theField : TDatasetField;
begin
  result := Variants.Null;
  AColumnId := GetDefaultItemID(Integer(AItemHandle));

  if Integer(ARecordHandle) < Self.GetRecordCount then begin
    theField := (DatasetAnalyzer.Items[Integer(ARecordHandle)] as TDatasetField);
    if Assigned(theField) then begin
      case AColumnId of
        0 : Result := theField.FieldName;
        1 : Result := theField.DataTypeStr;
        2 : Result := theField.Size;
      end;
    end;
  end;
end;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  DatasetFieldModel := TDatasetFieldModel.Create;
  cxGrid1TableView1.DataController.CustomDataSource := DatasetFieldModel;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin
  if ListBox1.ItemIndex >= 0 then begin
    Table1.Active := false;
    Table1.TableName := ListBox1.Items.Strings[ListBox1.ItemIndex];
    Table1.Active := true;

    DatasetFieldModel.DatasetAnalyzer.Analyzer(Table1);
    DatasetFieldModel.DataChanged;
  end;
end;

- 한글관련 버그 수정 (Delphi 2009 이상

사이트 : http://eaglesoft.tistory.com/162

- 옵션

cxGrid1TableView1.OptionsView.GroupByBox := false;
cxGrid1TableView1.OptionsData.Editing := false;  // 읽기전용

- ??

procedure TCreateTableFrm.Col1GetProperties(
  Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
  var AProperties: TcxCustomEditProperties);
var
  rowData : TRowObject;
begin
  rowData := TRowObject(CustomGridModel.RowDataList.Items[ARecord.Index]);


  ...
end;

- 수정중인 Cell 바로 적용

cxGrid1TableView1.DataController.PostEditingData;

- end - 

728x90
728x90
728x90
728x90

참조
http://delphigeist.blogspot.com/2009/11/saveload-controls-from-inifile-using.html

uses
  inifiles;

procedure TForm1.FormCreate(Sender: TObject);
var
  IniFile  : TiniFile;
begin
  //
  IniFile  := TiniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
  try
    isDEBUG := IniFile.ReadBool('INFO', 'DEBUG', false);
  finally
    IniFile.Free;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  IniFile  : TiniFile;
begin
  //
  IniFile  := TiniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
  try
    IniFile.WriteBool('INFO', 'DEBUG', isDEBUG);
  finally
    IniFile.Free;
  end;
end;

728x90
728x90

uses
  Dialogs;

function MessageDlg(const Msg: string; DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons; HelpCtx: Longint; DefaultButton: TMsgDlgBtn): Integer; overload;

TMsgDlgType = (
  mtWarning,
  mtError,
  mtInformation,
  mtConfirmation,
  mtCustom
);

TMsgDlgBtn = (
  mbYes,
  mbNo,
  mbOK,
  mbCancel,
  mbAbort,
  mbRetry,
  mbIgnore,
  mbAll,
  mbNoToAll,
  mbYesToAll,
  mbHelp,
  mbClose
);

if MessageDlg('종료 할래?', mtConfirmation, [mbYes, mbNo], 0, mbYes) = mrYes then begin
  Close;
end;

728x90
728x90

Antlr 도구를 이용해서 만들어본 자바파서입니다.
간단하게 샘플 Grammer 을 이용해서 만들어 보았습니다.
 
파싱하는 자바 소스는 컴파일 가능한 소스가 아니면
Grammer에 어긋나기 때문에 파싱이 되지 않습니다.
(사용된 Grammer가 최신 JDK에 만족하지 않을 수 있으므로 최신 JDK 문법도 파싱이 안 될수 있음)
 
Package, Import, Class, Method을 몇번째 라인, 열, 사용된 이름을 객체화해서 담아 두었습니다.
 
더 자세한 정보를 담으려 했으나,
Delphi로 자바 파싱에 관심이 있는 사람이 있는지 궁금하네요. (손들어 보세요.)
 
파싱한 결과를
객체화 하기 위해서 클래스를 설계하는 일도 만만치 않는 일이라 여기에서 중단합니다.
(누가 클래스를 설계주시면 객체에 담아 보겠습니다. JavaSourceUnit.pas)
 
Grammer 파일은 제외한 컴파일 하는 한 소스 파일은 제 블로그에서 받으실 수 있으며,
배포시 제 블로그의 주소와 함께 배포해주세요.
(Delphi 2090이상에서만 컴파일 가능)

728x90
728x90

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;

728x90
728x90

다운받는곳 : 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;


 

728x90
728x90

- 움직이는 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;

728x90

+ Recent posts