大家都知道,在windows系统中,有个“显示桌面”快捷按钮,只要一点上去,桌面上的所有窗口都会被最小化。问题:怎么样可以让我程序的主窗口忽略“显示桌面”的响应!我也试过去忽略系统相关消息的方法,但是好象不行。请大家指教……

解决方案 »

  1.   

    当你的程序运行的时候,你可以试一下最小化真的是不行。快捷键是vytl 与 alt中间键+M你试一下。
      

  2.   

    sankis
    你说的是什么意思?我不大理解!
    ctrl + alt + m 看快捷方式属性,刚知道,谢谢了,又学了一招!
      

  3.   

    我晕了。
    我是说ctrl 与 alt 中间的那个按键,
    我不知道叫什么+M
      

  4.   

    捕获最小化消息,忽略
    A window receives this message when the user chooses a command from the window menu (also known as the System menu or Control menu) or when the user chooses the Maximize button or Minimize button.WM_SYSCOMMAND  
    uCmdType = wParam;        // type of system command requested 
    xPos = LOWORD(lParam);    // horizontal postion, in screen coordinates 
    yPos = HIWORD(lParam);    // vertical postion, in screen coordinates 
     ParametersuCmdTypeSpecifies the type of system command requested. This can be one of these values:Value Meaning
    SC_CLOSE Closes the window.
    SC_CONTEXTHELP Changes the cursor to a question  with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message.
    SC_DEFAULT Selects the default item; the user double-clicked the window menu.
    SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate.
    SC_HSCROLL Scrolls horizontally.
    SC_KEYMENU Retrieves the window menu as a result of a keystroke.
    SC_MAXIMIZE (or SC_ZOOM) Maximizes the window.
    SC_MINIMIZE (or SC_ICON) Minimizes the window.
    SC_MONITORPOWER Windows 95 only: Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.
    SC_MOUSEMENU Retrieves the window menu as a result of a mouse click.
    SC_MOVE Moves the window.
    SC_NEXTWINDOW Moves to the next window.
    SC_PREVWINDOW Moves to the previous window.
    SC_RESTORE Restores the window to its normal position and size.
    SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file.
    SC_SIZE Sizes the window.
    SC_TASKLIST Executes or activates Windows Task Manager.
    SC_VSCROLL Scrolls vertically.
     xPosSpecifies the horizontal position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. Otherwise, the xPos parameter is not used.yPosSpecifies the vertical position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. This parameter is -1 if the command is chosen using a system accelerator, or zero if using a mnenomic. Return ValuesAn application should return zero if it processes this message.ResThe DefWindowProc function carries out the window menu request for the predefined actions specified in the previous table. 
    In WM_SYSCOMMAND messages, the four low-order bits of the uCmdType parameter are used internally by Windows. To obtain the correct result when testing the value of uCmdType, an application must combine the value 0xFFF0 with the uCmdType value by using the bitwise AND operator. 
    The menu items in a window menu can be modified by using the GetSystemMenu, AppendMenu, InsertMenu, ModifyMenu, InsertMenuItem, and SetMenuItem functions. Applications that modify the window menu must process WM_SYSCOMMAND messages.An application can carry out any system command at any time by passing a WM_SYSCOMMAND message to DefWindowProc. Any WM_SYSCOMMAND messages not handled by the application must be passed to DefWindowProc. Any command values added by an application must be processed by the application and cannot be passed to DefWindowProc. 
    Accelerator keys that are defined to choose items from the window menu are translated into WM_SYSCOMMAND messages; all other accelerator keystrokes are translated into WM_COMMAND messages. See AlsoAppendMenu, DefWindowProc, GetSystemMenu, InsertMenu, ModifyMenu, WM_COMMAND
      

  5.   

    sankis
    呵呵!是我理解错了,sorry
      

  6.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      with Application do
        SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) and
          not WS_EX_APPWINDOW or WS_EX_TOOLWINDOW);
      SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
    end;
      

  7.   

    fei19790920(饭桶的马甲(抵制日货)) oh ye谢谢你啦!太感谢了!是不是只要给它SWP_NOMOVE or SWP_NOSIZE属性就可以了呢???
      

  8.   

    你理解错误了
      with Application do
        SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) and
          not WS_EX_APPWINDOW or WS_EX_TOOLWINDOW);//不显示在任务栏上
    SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
    //设置为最顶层窗口
      

  9.   

    SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE)只要加这句话就OK了!
      

  10.   

    fei19790920(饭桶的马甲(抵制日货)) 高手!果然是高手!谢谢你!
      

  11.   

    设置HWND_TOPMOST有一个问题,我的窗口就会在其他所有非顶端窗口的前面,没发让其他非顶端窗口显示在它前面。有没有不设为TOPMOST而又可以屏蔽“显示桌面”的方法呢?
      

  12.   

    不知道怎么想的...又是怎么做的
      TForm1 = class(TForm)
      protected
        procedure CreateParams(var Params: TCreateParams); override;
      end;procedure TForm1.CreateParams(var Params: TCreateParams);
    begin
      inherited;
      Params.WndParent  :=  FindWindow('Shell_TrayWnd',nil);
    end;别问我为什么,自己想
      

  13.   

    我觉得
    Params.WndParent  :=  FindWindow('Shell_TrayWnd',nil);
    实质还是将窗口设置成顶层窗口我测试下来结果一样,“显示桌面”可以忽略,但是其他窗口仍旧无法显示在其前面!
      

  14.   

    非常感谢 ysai(蓝色忧郁)恩!照你的样子确实可以了,但是这样的话就影响任务栏的使用了!但是在我现在的这个应用中是这样的一个窗口:
    1、最大化
    2、没有标题栏
    3、忽略“显示桌面”
    4、最好在其他所有窗口的底层,不能是顶层窗口
    5、不影响任务栏的显示
    我总结一下,就好象是一个类似虚拟桌面的窗口。我现在在尝试钩子,现在还在实验(我会把我所遇到的和所学到的都公布出来,可以方便更多的人:p)
      

  15.   

    Params.WndParent  :=  FindWindow('Progman',nil);
      

  16.   

    如果你真想截消息,建议用SPY++看看再说
    可是,据我所知,显示桌面并不会给窗口发什么消息......
      

  17.   

    Params.WndParent  :=  FindWindow('Progman',nil);
    好了!谢谢你了!我用SPY++看过了!消息是有的,只有两个……不过现在好了!对了!
    ysai(蓝色忧郁) 
    你能不能稍微给我讲讲关于Shell_TrayWnd和Progman两个窗口的啊?关于Windows shell我不是很熟悉,我是要去买几本shell的书看看了!
      

  18.   

    这两个东东是:(格式 WindowText - ClassName 句柄)
    //任务栏
    (空) - Shell_TrayWnd (196672)
    ├开始 - Button (196676)
    ├(空) - TrayNotifyWnd (262188)
    │├16:49 - TrayClockWClass (196680)
    │├(空) - SysPager (196682)
    ││└通知区域 - ToolbarWindow32 (196684)
    │└(空) - Button (196686)
    └(空) - ReBarWindow32 (65686)
     ├运行应用程序 - MSTaskSwWClass (65692)
     │└运行应用程序 - ToolbarWindow32 (65696)
     └Quick Launch - ToolbarWindow32 (65690)//桌面(就是你要显示的东东)
    Program Manager - Progman (65702)
    └(空) - SHELLDLL_DefView (65704)
     └FolderView - SysListView32 (65706)
      

  19.   

    现在我在用vc实现,但是vc好象比Delphi的要复杂点,情况是这样的:
    Delphi一切正常,但是在vc里很奇怪,我就加了一下这句话::SetParent(m_hWnd, ::FindWindow("Progman", NULL));忽略“显示桌面”可以,但是下面任务栏中没有显示,而且窗口总是在最底层!我现在还在研究!(我用的是对话框工程)
      

  20.   

    ysai(蓝色忧郁)::SetParent(m_hWnd, ::FindWindow("Progman", NULL));
    这我在OnCreate里加上这句话可以么?为什么delphi可以,vc里却上面的问题呢?你有何意见?
      

  21.   

    偶不懂VC,所以...
    可能与你建立的Window是对话框有关