Z
zitai
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟在主控程序中调用了一个窗口A(动态库文件),当调用其他窗口后(未释放窗口A的dll),窗口失去了焦点,<br>但是我已经记录了该窗口的handle ,再调用窗口A时只想将将它从后台移到前台就可以了。但是bringwindowtotop,<br>setwindowpos,showwindow全部没法实现目的。不知该怎么办!!!<br><br>下面是其中的代码:<br>{<br>funname ----------------功能名称<br>filename ---------------文件名称<br>type TDllArray=array [0..9] of Record<br> Winhand:Thandle;<br> funcname:string;<br> filename:string;<br> end;<br>dllarray:TDllArray;<br>}<br><br>procedure ExcuteFunc(FuncName,filename:string;param:shortstring);<br>var<br>MKfound:Boolean; //-------------模块发现标志<br>GNfound:Boolean; //-------------功能发现标志<br>Foundindex:integer; //----------发现位置<br>index:integer; //循环变量<br>minnull:integer; //-----------最小空位置<br>begin<br>minnull:=10;<br>foundindex:=0;<br>MkFound:=False;<br>GnFound:=False;<br>for index:=0 to 9 do<br>begin<br> if dllarray[index].Winhand <> 0 then<br> begin<br> if dllarray[index].filename = filename then<br> begin<br> foundindex:=index;<br> MKfound:=True;<br> end;<br> if (dllarray[index].filename = filename) and (dllarray[index].funcname = funcname) then<br> begin<br> foundindex:=index;<br> Gnfound:=True;<br> end;<br> end<br> else<br> begin<br> if minnull> index then<br> minnull:=index;<br> end;<br>end;<br>if minnull =10 then<br> begin<br> application.MessageBox('请关闭掉一些窗口','出错信息!',MB_OK);<br> exit<br> end;<br>if NOT MKFOUND and (minnull < 10 ) THEN<br>begin<br> DllHandle:=loadlibrary(pchar(filename));<br> if DllHandle<>0 then<br> try<br> @DllMain:=getprocaddress(DllHandle,'ModMain');<br> if @DllMain<>nil then<br> begin<br> DllMain(operation,Frame.handle,pchar('NJ_SCGDB'),pchar('userid'),pchar('userid'),param);<br> end<br> else<br> application.MessageBox('没有对应的函数','程序出错!',MB_OK);<br> except<br> freelibrary(Dllhandle);<br> operation:=0;<br> end<br> else<br> application.messagebox('没有找到对应的DLL','出错信息',MB_OK);<br> dllarray[minnull].Winhand :=dllhandle;<br> dllarray[minnull].funcname :=funcname;<br> dllarray[minnull].filename :=filename;<br>end;<br>if MkFOUND AND not GNFOUND and (minnull <10 )then<br>begin<br> try<br> @DllMain:=getprocaddress(DllArray[foundindex].Winhand,'ModMain');<br> if @DllMain<>nil then<br> DllMain(operation,Frame.handle,pchar('NJ_SCGDB'),pchar('userid'),pchar('userid'),param)<br> else<br> application.MessageBox('没有对应的函数','程序出错!',MB_OK);<br> except<br> freelibrary(Dllhandle);<br> end;<br> dllarray[minnull].Winhand :=dllarray[foundindex].Winhand ;<br> dllarray[minnull].funcname :=funcname;<br> dllarray[minnull].filename :=filename;<br>end;<br>if GnFound then <br> begin<br> bringwindowtotop(dllarray[foundindex].winhand);//问题出现的位置<br> setwindowpos(dllarray[foundindex].winhand,HWND_TOP,1,1,400,600,SWP_DRAWFRAME);<br> setactivewindow(dllarray[foundindex].winhand);<br>// showwindow(dllarray[foundindex].winhand,SW_SHOWNORMAL);<br> end;<br> // clinttoscreen();<br>end;<br>