不设FormStyle=fsStayOnTop
如何实现?

解决方案 »

  1.   

    不设FormStyle=fsStayOnTop?为什么要有这样的要求???
      

  2.   

    有个API ,应该是SetWindowPosition().
      

  3.   

    用API函数可以
    先找到这个窗口,然后:
    BOOL SetWindowPos(          
        HWND hWnd,
        HWND hWndInsertAfter,
        int X,
        int Y,
        int cx,
        int cy,
        UINT uFlags
    );参数
    HWND hWndInsertAfter可以是:HWND_BOTTOM,HWND_NOTOPMOST,HWND_TOP,HWND_TOPMOST
    你可以选用TOP或者TOPMOST。
      

  4.   

    不需要显示在最前面的时候在程序中执行:
        form1.formstyle := fsNormal;
    需要时:FormStyle=fsStayOnTop
      

  5.   

    一旦设置了formstyle,在调用Shell_NotifyIcon时,失败
      

  6.   

    Public  procedure Createparams(Var Params:TCreateParams);override;... procedure TFormDrop.Createparams(var Params:TCreateParams);begin  Inherited CreateParams(Params);  With Params do  begin  EXStyle:=ExStyle or WS_EX_TOPMOST or WS_DLGFRAME  wndParnet:=GetDesktopWindow; //关键一行,用SetParent都不行!!  end;end;
      

  7.   

    function SetSysFocus(hwnd: THandle): integer;
    var
      hOtherWin,OtherTHreadID,hFocusWin:integer;
    begin
      hOtherWin:=GetForegroundWindow;
      OtherThreadID:=GetWindowThreadProcessID(hOtherWin,nil);
      if AttachThreadInput(GetcurrentThreadID,OtherThreadID,True) then
      begin
        hFocusWin:=GetFocus;
        windows.SetFocus(hwnd);
        //SendMessage(hwnd,WM_COPY,0,0);
        if hFocusWin<>0 then
        try
          //SendMessage(GetFocus,WM_COPY,0,0);
        finally
          AttachThreadInput(GetCurrentTHreadID,OtherTHreadID,False);
        end;
      end
      else result:=Windows.SetFocus(hwnd);
    end;这样调用SetSysFocus(Form1.Handle);
      

  8.   

    使你的窗体保留在桌面的最上面
    当我们想让一个窗体保留在桌面的最上面时,可以定义窗体的FormStyle属性,使窗体保持在最上面。但是,使用这种方法后,在切换窗体的模式时,窗体将闪烁。为了避免切换窗体模式时的闪烁,可以使用Windows API函数SetWindowPos来解决这一问题,使用方法如下:
    SetWindowPos(Form1.handle, HWND_TOPMOST, Form1.Left, Form1.Top, Form1.Width, Form1.Height,0);
    用实际窗体名称代替"Form1",调用这个命令就可以将窗体设置为保留在桌面的最上面。如要将窗体切换回正常的窗体,调用下面的命令:
    SetWindowPos(Form1.handle, HWND_NOTOPMOST, Form1.Left, Form1.Top, Form1.Width, Form1.Height,0);
      我在桌面中用程序改变了墙纸,但需点击右键刷新才可实现.我添加了button在其中加
    sendmessage(),无效不能改变.请教如何实现?
    varhDesktop: HWND;beginhDesktop := FindWindowEx(FindWindowEx(FindWindow('Progman', 'Program Manager'), 0,'SHELLDLL_DefView', ''), 0, 'SysListView32', '');PostMessage(hDesktop, WM_KEYDOWN, VK_F5, 0);PostMessage(hDesktop, WM_KEYUP, VK_F5, 1 shl 31);end;SendMessage(FindWindow('Progman', 'Program Manager'), WM_COMMAND, $A065, 0);