Archive for September, 2008

get default system charset

Tuesday, September 16th, 2008

function TranslateCharsetInfo(lpSrc: integer;
  var lpCs: TCharsetInfo; dwFlags: DWORD): BOOL; stdcall;
  external ‘gdi32.dll’ name ‘TranslateCharsetInfo’;

function GetDefaultCharset: TFontCharset;
var
  dwCodePage: dWord;
  CharSetInfo: TCharSetInfo;
begin
  {get default codepage}
  dwCodePage := StrToIntDef(GetLocaleStr(GetUserDefaultLCID, LOCALE_IDEFAULTANSICODEPAGE, ”), 0);
  if dwCodePage = 0 then
    dwCodePage := StrToIntDef(GetLocaleStr(GetSystemDefaultLCID, LOCALE_IDEFAULTANSICODEPAGE, ”), GetACP());
  {convert codepage into charset}
  if TranslateCharsetInfo(dwCodePage, CharSetInfo, TCI_SRCCODEPAGE) then
    Result := CharSetInfo.ciCharset
  else
    Result := 0
end;

VoipBuster

Monday, September 15th, 2008

Вчера нужно было позвонить в США. Решил поискать что-нибудь дешевле, чем Skype и нашел VoipBuster из семейства BetaMax. Обещали 60 минут бесплатного trial
Зарегистрировался, позвонил, но в итоге через 5 минут он меня оборвал и написал, что trial окончен. В итоге перезвонил по skype (2.5 цента минута)

directives for D2007 complier

Thursday, September 11th, 2008

{$IFDEF VER200}
  {$DEFINE SMForDelphi3}
  {$DEFINE SMForDelphi4}
  {$DEFINE SMForDelphi5}
  {$DEFINE SMForDelphi6}
  {$DEFINE SMForDelphi7}
  {$DEFINE SMForDelphi2005}
  {$DEFINE SMForDelphi2006}
  {$IFDEF BCB}
    {$DEFINE SMForBCB2006}
    {$DEFINE SMForBCB2007}
    {$DEFINE SMForBCB2009}
  {$ENDIF}
  {$DEFINE SMForDelphi2007}
  {$DEFINE SMForRADStudio2007}
  {$DEFINE SMForDelphi2009}
{$ENDIF}

minor changes for viewers

Thursday, September 11th, 2008

Just found that most menu items have no any defined shortcut. For example, Open ->Ctrl+O, Save->Ctrl+S etc

Fixed today:-)

TSMReport component: load/save from streams

Wednesday, September 10th, 2008

the TSMReport component now have the LoadReportFromStream and SaveReportToStream methods
Using these methods you may load/save the reports in any stream, including BLOB-streams for field in any dataset or implement the packed/encoded streams (zip/ZLib, for example)

Viewer for MS Outlook Messages: testimonials

Tuesday, September 9th, 2008

Thanks for the software which has rescued a problem I have had while away from the office with Microsoft Outlook failing to install.

Professor David Cope

ExcelFile Viewer: testimonials

Wednesday, September 3rd, 2008

Trevor Harvey:
“xlsview received, installed and a long lost spreadsheet which I had given up hope of ever seeing again has been translated to openoffice.calc and is looking great.

Well done for some really useful S/W and excellent service.”

pack table (Paradox, dBase)

Tuesday, September 2nd, 2008

If you use the TTable component in Delphi then to find the code to pack the table (to remove the records which are marked as deleted) is not a problem. For example:
http://www.swissdelphicenter.ch/torry/showcode.php?id=35

But how to pack the table using pure BDE API? What if you do not want to use the TTable/TDatabase components?

Today I wrote the next code for this task:

uses BDE; 
 
procedure TfrmMain.piPackTableClick(Sender: TObject); 
 
  procedure DbiError(ErrorCode: DBIResult); 
  begin 
    raise Exception.CreateFmt('BDE Error Code: %x', [ErrorCode]); 
  end; 
 
  procedure Check(Status: DBIResult); 
  begin 
    if Status <> 0 then DbiError(Status); 
  end; 
 
  function StrToOem(const AnsiStr: string): string; 
  begin 
    SetLength(Result, Length(AnsiStr)); 
    if Length(Result) > 0 then 
      CharToOem(PChar(AnsiStr), PChar(Result)); 
  end; 
 
var 
  hDatabase: hDbiDb; 
  hTableCursor: hDbiCur; 
  TableDesc: CRTblDesc; 
begin 
  { check if BDE installed } 
  Check(dbiInit(nil));  
 
  { Open a database session with exclusive read/write access } 
  Check(DbiOpenDatabase('',  
                        nil, // database type (Standard) 
                        dbiReadWrite, // open mode (versus read-only) 
                        dbiOpenExcl, // exclusive (versus shared) 
                        nil, // database login password 
                        0, nil, nil, 
                        hDatabase)); 
  try 
    Check(DbiSetDirectory(hDatabase, Pointer(StrToOem(ExtractFilePath(cbFileName.Text)))));  
 
    { Open the table, returning its cursor handle } 
    Check(DbiOpenTable(hDatabase, 
          PChar(ExtractFileName(cbFileName.Text)), 
  {$IFDEF DB_PARADOX} 
          szParadox, 
  {$ENDIF}  
 
  {$IFDEF DB_DBASE} 
          szDBASE, 
  {$ENDIF} 
 
          nil, nil, 0, // no result index required 
          dbiReadOnly, dbiOpenShared, 
          xltField, // use logical field types (normal) 
          False, nil, 
          hTableCursor)); 
 
  {$IFDEF DB_PARADOX} 
    FillChar(TableDesc, SizeOf(CRTblDesc), #0); 
    with TableDesc do 
    begin 
      StrCopy(szTblName, PChar(ExtractFileName(cbFileName.Text))); 
      StrCopy(szTblType, szParadox); 
      bPack := True; 
    end; 
    Check(DbiCloseCursor(hTableCursor)); 
    Check(DbiDoRestructure(hDatabase, 1, @TableDesc, nil, nil, nil, False)); 
  {$ENDIF}  
 
  {$IFDEF DB_DBASE} 
    Check(DbiPackTable(hDatabase, hTableCursor, nil, szDBASE, True)) 
    Check(DbiCloseCursor(hTableCursor)); 
  {$ENDIF} 
  finally 
    Check(DbiCloseDatabase(hDatabase)); 
  end; 
end;

Chrome

Tuesday, September 2nd, 2008

Google запускает свой browser: http://googleblog.blogspot.com/2008/09/fresh-take-on-browser.html
Из отличий – свой движок Java-script и отдельный процес под каждый url в своем табе для просмотра (убивать при ошибке будем таб со своим процессом, а не весь browser).

Зачем им это нужно – вопрос второй. Лично мне сейчас интересно другое – есть другой продукт под названием Chrome (Pascal for Visual Studio .NET) Не знаю или зарегистрировали они свой TradeMark, но скорее всего зарегили. Как Google будет разбираться с этими RO (Remote Objects)?

Я не думаю, что их устроит позиционирование на уровне Google Chrome. Все-таки простые названия (Chrome) более запоминающиеся.
И почему они не пошли по протоптаной дорожке и не назвали gBrowser?

Delphi 2009

Monday, September 1st, 2008

The compiled exe/dll can’t be executed in Windows 95/98/ME because there is no unicode support.
The bad news because CodeGear could create the wrappers (from unicode->ansi functions) for this situation. Now they suggest to create these wrappers yourself and update the Windows.pas unit

Hope they will include the new unit with wrappers in next update for D2009