Delphi 5沒有內置功能,可以在雙顯示器的情況下在顯示器上設置先前窗體的窗體。爲此,我已導入windows dll
。我搜索了這個,發現MonitorFromWindow()
和MonitorFromPoint()
。在顯示器上設置Delphi 5 Form,其中以前的窗體出現在雙顯示器系統中
我實施了MonitorFromWindow()
但我無法執行MonitorFromPoint()
。
如何獲取顯示器並在其上設置我的表單?
function MonitorFromWindow(hwnd: HWND; dwFlags: DWORD): HWND; stdcall; external 'User32.dll';
procedure TSmForm.AfterCreateForm(Session: ISmSession; SmHelpContext: TDM_Int32; IsDLL: Boolean);
type
HMONITOR = type THandle;
var
MBMonitor: HMONITOR;
const
MONITOR_DEFAULTTONEAREST = $00000002;
begin
//If you decide to remove the next two lines, make sure no one use this function and assume init of SmSession is here (like ScriptMaintanance etc.).
if SmSession<>Session then
SmSession := Session;
if SmHelpContext > 0 then
HelpContext := SmHelpContext;
//Following lines ensure that if the form resides in a dll, its icon is the same as the host application's
if (IsDLL) then
begin
if (Icon.Empty) and (ParentHWND <> 0) then
SendMessage(Handle, WM_SETICON, 1, SendMessage(ParentHWND, WM_GETICON, 1, 0));
end;
MBMonitor := MonitorFromWindow(Self.Handle, MONITOR_DEFAULTTONEAREST);
//HWND_NOTOPMOST
SetWindowPos(Self.Handle, MBMonitor, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
end { of TSmForm.AfterCreateForm } ;
具體什麼你的代碼有問題,你已經張貼?它毫不費力地翻譯MonitorFromPoint,所以你怎麼知道你不能這樣做? –
'Function MonitorFromPoint(ptScreenCoords:TPoint; dwFlags:DWORD):HMONITOR; STDCALL;外部用戶32「,它真的不會更容易。你有沒有嘗試過任何東西?我已經多次告訴過你,如果標題翻譯對你來說太難了,那麼你可以使用JEDI庫中的翻譯。忽視錯誤處理也是一個糟糕的政策。不要忽略錯誤。 –
我無法使用JEDI庫,因爲它不允許在我們的應用程序中使用3方庫。 – user7424581