41938

How to show a firemonkey form on second monitor

Question:

I am trying to display a FireMonkey form on a second monitor, using C++Builder with following code:

<pre class="lang-c prettyprint-override"> void __fastcall ShowFormOnScreen( int OutMon ) { MyForm->Top = 0; MyForm->BorderStyle = bsNone; MyForm->WindowState = wsNormal; MyForm->Left = Screen->Monitors[OutMon]->Left; MyForm->Height = Screen->Monitors[OutMon]->Height; MyForm->Width = Screen->Monitors[OutMon]->Width; MyForm->Show(); }

Unfortunately, the Screen object does not have the Monitors property, so how can do this in FireMonkey?

Answer1:

For windows you can use EnumDisplayMonitors to locate the second monitor. This needs a callback function which will receive the information from each monitor found. Example in Delphi below which displays a second Firemonkey form on the second monitor and makes the background black

// Callback function in function MonitorCount function MonCountCB(hm: HMONITOR; dc: HDC; r: PRect; l: LPARAM): Boolean; stdcall; var mInfo : MonitorInfoEx; // SecondaryRect: RECT; begin minfo.cbSize := sizeof(mInfo); GetMonitorInfo(hm, @mInfo); if mInfo.dwFlags <> MONITORINFOF_PRIMARY then begin MonitorForm.Left := mInfo.rcWork.Left; MonitorForm.Top := mInfo.rcWork.Top; MonitorForm.Width := mInfo.rcWork.Width; MonitorForm.Height := mInfo.rcWork.Height; end; inc(Integer(pointer(l)^)); result := true; end; procedure TForm1.CornerButton1Click(Sender: TObject); var MonitorCount : Integer; begin EnumDisplayMonitors(0,nil,MonCountCB, Integer(@MonitorCount)); MonitorForm.Viewport3D1.Color := TAlphaColors.Black; MonitorForm.Show; end;

Answer2:

FMX has no multi-monitor support yet. You will have to write platform specific code and switch behaviour using the platform conditional defines.

Answer3:

In XE7, there is now a global Screen variable which has a Screen.Displays[] property that you can use to get information about the available displays. The Screen.DisplayCount property can tell you how many displays there are. You have to add "FMX.Forms" to your USES clause to use this.

Recommend

  • example of embarcadero WindowHandleToPlatform c++
  • Transparent Form in firemonkey with a stylebook
  • Delphi XE4 stringgrid selectcell in FireMonkey
  • Minimize form in Firemonkey application
  • Addresses of Delphi and C++ WinAPI functions differ when they shouldn't
  • How can I get the “Edit Component's Name” window to show when I place a component?
  • How to get length of a dynamic array in Delphi? [closed]
  • Delphi Chromium Embedded - Clear browser cache
  • Microsoft Excel Pivot miscalculation in Sum for positive and negative numbers
  • read values from form post in jquery or javascript
  • apply a javascript function to draggable copy
  • CSS - Cannot get one spanned style to override another inherited style and align left
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Exception gevent.hub.LoopExit: LoopExit('This operation would block forever',)
  • Suppressing passwd when calling sqlplus from shell script
  • Database structure design with variable amounts of fields
  • Why is the size of this struct 32?
  • C# - Serializing and deserializing static member
  • How do I fake an specific browser client when using Java's Net library?
  • Sony Xperia Z Tablet not found by adb
  • How to get a value (ex: baseURL) in every Karate feature?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Javascript convert timezone issue
  • When should I choose bucket sort over other sorting algorithms?
  • Hazelcast - OperationTimeoutException
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • To display the title for the current loaction in map in iphone
  • Web-crawler for facebook in python
  • Akka Routing: Reply's send to router ends up as dead letters
  • AT Commands to Send SMS not working in Windows 8.1
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How do you join a server to an Active Directory (domain)?
  • How do I configure my settings file to work with unit tests?
  • Is it possible to post an object from jquery to bottle.py?
  • Checking variable from a different class in C#
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?