Delphi Multi-screen display area lookup

Source: Internet
Author: User

A simple idea for multi-screen support under Windows is to find the display area (enumdisplaymonitors) and move the corresponding window to the target area (Windows Api:movewindow). Here is a simple look-up display area method, grects to find the display area, Gmcount to find the number.

1 UnitEnummonitor;2 3 Interface4 uses5 multimon, Windows;6 Const7Monitor_max_count =Ten;//Maximum number of displays8 9 varTen      //Display Area OneGrects:Array[0.. Monitor_max_count-1] ofTrect; A      //Check the number of monitors found -Gmcount:integer =0; -  the //Refresh Monitor Information - procedureRefreshmontor; -  - Implementation +  - var +Isfirst:boolean = True;//whether it is the first one, which is used when looking for A  at functionEnummon (Amonitor:hmonitor; ADC:HDC; Arect:prect; Aparam:lparam): Boolean;stdcall; - var - Info:monitorinfo; - begin -Result: =True; -      //Stop searching if the number of monitors exceeds the preset number in     ifGmcount >= Monitor_max_count Then -     begin toResult: =false; + Exit; -     End; the  *Info.cbsize: =SizeOf (monitorinfo); $ Getmonitorinfo (Amonitor, @info);Panax Notoginseng     //if it is the primary monitor, it is not the first time to find, and if it is the second time, the end lookup -     if(Info.dwflags = monitorinfof_primary) Then the     begin +         ifIsFirst Then A         begin theIsFirst: =false; +Gmcount: =1; -grects[0] :=Info.rcmonitor; $Result: =True; $ Exit; -         End -         Else begin the             //Flag Reset -IsFirst: =true;WuyiResult: =false; the         End -     End; Wu  -Grects[gmcount]: =Info.rcmonitor; About INC (gmcount); $ End; -  - procedureRefreshmontor; - begin AGmcount: =0; +IsFirst: =true; theFillchar (Grects, SizeOf (grects),0); -Enumdisplaymonitors (0,Nil, Enummon,0); $ End; the  the initialization the Refreshmontor; the  - Finalization inGmcount: =0; theFillchar (Grects, SizeOf (grects),0); the End.
Enummonitor.pas

Delphi Multi-screen display area lookup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.