请问怎样才能将任务栏中的“总在最前”属性框中的勾去掉,求delphi的代码
我也看了csdn上许多大侠的代码,要去不要隐藏工具栏,
其实我的原本的问题很简单,就是想编一个程序让它最大化,但是最大化的程序总是在底部仍然露出任务栏,但若隐藏任务栏的话,该程序的底部还是露出一条边,所以我就想修改任务栏的“总在最前”属性。

解决方案 »

  1.   


    uses ShellApi;procedure TForm1.Button1Click(Sender: TObject);
    var 
      abd: TAppBarData;
      i: integer;
    begin
      abd.cbSize := SizeOf(abd);
      i := SHAppBarMessage(ABM_GETSTATE, abd);
      ShowMessage(IntToStr(i));
    { Notes:
      0 表示 "最上層顯示" 未勾選,"自動隱藏" 未勾選
      1 表示 "最上層顯示" 未勾選,"自動隱藏" 有勾選
      2 表示 "最上層顯示" 有勾選,"自動隱藏" 未勾選
      3 表示 "最上層顯示" 有勾選,"自動隱藏" 有勾選
    }
    end;雖然 MSDN 的文件中有列出 ABM_SETSTATE 這項常數,但卻無法使用它來改變"最上層顯示"以及"自動隱藏"的屬性(在 Delphi 附的 ShellApi.pas 裡面也找不到此常數),以下說明取自 MSDN:Taskbar Display Options
    The taskbar supports two display options: Auto Hide and Always On Top. To set these options, the user must open the taskbar shortcut menu, click Properties, and select or clear the Auto Hide check box or the Always On Top check box. There is no way to set these options programmatically. To retrieve the state of these display options, use the ABM_GETSTATE message. If you would like to be notified when the state of these display options changes, process the ABN_STATECHANGE notification message in your window procedure. To change the state of these display options, use the ABM_SETSTATE message.
    上面提到的兩個工作列的屬性也可以在 Registry 裡面找到,位置是
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects,在 Settings 二進位值的第三個 DWORD,如果 "最上層顯示" 為 True 且 "自動隱藏" 為 True,則其值為 00 00 00 03(在 regedit 中看到的是 03 00 00 00)。但你無法透過修改這個數值來改變工作列的狀態,因為 Explorer 會一直去寫入這個機碼以確保其值和目前的設定是相同的。工作列的視窗類別名稱是 Shell_TrayWnd(你可以利用 Delphi 所附的 WinSight32 找到工作列的視窗類別),你可以利用此類別名稱取得工作列的視窗 Handle,再利用其 Handle 取得或改變視窗的相關資訊,例如,以下的程式片段可以將工具列隱藏起來:var
      hTaskBar: HWND;
    begin
      hTaskBar := FindWindow('Shell_TrayWnd', nil);
      if (hTaskBar <> 0) then
        ShowWindow(hTaskBar, SW_HIDE);
    end;註:工具列雖然被隱藏起來,但是工具列所佔據的空間仍無法為其他視窗所用。
      

  2.   

    设置任务栏自动隐藏的api函数是什么啊 
    主要解答者: aiirii 提交人: aiirii 
    感谢: aiirii 
    审核者: ihihonline 社区对应贴子: 查看 
         A :  设置任务栏自动隐藏的api函数是什么啊  
    ---------------------------------------------------------------  
     
    自动隐藏  與  隐藏  是不同的概念啊  
    ---------------------------------------------------------------  
     
    procedure  TaskbarAutoHide;  
    var  
       Shell_TrayWnd:  HWND;  
       P_Wnd:  HWND;  
       R:  TRect;  
       iCount:  integer;  
    begin  
       Shell_TrayWnd  :=  FindWindow('Shell_TrayWnd',  nil);  
       SetForegroundWindow(Shell_TrayWnd);  
       GetWindowRect(Shell_TrayWnd,  r);  
       setcursorpos(r.Right  -  1,  r.Bottom  -  1);  
       Mouse_Event(MOUSEEVENTF_RIGHTDOWN,  r.Right  -  1,  r.Bottom  -  1,  0,  0);  
       Mouse_Event(MOUSEEVENTF_RIGHTUP,  r.Right  -  1,  r.Bottom  -  1,  0,  0);  
     
       keybd_event(ord('R'),  0,  KEYEVENTF_EXTENDEDKEY,  0);  //KEYDOWN£?  
       keybd_event(ord('R'),  0,  KEYEVENTF_EXTENDEDKEY  or  KEYEVENTF_KEYUP,  0);  
       //KEYUP  
     
       P_Wnd  :=  0;  
       iCount  :=  0;  
       while  P_Wnd  =  0  do  
       begin  
           P_Wnd  :=  FindWindow('#32770',  nil);  //  '工作列及開始功能表  內容');  
           Sleep(10);  
           Inc(iCount);  
           if  iCount  >  65535  then  Exit;  
       end;  
       SetWindowPos(P_Wnd,  HWND_TOP,  0,  0,  1,  1,  SWP_NOMOVE);  
       Application.ProcessMessages;  
       keybd_event(ord('U'),  0,  KEYEVENTF_EXTENDEDKEY,  0);  //KEYDOWN£?  
       keybd_event(ord('U'),  0,  KEYEVENTF_EXTENDEDKEY  or  KEYEVENTF_KEYUP,  0);  
       //KEYUP  
           //    {  Under  WinXP:1102:Control  ID  of  'Auto  Hide'  }  
           //    CheckDlgButton(FindWindowEx(P_Wnd,0,'SysTabControl32',nil),  1102,  BST_CHECKED);  
     
       PostMessage(P_Wnd,  WM_KEYDOWN,  VK_RETURN,  0);  
       PostMessage(P_Wnd,  WM_KEYUP,  VK_RETURN,  0);  
    end;  ////这么赖皮 ^o^
     -----------------------把上面最后的 ord('U') 换成 ord('T')就可以了
      

  3.   


    tnnd,好辛苦終于搞定
    <<<<<<<<<<<<<<<<<<<<<<<<
    The taskbar supports two display options: Auto Hide and Always On Top. To set these options, the user must open the taskbar shortcut menu, click Properties, and select or clear the Auto Hide check box or the Always On Top check box. There is no way to set these options programmatically.
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    即使不能程序改變Always On Top check box的狀態. 還有如下方法!!!
    procedure TForm1.SetTopMost(TopMost: Boolean);
    const
      WndPosArray: array[Boolean] of HWND = (HWND_BOTTOM, HWND_TOPMOST);
    var
      hTaskBar: HWND;
    begin
      hTaskBar := FindWindow('Shell_TrayWnd', nil);
      SetWindowPos(hTaskBar, WndPosArray[TopMost], 0, 0, 0, 0, SWP_NOMOVE or
        SWP_NOSIZE or SWP_NOACTIVATE);
    end;procedure TForm1.BitBtn10Click(Sender: TObject);
    begin
    SetTopMost(false);
    end;<<<<<<<<<<<<<<<<<<<<<<<<
      

  4.   

    jinjazz你的方法挺好的,但是怎么只能打开那个窗口,不能自动设置吗?
    难道要我手动的设置吗?不会吧!!?要是能实现点击“确定”按钮就好了。JonnySun,你的也不错,但是好像跑题了,我要的效果是在全屏的时候能够最大化的将工具栏也遮住呀,可是你的程序只能遮住工具栏的一块??
    大家在想想??
      

  5.   

    procedure  TaskbarAutoHide;
    var
       Shell_TrayWnd:  HWND;
       P_Wnd:  HWND;
       R:  TRect;
       iCount:  integer;
    begin
       Shell_TrayWnd  :=  FindWindow('Shell_TrayWnd',  nil);
       SetForegroundWindow(Shell_TrayWnd);
       GetWindowRect(Shell_TrayWnd,  r);
       setcursorpos(r.Right  -  1,  r.Bottom  -  1);
       Mouse_Event(MOUSEEVENTF_RIGHTDOWN,  r.Right  -  1,  r.Bottom  -  1,  0,  0);
       Mouse_Event(MOUSEEVENTF_RIGHTUP,  r.Right  -  1,  r.Bottom  -  1,  0,  0);   keybd_event(ord('R'),  0,  KEYEVENTF_EXTENDEDKEY,  0);  //KEYDOWN£?
       keybd_event(ord('R'),  0,  KEYEVENTF_EXTENDEDKEY  or  KEYEVENTF_KEYUP,  0);
       //KEYUP   P_Wnd  :=  0;
       iCount  :=  0;
       while  P_Wnd  =  0  do
       begin
           P_Wnd  :=  FindWindow('#32770',  nil);  //  '工作列及開始功能表  內容');
           Sleep(10);  
           Inc(iCount);
           if  iCount  >  65535  then  Exit;
       end;
       SetWindowPos(P_Wnd,  HWND_TOP,  0,  0,  1,  1,  SWP_NOMOVE);  
       Application.ProcessMessages;
       keybd_event(ord('U'),  0,  KEYEVENTF_EXTENDEDKEY,  0);  //KEYDOWN£?
       keybd_event(ord('U'),  0,  KEYEVENTF_EXTENDEDKEY  or  KEYEVENTF_KEYUP,  0);
       //KEYUP
           //    {  Under  WinXP:1102:Control  ID  of  'Auto  Hide'  }
           //    CheckDlgButton(FindWindowEx(P_Wnd,0,'SysTabControl32',nil),  1102,  BST_CHECKED);
       keybd_event(VK_RETURN,  0,  KEYEVENTF_EXTENDEDKEY,  0);  //KEYDOWN£?
       keybd_event(VK_RETURN,  0,  KEYEVENTF_EXTENDEDKEY  or  KEYEVENTF_KEYUP,  0);
      // PostMessage(P_Wnd,  WM_KEYDOWN,  VK_RETURN,  0);
      // PostMessage(P_Wnd,  WM_KEYUP,  VK_RETURN,  0);
      

  6.   

    jinjazz(近身剪(N-P攻略)) 
    晕..完全模拟人工操作哦.呵呵