Delphi Tip266 메세지 다이어그램(Message Dialog) 체크박스(CheckBox) 추가 메세지 다이어그램(Message Dialog) 체크박스(CheckBox) 추가 procedure TForm1.Button1Click(Sender: TObject);varAMsgDialog: TForm; function GetCheckValue(ADialog: TForm; const AName: String): boolean;vari: integer;beginfor i:=0 to ADialog.ControlCount-1 dobeginif ( ADialog.Controls[i].Name = AName ) and ( ADialog.Controls[i] is TCheckBox ) thenbeginResult := (ADialog.Controls[i] as TCheckBox).Checked;break;en.. 2024. 6. 6. TImage에 색상바 그리기 TImage에 색상바 그리기 unit Unit1; interface usesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, ExtCtrls, StdCtrls; typeTMain = class(TForm)HueImg: TImage;ColImg: TImage;Label1: TLabel;FGColorPanel: TPanel;BGColorPanel: TPanel;procedure FormCreate(Sender: TObject);procedure FormResize(Sender: TObject);procedure HueImgMouseDown(Sender: TObject; Button: TMouseBut.. 2024. 6. 3. 바코드프린터 출력 참고 바코드프린터 출력 procedure TForm1.Button4Click(Sender: TObject); var s, Str, data: String; begin data := Edit1.Text; S:=''; s:= Chr($1B)+ Chr($61)+Chr($1); // ' 정렬 0:왼쪽 1:중앙 2:오른쪽 S:= S + chr($1D) + chr($21)+ chr($1); //글자크기 S:= S + '영수증'+ chr($0D)+ chr($0A)+chr($0D)+ chr($0A); //원하글자와 제어코드를 계속해서 추가합니다.. ComPort1.WriteStr(s); S := ''; S:= S + chr($1D)+chr($21)+chr($0); //글자크기 처음으로돌리기 s:= S + Chr($1B.. 2024. 6. 2. 키보드 키입력 막기 - 화면 캡처 방지(Blocking Screen Capture) 키보드 키입력 막기 - 화면 캡처 방지(Blocking Screen Capture) unit Unit1; interface usesWinapi.Windows, Winapi.Messages, System.SysUtils,System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms,Vcl.Dialogs, Vcl.StdCtrls, ClipBrd; typeTForm1 = class(TForm)Button1: TButton;procedure FormCreate(Sender: TObject);private{ Private declarations }procedure ApplicationIdle(Sender: TObject; var Done: B.. 2024. 5. 29. DBGrid 동일값 셀병합(컬럼머지) DBGrid 동일값 셀병합 개발을 하다보면, DBGrid 콤포넌트의 기능이 약해서,제3자 Grid 콤포넌트를 많이 사용하게 된다. 그런데, 그 덩치큰 삼자 Grid 콤포넌트의 전체 기능이 필요한 것이 아니고,한두가지 기능만 필요한 경우가 많다.더우기, 퀀텀그리드 같은 경우는 전체 레코드를 메모리에 로딩하기 때문에,필요한 한두가지 기능때문에 쓰기는 참 사치스럽기까지 하다. 속도향상을 위해 메모리테이블을 써야 되는 경우도 있는데,퀀텀에서 또 내부적으로 메모리테이블을 사용하므로이런 경우 이중으로 메모리를 낭비하는 셈이 된다. 물론, 요즘 일반적 컴 사양에서 별무리가 아니라 하더라도,한두가지 기능때문에 이런 식으로 퀀텀을 쓰기에는소 잡는 칼로 닭 잡는 수가 될 수도 있다는 얘기다. 이 예제는, 인접하는 .. 2024. 5. 27. 내 실행파일 정보보기 내 실행파일 정보보기 procedure TForm1.Button1Click(Sender: TObject); const InfoNum = 10; InfoStr: array[1..InfoNum] of string = ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFileName', 'ProductName', 'ProductVersion', 'Comments'); var S: string; n, Len, i: DWORD; Buf: PChar; Value: PChar; begin S := Application.ExeName; n := GetFileVersion.. 2024. 5. 23. ShowModal,DialogBox,ShowMessage 등 떠 있을 때 폼 Disable 막기 ShowModal,DialogBox,ShowMessage 등 떠 있을 때 폼 Disable 막기 typeTForm1 = class(TForm) ...Timer1: TTimer;procedure Timer1Timer(Sender: TObject)privateprocedure WMEnable(var Msg: TMessage); message WM_ENABLE;end; implementation procedure TForm1.Timer1Timer(Sender: TObject);beginTimer1.Enabled:= False;EnableWindow(Handle, True);end; procedure TForm1.WMEnable(var Msg: TMessage);beginif Msg.wParam = 0 th.. 2024. 5. 21. 퀀텀 그리드 컬럼 동적 생성 퀀텀 그리드 컬럼 동적 생성 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. 이전 1 2 3 4 5 6 ··· 14 다음