2005年2月27日星期日

Book: Knoppix Hacks

cover of Knoppix Hasks

Knoppix Hacks is an invaluable collection of one hundred industrial-strength hacks for new Linux users, power users, and system administrators using--or considering using--the Knoppix Live CD. These tips and tools show how to use the enormous amount of software on this live CD to troubleshoot, repair, upgrade, disinfect, and generally be productive without Windows--without the difficulty of installing Linux itself. [Full Description]


http://www.oreilly.com/catalog/knoppixhks/
[@more@] Some sample chapters:
Hack 5: Free Your CD to Make Knoppix Run Faster (PDF)
Hack 33: Install Knoppix as a Single-Boot System (PDF)
Hack 40: Create an Emergency Router (PDF)
Hack 61: Migrate to a New Hard Drive (PDF)
Hack 78: Scan for Viruses (PDF)

2005年2月26日星期六

文摘: MSN / QQ 中的动画表情 在Delphi中RichEdit的实现。

相信用过QQ、MSN中的动画表情对我们的吸引力了吧。在前几天我的一个小应用中需要添加这样的一个功能,首先从网上下载了RXLib2.75(包括RxRichEdit),安装后测试了一下它提供的例子$(DELPHI)RXDemoRICHED2Richedit.dpr,在使用插入GIF图片时我发现了一个严重的问题:就是GIF图片是不会动的。因为原来对COM这些技术接触较少,只有上网查询资料,首先我去了大富翁www.delphibbs.com查找,不过没有查到,后来终于在网上查到了dtianx大侠的资料(见文章前面的链接),不过我发现他提供的代码是C++下的,于是把这些代码转换了一下,使其在Delphi下也能用。 ...

原文出处: CSDN

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ActiveX, ComCtrls, RxRichEd, ImageOleLib_TLB;

//RxRichEd单元是Rxlib下的RxRichEdit,一套增强功能的RichEdit
//ImageOleLib_TLB是从qq的ImageOle.dll引入的类型库

const
IID_IOleObject: TGUID = (
D1: $00000112; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00,
$46));
EM_GETOLEINTERFACE = WM_USER + 60;
type
TForm1 = class(TForm)
Button1: TButton;
Editor: TRxRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
FRTF: IRichEditOle;
FLockBytes: ILockBytes;
FStorage: ISTORAGE;
FClientSite: IOLECLIENTSITE;
m_lpObject: IOleObject;
m_lpAnimator: TGifAnimator;
i_GifAnimator: IGifAnimator;
reobject: TReObject;
clsid: TGuid;
sizel: tagSize;
dwStart, dwEnd: DWORD;
Rect:TRect;
begin
try
if CreateILockBytesOnHGlobal(0, True, FLockBytes) <> S_OK then
begin
showmessage('Error to create Global Heap');
exit;
end;
//建立一个混合文档存取对象
if StgCreateDocfileOnILockBytes(FLockBytes, STGM_SHARE_EXCLUSIVE or
STGM_CREATE or STGM_READWRITE, 0, FStorage) <> S_OK then
begin
Showmessage('Error to create storage');
exit;
end;
//取得RichEdit的接口
Sendmessage(Editor.handle,EM_GETOLEINTERFACE,0,LongInt(@FRTF));

