본문 바로가기

분류 전체보기1166

[Delphi] 파일 확장자 알아내기 function GetExt(FileName: string): string; var TempArray: TStringList; begin Result := ''; TempArray := TStringList.Create; ExtractStrings(['.'], [' '], PChar(FileName), TempArray); if Pos('.', FileName) 0 then Result := TempArray.Strings[TempArray.Count - 1]; TempArray.Clear; TempArray.Free; end; 2011. 7. 22.
[Delphi] ListBox 내용을 클립보드에 복사하기 uses절에 Clipbrd; 추가하고 ClipBoard.SetTextBuf( PChar(복사 할 내용) ); ex) ClipBoard.SetTextBuf( PChar( Listbox.Items.Strings[Listbox.ItemIndex] ) ); ClipBoard.SetTextBuf( PChar( Listbox.Items.Text ) ); 2011. 7. 15.
[Delphi] 델파이에서 파일쓰기 var F: TextFile; FileName: string;begin FileName := '파일명'; try try AssignFile(F, FileName); // 파일이 없으면 파일을 생성 if FileExists(FileName) then Append(F) // 기존 내용에 추가하기 else Rewrite(F); // 기존 내용을 덮어쓰기 Writeln(F, '작성 할 내용'); except on E: Exception do ; end; finally CloseFile(F); end; end; 2011. 6. 15.
[Delphi] 최상위 윈도우가 전체화면인지 확인하기 function IsMaxWindow: boolean; var Hnd: HWND; Rect: TRect; begin Result := False; Hnd := GetForegroundWindow(); // 현재 작업중인 윈도우를 알아내는 함수 GetWindowRect(Hnd, Rect); if (Rect.Left Rect.Top) then exit; if (Rect.Right = Screen.Width) and (Rect.Bottom = Screen.Height) then Result := True; // 전체화면 end; 2011. 5. 16.
[Delphi] 폼 드래그해서 이동하기 MouseDown 이벤트에서 ReleaseCapture; SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); 2011. 5. 16.
[Delphi] 하위 폴더까지 한번에 생성하기 uses SysUtils; function ForceDirectories(Dir: string): Boolean; 이런 좋은 함수를 이제야 알다니.. 2011. 5. 16.
[Delphi] 웹페이지 로딩 완료 체크하기 브라우저 컴포넌트의 DocumentComplete 이벤트에서 확인 가능함 !! procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); var CurWebrowser: IWebBrowser; TopWebBrowser: IWebBrowser; Document: OleVariant; WindowName: string; begin CurWebrowser := pDisp as IWebBrowser; TopWebBrowser := (Sender as TWebBrowser).DefaultInterface; if CurWebrowser = TopWebBrowser then ShowM.. 2011. 4. 7.
[Delphi] 전화번호 형식으로 바꾸기 function TelNoAutoMata(vTelNo: string): string; var tTelNo: string; FLocal, FSeoul: Boolean; begin tTelNo := StringReplace(vTelNo, '-', '', [rfReplaceAll, rfIgnoreCase]); if (Length(tTelNo) 12) then begin // Edit MaxLength : 13 result := copy(vTelNo, 1, 13); exit; end; FLocal := False; FSeoul := False; if tTelNo[1] = '0' then FLocal := True; if (FLocal) and (tTelNo[2] = '2') then FSeoul := True;.. 2011. 4. 5.
[Delphi] 문자 사이에서 숫자 추출 / 숫자 사이에서 문자 추출 { 문자 사이에서 숫자 추출하기 } function ExtractInt(AString: string): string; var I: Integer; TempString: string; begin TempString := ''; AString := Trim(AString); if AString '' then for I := 1 to Length(AString) do if (AString[I] in ['0'..'9']) then TempString := TempString + AString[I]; Result := Trim(TempString); end; { 숫자 사이에서 문자 추출하기 } function ExtractString(AString: string): string; var I: Integer; Te.. 2011. 4. 5.
[Delphi] 바탕화면 강제 새로고침 procedure UpdateDesktop; var hDesktop: HWND; begin hDesktop := FindWindowEx(FindWindowEx (FindWindow('Progman', 'Program Manager'), 0, 'SHELLDLL_DefView', nil), 0, 'SysListView32', nil); PostMessage(hDesktop, WM_KEYDOWN, VK_F5, 0); PostMessage(hDesktop, WM_KEYUP, VK_F5, 1 shl 31); end; 단점)) 새로고침 되면서 깜빡임!! 2011. 4. 5.