본문 바로가기

Delphi Tip219

퀀텀 그리드 컬럼 동적 생성 퀀텀 그리드 컬럼 동적 생성   procedure Form.CreateGridFields(const tvCaption, tvFieldName, tvProperties: string; tvMerging, tvalign: boolean; tvWidth: integer); begin  with tv.CreateColumn do  begin    Caption := tvCaption;    DataBinding.FieldName := tvFieldName;     HeaderAlignmentHorz := taCenter;     HeaderAlignmentVert := vaCenter;     Name := 'tv' + tvFieldName;     Options.CellMerging := tvMerging; .. 2024. 5. 3.
폼에 그림자 넣기 폼에 그림자 넣기       델파이 힌트(THintWindow)를 보니 그림자가 생기길래소스를 쫓아가다보니 윈도우클래스 스타일에 CS_DROPSHADOW 라는게 있는걸 알았습니다.그걸 폼에 적용해보니 되더군여.... unit Unit1; interface usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls; typeTForm1 = class(TForm)Button1: TButton;procedure Button1Click(Sender: TObject);privateprotectedprocedure CreateParams(var Params: TCreateParams); override;publicend; varForm.. 2024. 4. 25.
폼 배경에 비트맵 넣기 폼 배경에 비트맵 넣기 AnimateWindow() API함수는 폼에게 애니메이션 효과를 줄 수 있는 함수이다. 그런데, 폼에 TImage를 올려놓고 비트맵을 불러드린 다음에, 애니메이션 효과를 주면 비트맵이 보이지 않는다. 그래서 MSDN을 찾아보니, WM_PRINTCLIENT를 사용하라고 나온다. 소스참고 unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm2 = class(TForm) procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); procedure .. 2024. 4. 21.
폼을 점점 투명하게 나타나게 하기 폼을 점점 투명하게 나타나게 하기 procedure TForm1.Button1Click(Sender: TObject); var objFrm: TForm2; begin objFrm := TForm2.Create(self); AnimateWindow(objFrm.Handle, 500, AW_BLEND); objFrm.Show; end; 2024. 4. 19.
파워포인터 파일 다른이름으로 저장 파워포인터 파일 다른이름으로 저장 procedure Tfrm_Main.button_ppt_openClick(Sender: TObject); var msppt:variant; //PowerPoint Application 변수 mspps:variant; //PowerPoint Presentation 변수 mspps_slides_totalcount:integer; // PowerPoint Slides Total count 변수 begin msppt:=CreateOleObject('Powerpoint.Application'); msppt.visible:=true; msppt.WindowState:=ppWindowMinimized; mspps:=msppt.Presentations.open('c:\bbbb.ppt'.. 2024. 4. 16.
StringGrid Row색칠/정렬 하기 StringGrid Row색칠/정렬 하기 procedure Tfrm_xxx.Grid_ListDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var Ls_mt_kbn : String; LeftPos: Integer; TopPos : integer; CellStr: string; begin Ls_mt_kbn := Grid_List.Cells[16,ARow]; if (ACol >= Grid_List.FixedCols) and (ARow >= Grid_List.FixedRows) then with Grid_List.Canvas do begin if Ls_mt_kbn = 'M' then Brush.Color :=.. 2024. 4. 15.
메인폼과 Application 전역객체 메인폼과 Application 전역객체 델파이에서 메인폼은 일반폼과는 상당히 다르게 동작한다. 간혹 이를 잘못 이해해서 오류를 내는 경우가 있다. 지난번 예제에서 나도 이런 차이를 간과하여 실수를 저질렀는데, 사실 이런 에러는 VCL의 별별 기능을 파헤쳐서 응용하는 고수들일 수록 많이 부닥칠 수 있다. 그런 예를 들어보자. 다음은 첨부한 예제의 폼의 메인 폼 소스이다. // MainFm.pas 메인폼 소스 {중략} var MainFrm: TMainFrm; // 전역 폼 변수 implementation {$R *.dfm} uses SubFm; procedure TMainFrm.FormCreate(Sender: TObject); begin if assigned(Application.MainForm) then.. 2024. 4. 7.
델파이 줄바꿈 방법 델파이 줄바꿈 방법 showmessage('Line1'^M^J'Line2'^M^J'Line3'); showmessage('Line1'#13#10'Line2'#13#10'Line3'); 위 메시지 박스는 동일한 결과를 출력한다. 2024. 3. 25.
델파이에서 화면에 자석효과 주는 법 델파이에서 화면에 자석효과 주는 법 화면구석에 폼을 끌어다가 구석가까이가면 자석처럼 붙는효과를 주기 위한 방법이다. ScreenSnap SnapBuffer 폼의 속성중 위에 두가지 속성을 이용하면 가능하다. ScreenSnap : 자석효과를 사용할지 여부 결정 SnapBuffer : 픽셀 값을 지정 (화면의 가장자리와 몇 픽셀 거리에 가면 붙을 것) 이 효과는 '디스플레이 등록정보'의 '효과' 탭에서 ' 마우스를 끄는 동안 창 내용 표시'가 설정되어 있어야 된다. 이게 꺼져 있을 경우 (이동중에 폼의 위치가 선으로 표시되는 상태)에도 작동은 잘 합니다만, 바로바로 적용되지는 않고, 폼 드래그를 마친 뒤에 효과가 나타난다. 2024. 3. 18.
CPU 종류 알아오기 CPU 종류 알아오기 레지스트리를 이용한 CPU 종류 알아오기 입니다. function GetCPUType: String; var Registry: TRegistry; begin Registry:=TRegistry.Create; try Registry.RootKey:=HKEY_LOCAL_MACHINE; Registry.OpenKey('HARDWARE\DESCRIPTION\System\CentralProcessor\0',False); if Registry.ValueExists('ProcessorNameString') then Result := Registry.ReadString('ProcessorNameString') else Result := Registry.ReadString('Identifier');.. 2024. 3. 15.
디렉토리 삭제 및 하위 디렉토리 파일 삭제 디렉토리 삭제 및 하위 디렉토리 파일 삭제 uses ShellAPI; /---------------------------------------------------------------- // 디렉토리 및 파일을 지운다. // 하위 디렉토리와 모든 파일도 함께 지워진다. // 인자 설명 // - DirName : 지울 디렉토리명 // - UseRecycleBin : 휴지통을 사용할 것인가 여부 (아니면 영구삭제) // 리턴값 설명 // - 성공 여부 //---------------------------------------------------------------- function MinDeleteFile(const DirName : string; const UseRecycleBin: Boolean):.. 2024. 3. 12.
프로그램에 사용 DLL 목록 가져오기 프로그램에 사용 DLL 목록 가져오기 uses TlHelp32; {$R *.dfm} procedure EnumModules(Strings: TStrings); var Snapshot: THandle; ModuleEntry: TModuleEntry32; NextModule: BOOL; begin Snapshot := CreateToolhelp32Snapshot( TH32CS_SNAPALL, GetCurrentProcessID ); ModuleEntry.dwSize := SizeOf( TModuleEntry32 ); NextModule := Module32First( Snapshot, ModuleEntry ); while NextModule do {델마당만세} begin Strings.Add( ModuleE.. 2024. 3. 6.
하위폼 종료 감지 하위폼 종료 감지 하위폼의 종료시 메인폼에서 정보 감지하는방법 하위폼의 종료시 메인폼에서 정보 감지하는방법(Notification) 컴포넌트인(폼)경우 자신이 owner로 생성한 컴포넌트의 참조카운팅하는 메카니즘을 가지고 있는것 같은데 뒤져보면 Notificaton, FreeNotification 있는데 Notification을 오버라이딩하여 사용했다 type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); //하위폼 생성버튼 //.하위폼은 OnClose이벤트에서 action:=cafree하며 자기소멸시키며나옴 procedure Notification(Acomponent:Tcomponent;operation:.. 2024. 3. 4.
마우스 포인터 좌표의 윈도우 정보얻기 마우스 포인터 좌표의 윈도우 정보얻기 마우스 포인터가 있는 좌표의 윈도우의 핸들, 클래스, 명칭을 보여주는 예제입니다. unit unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Timer1: TTimer; Label1: TLabel; Label2: TLabel; Label3: TLabel; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private procedure ShowHwndAndClassName(C.. 2024. 3. 1.
시스템 정보 알아보기 시스템 정보 알아보기 CPU, OS, Memory, Hardware, Software의 정보들이 있는 레지스트리 정보입니다 CPU HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\??? 프로세서 ProcessorNameString Identifier Identifier 속도 ~MHz (NT) // CPU속도 측정 function GetCPUMHz: Double; var TimerHi, TimerLo: DWORD; PriorityClass, Priority: Integer; begin PriorityClass := GetPriorityClass( GetCurrentProcess ); Priority := GetThreadPriority( G.. 2024. 2. 27.
한글 초/중/종성 알아내기 한글 초/중/종성 알아내기 type TCVJ = packed record //초성 중성 종성의 번호를 저장할 구조체 C :integer; V :integer; J :integer; end; const //유니코드 한글 초성 순서표 UniCodeC : array [0..18] of string = ('ㄱ','ㄲ','ㄴ','ㄷ','ㄸ','ㄹ','ㅁ','ㅂ','ㅃ','ㅅ', 'ㅆ','ㅇ','ㅈ','ㅉ','ㅊ','ㅋ','ㅌ','ㅍ','ㅎ'); //유니코드 한글 중성 순서표 UniCodeV : array [0..20] of string = ('ㅏ','ㅐ','ㅑ','ㅒ','ㅓ','ㅔ','ㅕ','ㅖ','ㅗ','ㅘ', 'ㅙ','ㅚ','ㅛ','ㅜ','ㅝ','ㅞ','ㅟ','ㅠ','ㅡ','ㅢ', 'ㅣ'); //유니코드 한글.. 2024. 2. 15.
폼 Border 없이 사이즈 변경 폼 Border 없이 사이즈 변경 폼이 Border 를 갖고 있지 않을 때 마우스가 경계에 오면 커서가 바뀌면서 ReSize 가 되게 하는 방법입니다. WM_NCHITTEST 를 가로채서 거기에서 마우스 좌표를 폼좌표계로 변환후 마우스 위치에 따라 메시지의 result 를 HTTOP, HTLEFT 등으로 바꿔주기만 하면 됩니다. 폼의 BorderStyle 를 bsNone 로 해서 경계를 없애준 뒤에 하면 됩니다. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton;.. 2024. 2. 1.
시스템 커스(Help) 바꾸기 시스템 커스 바꾸기 Windows.pas에 OCR 에 관련된 상수부분이 선언된곳이 있다 그곳에 OCR_HELP = 32651 이라고 선언해주시고 Windows.pas를 재컴파일 해주시면 시스템 커서를 바꾸실때 용의하다. { Cursor 바꾸기 OCR_NORMAL 일반적인 화살표 OCR_IBEAM 입력창 등에 사용되는 I빔 OCR_WAIT 모래시계 커서 OCR_CROSS 십자모양 커서 OCR_UP 위쪽 화살표 OCR_SIZE 크기조절 커서. 윈 NT에만 있음. OCR_SIZEALL과 동일. OCR_ICON 아이콘 커서. 윈 NT에만 있음. OCR_SIZENWSE NW to SE 크기조절 커서 OCR_SIZENESW NE to SW 크기조절 커서 OCR_SIZEWE 수평 크기 조절 커서 OCR_SIZENS .. 2024. 1. 30.
BMP에 DPI값 세팅하기 및 알아오기 BMP에 DPI값 세팅 unit MyGraphic; interface uses SysUtils, Classes, Graphics, Dialogs; function GetBMPFileDPI(FileName: String): LongInt; procedure SetBMPFileDPI(FileName: String; DPI: Integer); function GetBmpDPI(Bitmap: TBitmap): LongInt; procedure SetBmpDPI(Bitmap: TBitmap; DPI: Integer); implementation function GetBMPFileDPI(FileName: String): LongInt; var Stream: TFileStream; Data: Word; A: Doub.. 2024. 1. 26.
디버깅용 콘솔창 띄우기 디버깅용 콘솔창 띄우기 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); private { Private declarations } ConHwnd: THANDLE; public { Public declarations }.. 2024. 1. 12.