if FRTF.GetClientSite(FClientSite)<>S_OK then
begin
ShowMessage('Error to get ClentSite');
Exit;
end;
CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
m_lpAnimator := TGifAnimator.Create(Self);
i_GifAnimator := m_lpAnimator.ControlInterface;
i_GifAnimator.LoadFromFile('c:ti.gif');
i_GifAnimator.QueryInterface(IID_IOleObject, m_lpObject);
OleSetContainedObject(m_lpObject, True);
FillChar(ReObject, SizeOf(ReObject), 0);
ReObject.cbStruct := SizeOf(ReObject);
m_lpObject.GetUserClassID(clsid);
ReObject.clsid := clsid;
reobject.cp := REO_CP_SELECTION;
//content, but not static
reobject.dvaspect := DVASPECT_CONTENT;
//goes in the same line of text line
reobject.dwFlags := REO_BELOWBASELINE; //REO_RESIZABLE |
reobject.dwUser := 0;
//the very object
reobject.poleobj := m_lpObject;
//client site contain the object
reobject.polesite := FClientSite;
//the storage
reobject.pstg := FStorage;
sizel.cx := 0;
sizel.cy := 0;
reobject.sizel := sizel;
//Sel all text
SendMessage(Editor.Handle, EM_SETSEL, 0, -1);
SendMessage(Editor.Handle, EM_GETSEL, dwStart, dwEnd);
SendMessage(Editor.Handle, EM_SETSEL, dwEnd + 1, dwEnd + 1);
//Insert after the line of text
FRTF.InsertObject(reobject);
SendMessage(Editor.Handle, EM_SCROLLCARET, 0, 0);
//VARIANT_BOOL ret;
//do frame changing
m_lpAnimator.TriggerFrameChange();
//show it
m_lpObject.DoVerb(OLEIVERB_UIACTIVATE, Nil, FClientSite, 0, Editor.Handle,Rect);
// m_lpObject.DoVerb(
m_lpObject.DoVerb(OLEIVERB_SHOW, Nil, FClientSite, 0, Editor.Handle, Rect);
//redraw the window to show animation
redrawwindow(Handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ERASENOW or RDW_ALLCHILDREN);
finally
FRTF:=nil;
FClientSite := nil;
FStorage :=nil;
end;
end;

end.

2005年2月24日星期四

xplorer2中x2tips的汉化方法

下载了Snoppy汉化的xplorer2-1.1.0.3(我已经懒得维护自己的“不完全汉化版”了),发现x2tips还是没有汉化,倒是另外提供了一个HLP文档,内容完全是x2tips里面的。也许是他不知道怎样汉化,毕竟这个需要一点技巧。

1. 先翻译x2tips.rtf(这个其实他已经做了)

2. 然后将翻译后的x2tips.rtf用文本编辑器打开,删除RTF头和每条tips之间多余的par,另存为x2tips.txt
(x2运行时读取的是这个文件)

3. 然后用reshacker等工具打开xplorer2.exe,在string table中可以找到一个rtf头
11260,
"{rtf1ansiansicpg1252deff0deflang2057{fonttbl{f0fmodernfprq6fcharset134
'cb'ce'cc'e5;}{f1fswissfprq2fcharset0
Verdana;}{f2fswissfprq2fcharset134
'cb'ce'cc'e5;}{f3fmodernfprq1fcharset0 Courier
New;}{f4fmodernfprq1fcharset134 'cb'ce'cc'e5;}{f5fnilfprq2fcharset134
'cb'ce'cc'e5;}}n{colortbl
;red0green0blue255;red255green0blue0;}nviewkind4uc1pardlang2052bf0fs26'c4'e3'd6'aa'b5'c0'c2'f0lang2057f1
...b0fs18parnparn"

x2运行时实际是从x2tips.txt中抽取一条,然后在前面添加这个rtf头,放到对话框中显示的

按RTF的要求,需要在这个头中声明后面文本需要用到的字体和颜色
一个简单的做法就是将前面翻译后x2tips.rtf的RTF头拷贝过来

11260,
"{rtf1ansiansicpg1252deff0deflang2057{fonttbl{f0fmodernfprq6fcharset134
'cb'ce'cc'e5;}{f1fswissfprq2fcharset0
Verdana;}{f2fswissfprq2fcharset134
'cb'ce'cc'e5;}{f3fmodernfprq1fcharset0 Courier
New;}{f4fmodernfprq1fcharset134 'cb'ce'cc'e5;}{f5fnilfprq2fcharset134
'cb'ce'cc'e5;}}n{colortbl
;red0green0blue255;red255green0blue0;}nviewkind4uc1pardlang2052bf0fs26'c4'e3'd6'aa'b5'c0'c2'f0lang2057f1
...b0fs18parnparn"

我这里将f0和f2字体改成了宋体('cb'ce'cc'e5)



Powered by ScribeFire.

2005年2月12日星期六

Total Commander 6.50出来了

还在家里过年,发现Total Commander已经推出了6.5版本
这个工具从来没有让我失望,但我正觉得xplorer2的一些功能不错时,Total Commander里面也有了,而且做的更好

