SetWindowPos如何设置参数,使效果和showmodal一样(20分)

先自己看看吧:<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=439953
 
我在窗口1CreateParams中写了如下代码<br>inherited;<br>with Params do<br>begin<br>&nbsp; &nbsp; Style := Params.Style xor WS_DLGFRAME;<br>&nbsp; &nbsp; WndParent := 0;<br>end;<br>可是我用showmodal打开另一个窗口, 窗口1就无法拖动了,怎么办:(<br>
 
这个问题没有人知道吗?
 
老兄真顽固。<br>已经说了, 如果用showmodal的话,当前进程下(注意是进程,也就是Application下)除了被showmodal显示出来的这个窗口外所有其它窗口都已经disable掉了。<br>所以要实现你的目标只有我说的两种方法:<br>1、用另一个进程运行那个悬浮窗(简单说悬浮窗是另外一个exe程序)<br>或者<br>2、不调用TForm.ShowModal显示窗口而手工实现ShowModal中的方法, 即先disable掉你所不希望被操作的窗口, 然后用Show显示出对话窗口(这时悬浮窗因为没有被disable掉所以还能移动),在对话窗退出前先Enable先前disable掉的窗口再关闭。<br>
 
很显然netants不是用你说的第一种方式来做到这种效果。<br>至于你说的第2种,我要看看。<br>
 
试了半天没有效果,有哪位高手给点实际的代码。
 
好吧,一个简单的例子: 说明: MyShowModal中的FloatWindow就是你的浮动窗<br>type<br>&nbsp; TIntArr = array of HWND;<br>&nbsp; PIntArr = ^TIntArr;<br><br>function DoDisableWindow(Window: HWnd; Data: Longint): Bool; stdcall;<br>var<br>&nbsp; p: PIntArr;<br>&nbsp; l: Integer;<br>begin<br>&nbsp; p := Pointer(data);<br>&nbsp; l := high(p^)+1;<br>&nbsp; if IsWindowVisible(Window) and IsWindowEnabled(Window) then<br>&nbsp; begin<br>&nbsp; &nbsp; setlength(p^, l+1);<br>&nbsp; &nbsp; p^[l] := Window;<br>&nbsp; &nbsp; EnableWindow(Window, False);<br>&nbsp; end;<br>&nbsp; result := True;<br>end;<br><br>function TFormXXX.MyShowModal: Integer;<br>var<br>&nbsp; actwnd: HWND;<br>&nbsp; Lst: TIntArr;<br>&nbsp; i: Integer;<br>begin<br>&nbsp; actwnd := getactivewindow;<br>&nbsp; enumthreadwindows(GetCurrentThreadId, @DoDisableWindow, Integer(@Lst));<br>&nbsp; if handleallocated then<br>&nbsp; &nbsp; enablewindow(handle, true);<br>&nbsp; if FloatWindow.handleallocated then<br>&nbsp; &nbsp; enablewindow(FloatWindow.Handle, True);<br>&nbsp; try<br>&nbsp; &nbsp; result := 0;<br>&nbsp; &nbsp; showwindow(handle, SW_SHOW);<br>&nbsp; &nbsp; setactivewindow(handle);<br>&nbsp; &nbsp; repeat<br>&nbsp; &nbsp; &nbsp; application.HandleMessage;<br>&nbsp; &nbsp; &nbsp; if Application.Terminated then Result := mrCancel;<br>&nbsp; &nbsp; until result&lt;&gt;0;<br>&nbsp; finally<br>&nbsp; &nbsp; for i := 0 to high(lst) do<br>&nbsp; &nbsp; &nbsp; if IsWindow(lst) then<br>&nbsp; &nbsp; &nbsp; &nbsp; EnableWindow(lst, True);<br>&nbsp; &nbsp; setlength(lst, 0);<br>&nbsp; &nbsp; setactivewindow(actwnd);<br>&nbsp; end;<br>end;<br>
 
Another_eYes:<br>非常感谢,我有点明白了,试了一下,确实是我需要的效果。<br>看来我还要搞清楚这些函数的使用。
 
总算解决了这个问题!!!
 
这种处理的思想很好,但具体处理方法有问题,可以改进一下。
 
顶部