GNU Gettext for Borland Delphi, C++ Builder and Kylix

使Delphi支持多语言的一种途径
使用方法:
http://dybdahl.dk/dxgettext/docs/howto.php

Tools

  • GNU gettext for Delphi and C++ Builder toolkit: dxgettext-1.2.2.exe
  • GNU gettext for Kylix toolkit: dxgettext-1.1.1.tar.gz
  • poedit to edit translations (a must-have)
  • UniRed – a free unicode plain-text editor for Windows, good for converting text files between character sets etc.

Other stuff

[转自]GNU Gettext for Borland Delphi, C++ Builder and Kylix

DDevExtensions 1.9发布——支持Delphi2009

更新:

  • Added: Support for Delphi 2009
  • Added: Compiler-Dialog: AutoSave after successful compile (default: off)
  • Added: OldPalette: AlphaSort option for the palette popup menu
  • Added: OldPalette supports “Small Fonts” for the tab font
  • Added: “Close all and terminate” by keeping the CTRL key pressed while closing the IDE (from DelphiSpeedUp)
  • Added: Disable package cache option (from DelphiSpeedUp)
  • Added: Shows waiting cursor while loading designtime package (from DelphiSpeedUp)
  • Added: Option to enable the IDE’s “User can cancel kibitzing” feature [CodeCompletion and HelpInsight can be aborted by ESC/mouse move]
  • Added: The “Add to implementation” checkbox in the “Use Unit” Dialog can be switch by pressing the SHIFT-key
  • Renabled: Editor Focus bugfix (bug still exists)
  • Removed: Delphi 5-2007 support
  • Removed: ComponentSelector (superseded by Delphi’s ToolPalette search edit)
  • Removed: CompilerEnhancements (superseded by the new project warning options)
  • Removed: FormDesigner Alt key disables guide lines (superseded by Delphi 2009’s implementation)

 

下载地址:http://andy.jgknet.de/dspeedup/index.php?page=download

delphi中给supermap的地图页面添加点

环境:

Delphi7中用WebBrowser打开地图页面,需要在其中添加一个起始点的显示。

supermap的地图显示用ajax实现。

解决办法:

1)在地图页面上添加显示点的javascript函数ShowPOI2(x,y,CallerID),可以添加在js文件中,比如说page.js或者customation.js等同地图页面一起载入的文件。

function ShowPOI2(x,y,callerid)
{
       var InnerHtmlName="<img src=’images/car2.gif’/><font face=’宋体’ size=’2′ color=’#800080′ style=’text-decoration: blink’>"+callerid+"</font>";
       map.CustomLayer.InsertMark("POIInfo1", x, y, 0, 0, InnerHtmlName,10);
       map.SetCenterAndZoom(x,y,8);
}

其中,

CustomLayer.InsertMark(id, x, y, w, h, innerHtml, className, zIndex)
添加自定义注记。如果地图中已经存在与该注记ID相同的对象,则替换存在的注记。
id:自定义注记的ID值。

x:对象的x坐标(地理坐标)

y:对象的y坐标(地理坐标)

w:对象的宽度(显示宽度),以象素(px)为单位

h: 对象的高度(显示高度),以象素(px)为单位

innerHtml:呈现时的HTML

className:呈现时的样式单CSS的ID

zIndex:自定义注记层的Index值。

摘自is.net的开发手册。

如果有多个点要同时显示的,并且都是用InsertMark添加的,那么第一个参数id,就必须不同;或者也可以考虑用addMark添加,addmark允许id相同。

2)   在Delphi中,用webbrowser载入地图页面,利用IHTMLWindow2的executeScript进行调用,传递x,y,callerid的值到ShowPOI函数。如下:

jsfunc := Format('ShowPOI2(%f,%f,%s)', [x, y, 
QuotedStr(ACallerID)]); frame_doc.parentWindow.execScript(jsfunc, 'JavaScript');


注意要引用到地图的frame,不然,会找不到相应的script。


3)  注意,如果点的值位于地图的显示范围之外,可能引起地图白屏,就是白茫茫一片,什么也看不到。

Delphi 资源编辑器top3

有几种资源工具可以帮助Delphi开发员可以从23位的Windows 可执行文件中查看、修改、添加、删除资源。

下面就是:

1. XN Resource Explorer

XN Resource Explorer 是一个免费(带源码),强大,全功能的资源编辑器,支持Windows 98, Windows 2000 和 Windows XP上的PE查看。XN Resource Explorer 支持Delphi所有的资源文件(.RES)和PE模块(.EXE, .DLL等)。它可以显示组成Delphi程序的所有模块,让你编辑Delphi窗体中使用的组件的属性。

2. Resource Hacker

一个可以在32位Windows 可执行文件和资源文件(.RES)中查看,修改,重命名,添加,删除和释放资源的免费工具。它带有一个内部的资源脚本的编译和反编译器,可以工作在Win95, Win98, WinME, WinNT, Win2000 和 WinXP系统上。

3. Resource-Grabber

这个工具可以扫描系统上的目录和驱动器,从你指定的目录中的应用程序和DLL文件中释放出所有的位图文件,按钮文件,图标,鼠标,JPG/JPEG图像,音频文件,视频片段,动画,窗体图片,网页,文本和其他资源。

翻译自:

http://delphi.about.com/od/toppicks/tp/aatpresourceman.htm

TWebBrowser 获取html文件中Frame文档的方法

看代码:

var  document: IHTMLDocument2;
  ole_index: OleVariant;
  frame_dispatch: IDispatch;
  frame_win: IHTMLWindow2;
  frame_doc: IHTMLDocument2;
