返回列表 发帖

[原创]记事本定时保存器

[这个贴子最后由chinanic在 2006/10/16 02:14am 第 1 次编辑]

delphi?
强!
原理见这页。
http://www.thysea.com/lb/cgi-bin/topic.cgi?forum=127&topic=1999
另外,我在做此类程序的时候发现一个问题。例如,如果打开一个空记事本,在没有输入任何文字的情况下,“编辑”菜单中的“查找”选项是灰色的不可用,但用模拟菜单输入的方法去执行,仍然可以奏效。
用模拟菜单输入的方法执行,是直接调用该过程,而在这个过程的头部并没有对启用该过程所需的条件进行校验,所以才可以执行。。[br][br]-=-=-=-=- 以下内容由 chinanic2006年10月16日 02:20am 时添加 -=-=-=-=-
文章所有API函数可以在下面这个网址查询:
http://ebook.coolersky.com/base/win32api/web.htm
不过是FOR VB 的!
不好意思,偶只知道点VB!

TOP

[原创]记事本定时保存器

LBSALE[1]LBSALEunit Unit1; interface uses Windows,ShellAPI, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls, StdCtrls, Buttons, Menus; const WM_NID=WM_USER+1000; type TForm1 = class(TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; TabSheet2: TTabSheet; LabeledEdit1: TLabeledEdit; Label2: TLabel; Label1: TLabel; BitBtn1: TBitBtn; Label3: TLabel; TabSheet3: TTabSheet; L3: TLabel; DateTimePicker1: TDateTimePicker; L2: TLabel; Label4: TLabel; Label5: TLabel; Timer1: TTimer; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; procedure Timer1Timer(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure L3Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure N3Click(Sender: TObject); private procedure mwy(var Msg:TMessage);Message WM_NID;//过程声明。用于响应托盘单击或右击等事件。 { Private declarations } public { Public declarations } end; var Form1: TForm1; NotifyIcon:TNotifyIconData; implementation {$R *.dfm} procedure TForm1.mwy(var Msg:TMessage); var mouse:TPoint; begin if msg.LParam=WM_LBUTTONDOWN then Form1.Visible:=Not form1.Visible; if msg.LParam=WM_RBUTTONDOWN then begin GetCursorPos(mouse);//获取鼠标当前位置。 PopupMenu1.Popup(mouse.X,mouse.Y);//在这个位置上弹出右键菜单。 end; end; procedure TForm1.Timer1Timer(Sender: TObject); var h:HWND; m:HMENU; id:UINT; begin h:=FindWindow(';notepad';,0); if h=0 then exit; m:=GetSubMenu(GetMenu(h),0); id:=GetMenuItemID(m,2); SendMessage(h,WM_COMMAND,id,0); end; procedure TForm1.BitBtn1Click(Sender: TObject); begin if length(labelededit1.Text)=0 then begin form1.Hide; Messagebox(0,chr(13)+';你太笨了,竟然没有设置时间就执行!';,';失败:';,mb_ok+mb_iconerror); form1.Show; exit; end; if strtoint(trim(labeledEdit1.Text))<30 then begin form1.Hide; Messagebox(0,chr(13)+';你设置的时间太短,这样会导致CPU使用率过高。请重新设置!';,';失败:';,mb_ok+mb_iconerror); labelededit1.Clear; form1.Show; exit; end; if strtoint(trim(labeledEdit1.Text))>60000 then begin form1.Hide; if Messagebox(0,chr(13)+';你设置的时间太大,这样保存频率太低。';+chr(13)+';使你输入的内容不能立即得到保存。重新设置吗?';,';→无条件为你⊙制作,联系QQ335342';,mb_yesno+mb_iconinformation)=idyes then begin labelededit1.Clear; form1.Show; exit; end; end; if Bitbtn1.Caption=';执行(&E)'; then begin bitbtn1.Caption:=';取消(&E)';; LabeledEdit1.Enabled:=False; end else begin bitbtn1.Caption:=';执行(&E)';; Timer1.Enabled:=False; LabeledEdit1.Enabled:=True; exit; end; Shell_NotifyIcon(NIM_ADD,@NotifyIcon); Timer1.Enabled:=True; form1.Hide; end; procedure TForm1.FormCreate(Sender: TObject); begin with NotifyIcon do begin cbSize:=SizeOf(TNotifyIconData); Wnd:=Handle; uID:=19; uFlags:=NIF_ICON OR NIF_TIP OR NIF_MESSAGE; uCallBackMessage:=WM_NID; hIcon:=Application.Icon.Handle; szTip:=';单击显示或隐藏主窗体,右击获取更多功能……';; end; //不显示任务按扭: SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); DateTimePicker1.Date:=date;//设置当前日历! end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin //最终退出程序时删除托盘小图标。 NotifyIcon.cbSize:=SizeOf(TNotifyIconData); NotifyIcon.Wnd:=Handle; NotifyIcon.uID := 19; Shell_NotifyIcon(NIM_DELETE,@NotifyIcon); end; procedure TForm1.L3Click(Sender: TObject); begin form1.hide; if MessageBox(0,chr(13)+';太好了,我还一直担心你不会来呢!今天你快乐吗?';,';→无条件为你⊙程序设计!联系QQ:335342';,MB_YesNo+MB_ICONQUESTION)=IDYES then MessageBox(0,chr(13)+';快乐同在!加我QQ吧,很想认识远方的你!';,';联系QQ:335342';,mb_ok+mb_iconinformation) else MessageBox(0,chr(13)+';郁闷!外面阳光灿烂,为何不出去散散心呢?!';,';→无条件为你⊙制作,联系QQ:335342';,mb_ok+mb_iconstop); form1.Show; end; procedure TForm1.N1Click(Sender: TObject); begin form1.Show; end; procedure TForm1.N2Click(Sender: TObject); begin form1.Hide; end; procedure TForm1.N3Click(Sender: TObject); begin close; end; end. [br][br]-=-=-=-=- 以下内容由 无条件为你2006年10月15日 10:01pm 时添加 -=-=-=-=- 防止匆匆客人看贴,所以设置1元售贴。

TOP

返回列表 回复 发帖