Blog信息 |
blog名称:注册会计师(注会)练习软件 日志总数:398 评论数量:116 留言数量:27 访问次数:3267811 建立时间:2005年6月6日 |

| |
[delpih编程]delphi查询access中某一张表是否存在 软件技术
吕向阳 发表于 2009/6/2 14:40:28 |
//方法一 adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add('select count(*) from sysobjects where name=''yourtablename''); adoquery1.open; if adoquery1.eof then showmessage('表不存在');
//方法二 var List:TstringList; begin List:=TstringList.create; try AdoConnection1.Gettablenames(List); if list.indexof(yourtablename)=-1 then showmessage('库中无此表!'); finally List.free; end; end;
|
|
[delpih编程]dbgrideh中精确控制某一特定单元格的颜色及加行号 软件技术
吕向阳 发表于 2009/5/31 0:01:42 |
procedure Tfmwater.DBGridEh2DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState); begin //以下是加行号 with DBGrideh2.DataSource.DataSet do begin if DataCol = 0 then //設置在第一列 begin if state <> dsInsert then rech := recno; //這句是關鍵。。。 DBGrideh2.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, IntToStr(rech)); inc(rech); //將i加1 end; //以下是精确控制特定条件的某个单元格的颜色 if datacol = 6 then begin if (DBGrideh2.DataSource.DataSet.FieldByName ('pay1').AsFloat <> DBGrideh2.DataSource.DataSet.FieldByName ('pay2').AsFloat) then begin DBGrideh2.Canvas.Brush.Color := clred; DBGrideh2.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, DBGrideh2.DataSource.DataSet.FieldByName ('pay2').AsString); end end;
end;
end;
|
|
[delpih编程]delphi对access数据库mdb的压缩 软件技术
吕向阳 发表于 2009/5/25 18:49:42 |
引用单元 uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,dao97;
========= 按钮事件 procedure TForm1.Button1Click(Sender: TObject); var x:DBEngine; begin x:=CoDBEngine.Create; x.CompactDatabase('d:\nwind97.mdb','d: \backup.mdb','',0,'');
end;
|
|
[delpih编程]窗体有焦点时热键生效,切换到其他程序时热键失效 软件技术
吕向阳 发表于 2009/5/25 17:42:33 |
核心思路就是加入一个ApplicationEvents控件,控件在addtion栏 中,delphi的内置控件。
在其active事件中注册热键,在deactive控件中取消注册就可以了,其 他的照旧。
procedure TForm1.ApplicationEvents1Deactivate(Sender: TObject); var i: Integer; begin //注销热键 for i := Low(HotKeyId) to High(HotKeyId) do begin UnRegisterHotKey(handle, HotKeyId[i]); GlobalDeleteAtom(HotKeyId[i]); end; end;
procedure TForm1.ApplicationEvents1Activate(Sender: TObject); var i: integer; begin // for i := Low(HotKeyId) to High(HotKeyId) do HotKeyId[i] := GlobalAddAtom(PChar(IntToStr(i))); //热键命 名可随意
RegisterHotKey(Handle, HotKeyId[11], MOD_CONTROL, 65); //PageUp RegisterHotKey(Handle, HotKeyId[12], MOD_CONTROL, 66); //PageUp RegisterHotKey(Handle, HotKeyId[13], MOD_CONTROL, 67); //PageUp RegisterHotKey(Handle, HotKeyId[14], MOD_CONTROL, 68); //PageUp RegisterHotKey(Handle, HotKeyId[15], MOD_CONTROL, 69); //PageUp RegisterHotKey(Handle, HotKeyId[16], MOD_CONTROL, 49); //PageUp RegisterHotKey(Handle, HotKeyId[17], MOD_CONTROL, 50); //PageUp
RegisterHotKey(Handle, HotKeyId[5], 0, VK_PRIOR); //PageUp RegisterHotKey(Handle, HotKeyId |
|
[delpih编程]改进的trackbar控件 软件技术
吕向阳 发表于 2009/5/25 14:03:29 |
unit utrackbar;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls;
type
TmyTrackBar = class(TTrackBar) private FOldValue: Integer; FOnmyChange: TNotifyEvent; procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN; procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP; published property OnmyChange: TNotifyEvent read FOnmyChange write FOnmyChange; end;
procedure Register;
implementation
procedure Register; begin RegisterComponents('lxy', [tmytrackbar]); end;
procedure TmyTrackBar.WMLButtonDown(var Message: TWMLButtonDown); begin
FOldValue := Position; inherited; end;
procedure TmyTrackBar.WMLButtonUp(var Message: TWMLButtonUp); begin inherited; if Assigned(FOnmyChange) and (FOldValue <> Position) then begin FOnmyChange(Self); end; end; end.
|
|
[delpih编程]随机提取记录的SQL例子 软件技术
吕向阳 发表于 2009/5/22 22:37:21 |
随机提取10条记录的例子: SQL Server:
Select Top 10 * From 表 Order By NewID()
Access
Select Top 10 * From 表 Order By Rnd(ID) Rnd(ID) 其中的ID是自动编号字段,可以利用其他任何数值来完成,比 如用姓名字段(UserName) Select Top 10 * From 表 Order BY Rnd(Len(UserName))
MySql:Select * From 表 Order By Rand() Limit 10
|
|
|