怎样能让执行的程序在右下角任务栏中而双击弹出表单 RT 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 去www.playicq.com注册一个用户登陆进去搜索trayicon,好了,你会看到很多,下载这个TrayIcon,然后使用它,它已经做得非常好了。如果你想知道原理,看它代码。 一个例子unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, Grids,DateUtils, ExtCtrls, Buttons,IniFiles, Menus, DB, DBTables,shellapi, ADODB, DBGrids;const MY_MESSAGE = WM_USER + 100;type TForm1 = class(TForm) Timer1: TTimer; ADOConnection1: TADOConnection; ADOQuery1: TADOQuery; Panel1: TPanel; Panel2: TPanel; DataSource1: TDataSource; DBGrid1: TDBGrid; Button1: TButton; Timer2: TTimer; ADOQuery2: TADOQuery; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormPaint(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Timer2Timer(Sender: TObject); private { Private declarations } public { Public declarations } procedure OnIconNotify(var Message: TMessage);message MY_MESSAGE; end;const screenwidth:longint=1024; screenheight:longint=768;var Form1: TForm1;implementationuses Unit2, Unit3;{$R *.dfm}{ TForm1 }procedure TForm1.OnIconNotify(var Message: TMessage);var busy:boolean;begin busy:=false; if not Busy then begin Busy:=true; if Message.LParam=WM_LBUTTONDBLCLK then begin form4.show; end; Busy := false; end;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);var nid:TNotifyIconData;begin nid.cbSize := sizeof(nid); // nid变量的字节数 nid.cbSize := sizeof(nid); // nid变量的字节数 nid.uID:=1; //内部标识,与加入小图标时的数一致 nid.Wnd := Handle; //主窗口句柄 Shell_NotifyIcon(NIM_DELETE,@nid); //去掉小图标 Shell_NotifyIcon(NIM_DELETE,@nid); //去掉小图标end;procedure TForm1.FormPaint(Sender: TObject);begin form1.Hide;end;procedure TForm1.Timer1Timer(Sender: TObject);var path:string; tf:TINIFile; user:string; s:string;begin path:=extractfilepath(application.ExeName); tf:=TINIFile.Create(path+'id.ini'); with tf do begin s:=readstring('user','user','user'); free; end; if s<>'user' then begin form1.ADOQuery2.Close; form1.ADOQuery2.SQL.Clear; form1.ADOQuery2.SQL.Add('select * from yhqxb where id=:s1'); form1.ADOQuery2.Parameters.ParamByName('s1').Value:=s; form1.ADOQuery2.Open; user:=form1.ADOQuery2.FieldValues['xm']; form1.ADOQuery1.Close; form1.ADOQuery1.SQL.Clear; form1.ADOQuery1.SQL.Add('select bgmc,jlbh,fjr,fjsj from xx where sjr=:s1 and zt=:s2'); form1.ADOQuery1.Parameters.ParamByName('s1').Value:=user; form1.ADOQuery1.Parameters.ParamByName('s2').Value:='未读'; form1.ADOQuery1.Open; form1.ADOQuery1.FieldByName('bgmc').DisplayLabel:='表格名称'; form1.ADOQuery1.FieldByName('jlbh').DisplayLabel:='记录编号'; form1.ADOQuery1.FieldByName('fjr').DisplayLabel:='发件人'; form1.ADOQuery1.FieldByName('fjsj').DisplayLabel:='发件时间'; if form1.ADOQuery1.RecordCount>0 then begin form1.DataSource1.DataSet:=form1.ADOQuery1; showwindow(form1.Handle,sw_restore); form1.Timer1.Enabled:=false; end; end;end;procedure TForm1.FormShow(Sender: TObject);var path:string; tf:TINIFile; user:string;begin path:=extractfilepath(application.ExeName); tf:=TINIFile.Create(path+'id.ini'); with tf do begin user:=readstring('user','user','user'); free; end; if user='user' then begin messagebox(form2.Handle,'该程序是第一次运行,请先输入你的用户名','信息',mb_ok or mb_iconinformation); form2.ShowModal; endend;procedure TForm1.Button1Click(Sender: TObject);begin showwindow(form1.Handle,SW_HIDE); form1.Timer1.Enabled:=true;end;procedure TForm1.FormCreate(Sender: TObject);var scaled:boolean; oldformwidth:integer; nid:TNotifyIconData; newhintfont:tfont;begin Scaled:=TRUE; if(Screen.width <> ScreenWidth)then begin OldFormWidth:=Width; Height:=longint(Height)*longint(Screen.Height)DIV ScreenHeight; Width:=longint(Width)*longint(Screen.Width)DIV ScreenWidth; ScaleBy(Screen.Width,ScreenWidth); Font.Size:=(Width DIV OldFormWidth)*Font.Size; end; nid.cbSize:=sizeof(nid); // nid变量的字节数 nid.Wnd:=Handle; // 主窗口句柄 nid.uID:=1; // 内部标识,可设为任意数 nid.hIcon:=Application.Icon.Handle; // 要加入的图标句柄,可任意指? nid.hIcon:=Application.Icon.Handle; // 要加入的图标句柄,可任意指? nid.szTip:='表格管理过程控制信息监控'; // 提示字符串 nid.uCallbackMessage:=MY_MESSAGE; // 回调函数消息 nid.uFlags:=NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有? if not Shell_NotifyIcon(NIM_ADD,@nid) then begin ShowMessage('Failed!'); Application.Terminate; end; {将程序的窗口样式设为TOOL窗口,可避免在任务条上出现} SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW); application.HintColor:=clred; application.HintHidePause:=5000; application.HintPause:=0; application.HintShortPause:=100; newhintfont:=tfont.Create; newhintfont.Name:='楷体-GB2312'; newhintfont.Color:=clwhite; newhintfont.Size:=10; form1.Timer1.Enabled:=false; form1.Timer2.Enabled:=false;end;procedure TForm1.Timer2Timer(Sender: TObject);var path:string; tf:TINIFile; user:string; s:string;begin path:=extractfilepath(application.ExeName); tf:=TINIFile.Create(path+'id.ini'); with tf do begin s:=readstring('user','user','user'); free; end; if s<>'user' then begin form1.ADOQuery2.Close; form1.ADOQuery2.SQL.Clear; form1.ADOQuery2.SQL.Add('select * from yhqxb where id=:s1'); form1.ADOQuery2.Parameters.ParamByName('s1').Value:=s; form1.ADOQuery2.Open; user:=form1.ADOQuery2.FieldValues['xm']; form3.ADOQuery1.Close; form3.ADOQuery1.SQL.Clear; form3.ADOQuery1.SQL.Add('select bgmc,jlbh,fjsj,sjr from xx where fjr=:s1 and zt=:s2 and fjsj<=:s3'); form3.ADOQuery1.Parameters.ParamByName('s1').Value:=user; form3.ADOQuery1.Parameters.ParamByName('s2').Value:='未读'; form3.ADOQuery1.Parameters.ParamByName('s3').Value:=now-3; form3.ADOQuery1.Open; if form3.ADOQuery1.RecordCount>0 then begin form3.Show; form1.Timer2.Enabled:=false; end; end;end;end. 下载免费的带源代码的控件Rx Lib 2.75,上面有一个rxTrayIcon控件就是你需要的!!! Nid.cbSize := sizeof(Nid); Nid.wnd := handle; Nid.uID := 1; //Icon 标示 Nid.uCallBackMessage := Wm_TrayIconMessage; Nid.hIcon := IconImage.Picture.Icon.handle; Nid.szTip := '..........; Nid.uFlags := Nif_Message Or Nif_Icon; Shell_NotifyIcon(NIM_ADD, @Nid); if Message.LParam=WM_LBUTTONDBLCLK then begin form4.show; end;就是双击任务栏中的图标弹出表单 如何把大图片(1280*1024)首尾相连,连接10张,20张,30张都可以,只要代码,谢谢 散分!!! 为什么用ADOTable删除数据课中的数据时总报错? 关于报表控件的问题 很急!看看! 关于分发带数据库的程序的一点小建议(抛砖引玉) 我的瑞星已是:13.34,为什么Nimda.win32还是骚扰我?thanks. 怎样结束一个应用程序,将所有占用空间都释放掉 下面的程序语句在Delphi5中编译通过,为什么在Delphi6中编译通不过?请各位解答! 我做了一个数据库单表或多表的查询组件包很好用。请大家多提意见 对浏览器编程熟的人来看一下 关于hint的问题
注册一个用户登陆进去
搜索trayicon,好了,你会看到很多,下载这个TrayIcon,然后使用它,它已经做得非常好了。
如果你想知道原理,看它代码。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Grids,DateUtils, ExtCtrls, Buttons,IniFiles,
Menus, DB, DBTables,shellapi, ADODB, DBGrids;
const MY_MESSAGE = WM_USER + 100;
type
TForm1 = class(TForm)
Timer1: TTimer;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Panel1: TPanel;
Panel2: TPanel;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
Timer2: TTimer;
ADOQuery2: TADOQuery;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormPaint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure OnIconNotify(var Message: TMessage);message MY_MESSAGE;
end;
const
screenwidth:longint=1024;
screenheight:longint=768;
var
Form1: TForm1;implementationuses Unit2, Unit3;{$R *.dfm}{ TForm1 }procedure TForm1.OnIconNotify(var Message: TMessage);
var
busy:boolean;
begin
busy:=false;
if not Busy then
begin
Busy:=true;
if Message.LParam=WM_LBUTTONDBLCLK then
begin
form4.show;
end;
Busy := false;
end;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
nid:TNotifyIconData;
begin
nid.cbSize := sizeof(nid); // nid变量的字节数
nid.cbSize := sizeof(nid); // nid变量的字节数
nid.uID:=1; //内部标识,与加入小图标时的数一致
nid.Wnd := Handle; //主窗口句柄
Shell_NotifyIcon(NIM_DELETE,@nid); //去掉小图标
Shell_NotifyIcon(NIM_DELETE,@nid); //去掉小图标
end;procedure TForm1.FormPaint(Sender: TObject);
begin
form1.Hide;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
path:string;
tf:TINIFile;
user:string;
s:string;
begin
path:=extractfilepath(application.ExeName);
tf:=TINIFile.Create(path+'id.ini');
with tf do
begin
s:=readstring('user','user','user');
free;
end;
if s<>'user' then
begin
form1.ADOQuery2.Close;
form1.ADOQuery2.SQL.Clear;
form1.ADOQuery2.SQL.Add('select * from yhqxb where id=:s1');
form1.ADOQuery2.Parameters.ParamByName('s1').Value:=s;
form1.ADOQuery2.Open;
user:=form1.ADOQuery2.FieldValues['xm'];
form1.ADOQuery1.Close;
form1.ADOQuery1.SQL.Clear;
form1.ADOQuery1.SQL.Add('select bgmc,jlbh,fjr,fjsj from xx where sjr=:s1 and zt=:s2');
form1.ADOQuery1.Parameters.ParamByName('s1').Value:=user;
form1.ADOQuery1.Parameters.ParamByName('s2').Value:='未读';
form1.ADOQuery1.Open;
form1.ADOQuery1.FieldByName('bgmc').DisplayLabel:='表格名称';
form1.ADOQuery1.FieldByName('jlbh').DisplayLabel:='记录编号';
form1.ADOQuery1.FieldByName('fjr').DisplayLabel:='发件人';
form1.ADOQuery1.FieldByName('fjsj').DisplayLabel:='发件时间';
if form1.ADOQuery1.RecordCount>0 then
begin
form1.DataSource1.DataSet:=form1.ADOQuery1;
showwindow(form1.Handle,sw_restore);
form1.Timer1.Enabled:=false;
end;
end;
end;procedure TForm1.FormShow(Sender: TObject);
var
path:string;
tf:TINIFile;
user:string;
begin
path:=extractfilepath(application.ExeName);
tf:=TINIFile.Create(path+'id.ini');
with tf do
begin
user:=readstring('user','user','user');
free;
end;
if user='user' then
begin
messagebox(form2.Handle,'该程序是第一次运行,请先输入你的用户名','信息',mb_ok or mb_iconinformation);
form2.ShowModal;
end
end;procedure TForm1.Button1Click(Sender: TObject);
begin
showwindow(form1.Handle,SW_HIDE);
form1.Timer1.Enabled:=true;
end;procedure TForm1.FormCreate(Sender: TObject);
var
scaled:boolean;
oldformwidth:integer;
nid:TNotifyIconData;
newhintfont:tfont;
begin
Scaled:=TRUE;
if(Screen.width <> ScreenWidth)then
begin
OldFormWidth:=Width;
Height:=longint(Height)*longint(Screen.Height)DIV ScreenHeight;
Width:=longint(Width)*longint(Screen.Width)DIV ScreenWidth;
ScaleBy(Screen.Width,ScreenWidth);
Font.Size:=(Width DIV OldFormWidth)*Font.Size;
end;
nid.cbSize:=sizeof(nid); // nid变量的字节数
nid.Wnd:=Handle; // 主窗口句柄
nid.uID:=1; // 内部标识,可设为任意数
nid.hIcon:=Application.Icon.Handle; // 要加入的图标句柄,可任意指?
nid.hIcon:=Application.Icon.Handle; // 要加入的图标句柄,可任意指?
nid.szTip:='表格管理过程控制信息监控'; // 提示字符串
nid.uCallbackMessage:=MY_MESSAGE; // 回调函数消息
nid.uFlags:=NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有?
if not Shell_NotifyIcon(NIM_ADD,@nid) then
begin
ShowMessage('Failed!');
Application.Terminate;
end;
{将程序的窗口样式设为TOOL窗口,可避免在任务条上出现}
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
application.HintColor:=clred;
application.HintHidePause:=5000;
application.HintPause:=0;
application.HintShortPause:=100;
newhintfont:=tfont.Create;
newhintfont.Name:='楷体-GB2312';
newhintfont.Color:=clwhite;
newhintfont.Size:=10;
form1.Timer1.Enabled:=false;
form1.Timer2.Enabled:=false;
end;procedure TForm1.Timer2Timer(Sender: TObject);
var
path:string;
tf:TINIFile;
user:string;
s:string;
begin
path:=extractfilepath(application.ExeName);
tf:=TINIFile.Create(path+'id.ini');
with tf do
begin
s:=readstring('user','user','user');
free;
end;
if s<>'user' then
begin
form1.ADOQuery2.Close;
form1.ADOQuery2.SQL.Clear;
form1.ADOQuery2.SQL.Add('select * from yhqxb where id=:s1');
form1.ADOQuery2.Parameters.ParamByName('s1').Value:=s;
form1.ADOQuery2.Open;
user:=form1.ADOQuery2.FieldValues['xm'];
form3.ADOQuery1.Close;
form3.ADOQuery1.SQL.Clear;
form3.ADOQuery1.SQL.Add('select bgmc,jlbh,fjsj,sjr from xx where fjr=:s1 and zt=:s2 and fjsj<=:s3');
form3.ADOQuery1.Parameters.ParamByName('s1').Value:=user;
form3.ADOQuery1.Parameters.ParamByName('s2').Value:='未读';
form3.ADOQuery1.Parameters.ParamByName('s3').Value:=now-3;
form3.ADOQuery1.Open;
if form3.ADOQuery1.RecordCount>0 then
begin
form3.Show;
form1.Timer2.Enabled:=false;
end;
end;
end;end.
Nid.wnd := handle;
Nid.uID := 1; //Icon 标示
Nid.uCallBackMessage := Wm_TrayIconMessage;
Nid.hIcon := IconImage.Picture.Icon.handle;
Nid.szTip := '..........;
Nid.uFlags := Nif_Message Or Nif_Icon;
Shell_NotifyIcon(NIM_ADD, @Nid);
begin
form4.show;
end;
就是双击任务栏中的图标弹出表单