begin
//获取主文档  
document := WebBrowser1.Document as IHTMLDocument2;
if not Assigned(document) then Exit; //获取第二个frame,为IDIspatch类型 ole_index := 1; frame_dispatch := document.Frames.Item(ole_index);
//如果不为空,转换IDispatch为IHTMLWindow2,获取document
if frame_dispatch <> nil then begin frame_win := frame_dispatch as IHTMLWindow2; frame_doc := frame_win.document;
end;

接下来就可以根据frame_doc进行各种处理了。关键就是通过IDispatch中转类型。

Delphi中从Excel导入数据的通用方法

用Delphi从excel导入数据的时候,经常都只是需要一个worksheet,然后循环读取单元格信息,存入数据库。但是,每次都要重复的写关于打开,关闭excel的application的代码。

话不多说,看代码:

TypeTExcelFunction = procedure(asheet: OleVariant);//声明导入函数//afilename为数据源文件名,func为执行导入的函数
procedure RunExcelApplication (afilename: string;                              func: TExcelFunction);
var
  app: OleVariant;
  oldCursor: TCurSor;
begin
  oldCursor := Screen.Cursor;  //保存鼠标指针状态
  Screen.Cursor := crHourGlass;
  try
    CoInitializeEx(nil, 0);
    app := CreateOleObject('Excel.Application');
    app.DisplayAlerts := False;
    app.WorkBooks.open(afilename); //打开源文件
    app.WorkSheets[1].Activate;
    app.visible := False;//隐藏excel窗体
    if Assigned(func) then  //执行导入函数
      func(app.ActiveSheet);//传递sheet给函数进行导入
    app.WorkBooks.close;
    app.quit;//关闭推出excel
    Screen.Cursor := oldCursor;
  except
    on e: Exception do
    begin
      MessageBox(GetActiveWindow, pchar(e.message), '提示', MB_OK + MB_ICONINFORMATION);
      Screen.Cursor := OldCursor;
      Exit;
    end;
  end;
end;

关键在于定义一个以sheet:OLEVariant为参数的过程,来执行具体的导入工作。

访问单元格:sheet.cells[row,col]

转为string:vartostr(sheet.cells[row,col])

转为datetime:vartodatetime(sheet.cells[row,col])

……

最好先转化为基本类型后,再进行其他操作,可以减少一些莫名的错误。

IE7,Delphi使用TWebBrowser提示psapi.dll出错

系统升级到IE7后,打开以前包含TWebBrowser的项目后,出错,显示

找不到过程入口点 GetProcessImageFileNameW PSAPI.DLL 动态链接库中。

后来,每次启动delphi,都会显示这个错误。

 

原因:

版本不符。IE7的WebBrowser控件为新的版本,依赖新的版本的psapi.dll,位于system32下,版本号为:5.2.3790.3959

查看delphi的bin路径,也发现了一个psapi.dll,版本为5.00.1641.1,而Delphi启动后,默认导入的是本目录下的psapi.dll,所以可能缺少了该函数而报错。

 

解决办法:

把Delphi的bin下的psapi.dll改名或删除。

程序设计相关资源–Delphi篇(2007-9-11最后更新)

书籍
程序设计的书太多,其中有好有坏,整理一些我认为值得看,有价值的书供大家参考,使大家在学习的过程中少走弯路。。。
1. 入门
《PASCAL 精要》- 如果你有兴趣用Delphi来开发程序,但你还没入门,建议你不要被Delphi的RAD迷惑,先从这本PASCAL精要开始。
http://www.marcocantu.com/epascal/chinese/default.htm
《Delphi 2005 从入门到精通》 – 《PASCAL精要》的作者所著的另一本书,说是从入门到精通,实际上只能带你入门,不过能入门已经够了。。。我当时看这本书的时候是Delphi 4,不过已经绝版了,现在能卖到的就是这本2005
http://www.china-pub.com/computers/common/info.asp?id=30066

继续阅读

Declaration of ‘%s’ differs from previous declaration (E2037)

       很奇怪的是,之前编译一直都没有问题,可是,今天编译的时候,就出现这个错误,并且是delphi7和Delphi 2007都是同样的错误。

根据帮助文档,只要确认声明和实现的函数名、参数名、参数类型,参数修饰、返回值等一样,就是说所有都一样,基本上就不会产生这个错误了。可是很不幸的,还是让我碰上了。

代码如下:

  public
    procedure ShowSubForm(AFormClass: TFormClass);

procedure TFrmMain.ShowSubForm(AFormClass: TFormClass);
begin
  if self.PanelMain.ControlCount > 0 then
  begin
    if PanelMain.Controls[0].ClassName = AFormClass.ClassName then
      Exit;
    Screen.Cursor := crHourGlass;
    PanelMain.Controls[0].Free;
  end;

  with AFormClass.Create(Application) do
  begin
    Visible := False;
    Screen.Cursor := crDefault;
    Parent := Self.PanelMain;
    BorderStyle := bsNone;
    Align := alClient;
    FrmMain.Caption := Caption;
    Show;
  end;
end;
经过仔细比对,可以确定,函数模样完全一致。
通过添加函数进行测试,发现,只要参数类型是TFormClass就会出现这个编译错误,甚至是TClass也可以编译通过,不知道是什么原因。

MMX6 发布

官方资料:
MMX 6 released

On March 26th 2008 ModelMaker Tools released ModelMaker Code Explorer 6. Check the upgrade policy to upgrade existing licenses.

Main new Features

 

ps:MMX是Delphi的插件,提供了及时编辑类的成员的方便途径。MMX6 的更新还是满大的。