milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

TObject(Sender) vs. (Sender as TObject)

Details
Written by: Stanko Milosev
Category: Delphi
Published: 20 January 2010
Last Updated: 20 January 2010
Hits: 5986

TObject(Sender) is unsafe since:

TButton(Edit1).Caption := 'junk code';

will not raise an exception, while:

(Edit1 as TButton).Caption := 'junk code';

will raise an exception.

Taken from here.

Find if field exists in a dataset

Details
Written by: Stanko Milosev
Category: Delphi
Published: 18 January 2010
Last Updated: 18 December 2011
Hits: 8770
if Table.FieldDefs.IndexOf('User1') > -1 then
       ShowMessage('Found')
     else
       ShowMessage('NOT Found');

Taken from here.

FormatMesage

Details
Written by: Stanko Milosev
Category: Delphi
Published: 29 September 2009
Last Updated: 18 December 2011
Hits: 5636

Using:

FormatMessage(Format_Message_Allocate_Buffer + Format_Message_From_System, nil, dwResult, 0, @pstrError, 0, nil);

Taken from here.

Regional settings.

Details
Written by: Stanko Milosev
Category: Delphi
Published: 03 August 2009
Last Updated: 18 December 2011
Hits: 5806

If you want to change regional settings for your application (not globaly for Windows), you can use this code:

function MakeLCID( lgID: Word; srtid: Word ): DWORD;
begin
Result := MakeLong( lgid, srtid );
end;

function MakeLangID( p, s: Word ): Word;
begin
Result := (s shl 10) or p
end;

procedure TForm3.btn1Click(Sender: TObject);
begin
Win32Check( SetThreadLocale(
MakeLCID(
MakeLangID( LANG_ENGLISH, SUBLANG_ENGLISH_US), 0)));
GetFormatSettings;
Application.UpdateFormatSettings := false;
ShowMessage(FormatDateTime('ddd, dd mmm yyyy hh:nn:ss +0200', Now));
end;

Taken from here.

  1. CreateProcess - fail
  2. RSS
  3. Creating and modifying component templates
  4. Delphi 2007 IDE like Delphi 7

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 94 of 168

  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98