Y
youou
Unregistered / Unconfirmed
GUEST, unregistred user!
因为搜索到贴子,你们已经实现了....希望能帮个忙...<br><br>======================<br>搜索了老半天,还是没搜索到:我使任务栏中的快速启动无效,但是>>后的一直有效,如何也使它无效呢?<br>var<br> wndHandle: THandle;<br>begin<br>wndHandle := FindWindow('Shell_TrayWnd', nil);<br>wndHandle := FindWindowEx(wndHandle,0,'RebarWindow32',nil);<br>wndHandle := FindWindowEx(wndHandle,0,'Toolbarwindow32',nil);<br><br>EnableWindow(wndHandle,CheckBox1.Checked);<br>end;<br>=========<br>这个代码不会快速启动中>>后的无效?怎么办?请大家帮帮忙....<br>这个该如何实现?是用到钩子吗?<br><br>===============<br><br>上面的我不会,所以又想到用代替的办法..屏bi后的右边有时会出现一小块,如果shu标点<br>击时感觉有点死机的现象,希望大家copy代码..试试吧..<br><br><br>unit ut_ToolBar;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> btnRestore: TButton;<br> btnNew: TButton;<br> procedure btnNewClick(Sender: TObject);<br> procedure btnRestoreClick(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> FNewButton : Boolean; // Check whether new start button had been created.<br> procedure NewButtonMsg (Var Msg : TMessage); // new button events.<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> OldProc, NewProc : Pointer;<br> ToolBarHwnd, TrayHwnd,ReBarHandle,ReplaceBtnHwnd : Hwnd;<br><br>implementation<br><br>{$R *.DFM}<br><br><br><br>procedure TForm1.btnNewClick(Sender: TObject);<br>var<br> Rct : TRect;<br> fnt : HFont;<br>begin<br> TrayHwnd := FindWindow('Shell_TrayWnd', nil);<br> ReBarHandle := FindWindowEx( TrayHwnd,0,'RebarWindow32',nil);<br> ToolBarHwnd := FindWindowEx(ReBarHandle,0,'ToolbarWindow32',nil);<br><br> // Create New Button to replace start button!<br> if FNewButton then Exit; // Don't create when new button had been created.<br><br> Windows.GetWindowRect(ToolBarHwnd,Rct); //获得开始按钮的矩形区域<br><br> ReplaceBtnHwnd := CreateWindowEx(WS_EX_WINDOWEDGE,<br> 'ToolbarWindow32','Toolbar',WS_Child or WS_Visible,<br> 0,0,rct.right - rct.left, Rct.bottom - Rct.top,<br> ReBarHandle,0,0,nil); // Create a button, which parent is windows's Tray.<br><br> if ReplaceBtnHwnd > 0 then<br> begin<br> // Hide old Start button. HWND_BOTTOM<br> SetWindowPos(ToolBarHwnd,HWND_BOTTOM,<br> Rct.left,rct.top,rct.right - rct.left, Rct.bottom - Rct.top,<br> SWP_HIDEWINDOW {OR SWP_NOREDRAW});<br><br> // Set New button's font and caption.<br> SetWindowText(ReplaceBtnHwnd, 'Start');<br><br> fnt := CreateFont(0,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,0,0,0,0,'Time New Romans');<br> SendMessage(ReplaceBtnHwnd, WM_SETFONT,fnt,MAKELPARAM(0,0));<br> // Show New start button.<br> SetWindowPos(ReplaceBtnHwnd,HWND_TOPMOST,<br> Rct.left,rct.top,rct.right - rct.left, Rct.bottom - Rct.top,<br> SWP_NOACTIVATE); //SWP_SHOWWINDOW<br><br> ShowWindow(ReplaceBtnHwnd,SW_ShowNormal);<br><br><br> UpdateWindow(ReplaceBtnHwnd);<br><br> // To handle the new messages.<br> NewProc := Pointer(LongInt(MakeObjectInstance(NewButtonMsg)));<br><br> OldProc := Pointer(SetWindowLong(ReplaceBtnHwnd,GWL_WNDPROC,LongInt(NewProc)));<br><br> if NewProc = nil then<br> begin<br> Showmessage('Can not grab new button''s message!');<br> Exit;<br> end;<br> FNewButton := True;<br> end;<br><br>end;<br><br>procedure TForm1.btnRestoreClick(Sender: TObject);<br>var<br> Rct: TRect;<br>begin<br> if FNewButton then // Restore Old Start button.<br> begin<br> Windows.GetWindowRect(ToolBarHwnd,Rct); //获得开始按钮的矩形区域<br> SetWindowLong(ToolBarHwnd,GWL_WNDPROC,LongInt(OldProc));<br> DestroyWindow(ReplaceBtnHwnd);<br> ReplaceBtnHwnd := 0;<br> ShowWindow(ToolBarHwnd,SW_ShowNormal);<br> SetWindowPos(ToolBarHwnd,HWND_TOPMOST,0,0,Rct.Right - Rct.Left,Rct.Bottom - Rct.Top,SWP_SHOWWINDOW);<br> FNewButton := False;<br> end;<br>end;<br><br>procedure TForm1.NewButtonMsg(var Msg: TMessage);<br>begin<br> if Msg.Msg = WM_LBUTTONUP then<br> exit<br><br> else<br> Msg.Result := CallWindowProc(OldProc,ReplaceBtnHwnd,Msg.msg, msg.wParam, msg.lParam);<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> if FNewButton then<br> btnRestoreClick(self); //Restore button when form exiting.<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> btnNewClick(Sender);<br>end;<br><br>end.<br>