比较重要的新功能有:

  • 缩略图方式(thumbnail view, 这下xplorer2不能专美了)
  • 自定义显示栏目列表(Custom columns mode, 也是xplorer2提供了但tc原来没有的)
  • 内容插件接口(Content plugins),可以通过插件提取文件的描述信息,比如从mp3的tag从读取作者、歌名, 并且可以用于搜索(比xplorer2的接口要强大, 它只能利用系统插件,开发起来也比较麻烦)
  • 自动安装插件

New in Total Commander 6.50:

- Thumbnail view: Display of miniature pictures for images and some other file types
缩略图方式,这下xplorer2不能专美了
- Custom columns mode: Up to 29 different user-defined view modes with custom columns
自定义显示栏目列表, 也是xplorer2提供了但tc原来没有的
- Content plugins: Display+Search for additional file properties, use in multi-rename tool
内容插件接口,可以通过插件提取文件的描述信息,比如从mp3的tag从读取作者、歌名
并且可以用于搜索--比xplorer2的接口要强大(它只能利用系统插件,开发起来也比较麻烦)
- Overlay icons for special file types like LNK files (configurable)
- Automatic installation of plugins and languages when opening plugin archive (if supported by the plugin)
自动安装插件
- New configuration page for configuring all plugin types
- Alt+Shift+F3 loads lister without plugins and any multimedia additions
- Shift+button click on current directory switches to the dir part on which you clicked
与xplorer2类似的功能: 标题上的路径可以分段点击(不过视觉效果不如x2)
- Shift+button click in search on 'go to file' or 'feed to listbox' opens dir in new tab
- Search for NTFS-encrypted files
- Define different location of tree content files (treeinfo.wc)
- Show current speed also when copying in synchronize dirs function
- FTP: Support for MODE Z compressed uploading/downloading
- New type of locked tab: still allows to change dirs, but reverts to tab-root when clicking "" or switching to other tab
允许改变目录的锁定标签页
- Multi-rename tool: Multiple search+replace, search+replace history, button to reload rename results
- F5 - F2 now transfers in background also for FTP uploads+downloads
- New pseudo environment variables supported in path names, pointing to locations of virtual folders:
%APPDATA%,
%DESKTOP%, %PERSONAL% (My Documents), %PROGRAMS%, %STARTMENU%, %FONTS%,
%STARTUP% (use lowercase to access env vars with these names)
- New
internal commands (for button bar, starter menu and user-defined
hotkeys) to change drives: cm_GotoDriveA..cm_GotoDriveZ,
cm_GotoNextDrive and cm_GotoPreviousDrive
- New internal commands cm_srcactivatetab1..10 activates tab 1-10 in source panel, similar for target panel.
-
Subdir filters now also work when copying (only files of this type).
Syntax: Include: somedir1 somedir2 Exclude: *.* | somedir1 somedir2
-
Synchronize dirs: Also allow to set copy direction of equal files (via
right click menu only!), e.g. for copying them to a different location
- Remember special display modes (thumbnails, comments, custom columns) separately per tab, and when closing
- The complete list can be found in history.txt



Powered by ScribeFire.

2005年2月11日星期五

Vim Tip #118: Configure gVim as Internet Explorer 'View Source' editor

http://vim.sourceforge.net/tips/tip.php?tip_id=118

The reason:
- Hated it when the file was "Too big for notepad" :)
- syntax highlighting

Key point:
1. How to make gvim the IE's 'View source' editor
2. How to let it auto syntax higlighting, as the temporary file might has no extension.

Answers:
1.
REGEDIT4 [HKEY_LOCAL_MACHINESOFTWAREMicrosoftInternet ExplorerView
Source EditorEditor Name]
@="c:Program Filesvimgvim.vbs"
Here's
another problem: "Unfortunately, you can't specify a quoted filename
argument here, i.e. "%1". The editor specified is supposed to handle
filenames which contain spaces(which come from 'Temporary Internet
Files') ."(seems that IE6 doesn't have this limitation). Thus we
need a vbs wrapper (or a shortcut with arguments specified) to quote
the argument.

2. gvim -c syntax=html

Powered by ScribeFire.