<br>function fun_GetImageSize: TImageSize;<br>var<br> ISH: THandle;<br> CancelHandle: THandle;<br> WidthHandle : THandle;<br> HeightHandle: THandle;<br> TextW: array [0..255] of Char;<br> TextH: array [0..255] of Char;<br>begin<br> // Step 1: Call PS to show the 'Image Size' dialog.<br> prc_MenuClick(2,8,-1);<br> // Step 2: If success,get the two Edit's handles.<br> repeat<br> Application.ProcessMessages;<br> ISH:= FindWindow(PChar('PSFloatC'),PChar('Image Size'));<br> until ISH <> 0 ;<br><br> repeat<br> Application.ProcessMessages;<br> CancelHandle:= FindWindowEx(ISH,0,PChar('Button'),Pchar('Cancel'));<br> WidthHandle:= FindWindowEx(ISH,0,PChar('Edit'),nil);<br> HeightHandle:= FindWindowEx(ISH,WidthHandle,PChar('Edit'),nil);<br> Until ((CancelHandle<>0) and (WidthHandle<>0) and (HeightHandle<>0));<br><br> SendMessage(WidthHandle,WM_GETTEXT,Sizeof(TextW),LongInt(@TextW));<br> SendMessage(HeightHandle,WM_GETTEXT,Sizeof(TextH),LongInt(@TextH));<br> Form1.Caption:= TextW;<br> Result.X:= StrToInt(Form1.Caption);<br> Form1.Caption:= TextH;<br> Result.Y:= StrToInt(Form1.Caption);<br> form1.caption:= form1.caption+ ' _ '+TextW;<br> PostMessage(CancelHandle,BM_CLICK,0,0); //After Use, Close it.<br>end;<br><br><br><br>procedure prc_AdjustWindow(AWidth: Integer;AHeight: Integer);<br>var<br> PP: TPoint;<br> ISH:Thandle;<br>const offSetH=100;<br>const offSetW= 35;<br>begin<br><br> PP:=fun_GetImageSize;<br> if (PP.Y)/(PP.X) > (AHeight/AWidth) then<br> begin<br> Windows.SetWindowPos(PSH,Form1.Handle,Screen.Width-5,Screen.Height-5,Screen.Width-55,AHeight+offSetH,SWP_NOACTIVATE);<br> end;<br> if (PP.Y)/(PP.X) < (AHeight/AWidth) then<br> begin<br> Windows.SetWindowPos(PSH,Form1.Handle,Screen.Width-5,Screen.Height-5,AWidth+offSetW,Screen.Height-5,SWP_NOACTIVATE)<br> end;<br> repeat<br> Application.ProcessMessages;<br> ISH:= FindWindow(Pchar('PSFloatC'),PChar('Image Size'));<br><br> until ISH= 0 ;<br> SendMessage(PSH,<br> WM_COMMAND,<br> GetMenuItemID(GetSubMenu(GetMenu(PSH),6),7),0); //Click 'VIew'-'Fit On Screen'<br> //prc_MenuClick(6,7,-1);<br>end;<br><br><br><br><br>procedure prc_MenuClick(m1,m2,m3: Integer);<br>begin<br>if m3 >= 0 then<br> PostMessage(PSH,WM_COMMAND,<br> GetMenuItemID(GetSubMenu(GetSubMenu(GetMenu(PSH),m1),m2),m3)<br> ,0)<br>else<br> PostMessage(PSH,<br> WM_COMMAND,<br> GetMenuItemID(GetSubMenu(GetMenu(PSH),m1),m2),0);<br>end;<br><br><br><br><br>这是一个例子,看不懂给我发邮件:)