[RSS - Pasarkode] Category : delphi http://pasarkode.com/category-23-delphi.html Object Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Embarcadero Delphi. en-us 2014 Pasarkode.com Wed, 25 Nov 2020 12:55:26 +0700 Wed, 25 Nov 2020 12:55:26 +0700 http://pasarkode.com/images/pasarkode.com.fb.png Pasarkode.com http://pasarkode.com/rss/delphi.rss Check two files are equal http://pasarkode.com/kode-408-check-two-files-are-equal.code Source one   function Are2FilesEqual(const File1, File2: TFileName): Boolean; var ms1, ms2: TMemoryStream; begin Result := False; ms1 := TMemoryStream.Create; try ms1.LoadFromFile(File1); ms2 := TMemoryStream.Create; try ms2.LoadFromFile(File2); ... Define binary type http://pasarkode.com/kode-406-define-binary-type.code Source one   function GetEXEType(FileName: string): string; var BinaryType: DWORD; begin if GetBinaryType(PChar(FileName), Binarytype) then case BinaryType of SCS_32BIT_BINARY: Result := 'Win32 executable'; SCS_DOS_BINARY: Result := 'DOS executable'; ... Coloring Cells in a DBGrid http://pasarkode.com/kode-405-coloring-cells-in-a-dbgrid.code It's much easier to give color to DBGrids. Here you have to use the "OnDrawColumnCell"-Event. The following example is coloring the Cells of Column "Status" when the value is not "a". If you want to color the whole line you only have to delete the "If..." ... Coloring Cells in a StringGrid http://pasarkode.com/kode-404-coloring-cells-in-a-stringgrid.code The Source Code procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); Const //define your color here. Of course you //can use default colors too. clPaleGreen = TColor($CCFFCC); clPaleRed = ... Disable the Close X button on a Form http://pasarkode.com/kode-403-disable-the-close-x-button-on-a-form.code Source code for hide close button from a from procedure TFMain.FormCreate(Sender: TObject); var hMenuHandle: Integer; begin hMenuHandle := GetSystemMenu(Handle, False); if (hMenuHandle 0) then DeleteMenu(hMenuHandle, SC_CLOSE, ... Activating the Start Menu by Code http://pasarkode.com/kode-402-activating-the-start-menu-by-code.code Just code this event handler (in this example, a button click): procedure TForm1.Button1Click(Sender: TObject); begin SendMessage(Self.Handle, WM_SYSCOMMAND, SC_TASKLIST, ... Read Record Using AdoQuery with Condition http://pasarkode.com/kode-398-read-record-using-adoquery-with-condition.code Cnt: integer; try AdoQuery1.Sql.Text := 'SELECT * FROM TABLE_NAME'; Cnt := AdoQuery1.ExecSql; if Cnt = 1 then //only one record else if Cnt > 1 then //more 1 records else //exception from condition except //handle exception end; ... Displaying Indonesian Day of Week http://pasarkode.com/kode-396-displaying-indonesian-day-of-week.code Eg, displaying like this : "Tanggal 25/11/2006 adalah hari Sabtu" (in English: Day of week of 25/11/2006 is Saturday), this You can use combination of "DayOfWeek" function with your own dayOfWeek array of String unit Unit1; interface uses Windows, Messages, SysUtils, ... highlight HTML Tags in TRichEdit http://pasarkode.com/kode-395-highlight-html-tags-in-trichedit.code This sample code to highlight HTML tags in TRichEdit     procedure HTMLSyntax(RichEdit: TRichEdit; TextCol, TagCol, DopCol: TColor); var i, iDop: Integer; s: string; Col: TColor; isTag, isDop: Boolean; begin iDop := 0; isDop := False; isTag := False; ... Change Current Language http://pasarkode.com/kode-394-change-current-language.code To change current language, use LoadKeyboardLayout function.For example, first parameter 0x0407 is German (standard), 0x0409 is English (U.S.). procedure TForm1.Button1Click(Sender: TObject); begin LoadKeyboardLayout('00000407', ...