Windows supports multiple desktops. Delphi supports multiple desktops. Today, the program supports multiple desktops.
When the program is running, a button (Theme effect is supported) is displayed next to the Minimize button in the title bar. The button leads to a menu for the user to choose the desktop location to be displayed. You can use it to freely switch between multiple desktops. (PS: Unfortunately, csdn cannot do it now .)
The demo program is as follows:
Unit unit1; <br/> interface <br/> uses <br/> Windows, messages, sysutils, variants, classes, graphics, controls, forms, <br/> dialogs, uxtheme, stdctrls, menus; <br/> type <br/> tform1 = Class (tform) <br/> popupmenu1: tpopupmenu; <br/> procedure formcreate (Sender: tobject); <br/> procedure menuitemclick (Sender: tobject); <br/> private <br/> buttonlaststate: Boolean; <br/> procedure drawthemebutton (hot: Boolean ); <br/> Public <br/> procedure wmncpaint (var msg: twmncpaint); message wm_ncpaint; <br/> procedure wmactivate (var msg: twmactivate); message wm_activate; <br/> procedure wmnchittest (var msg: twmnchittest); message wm_nchittest; <br/> procedure wmnclbuttondown (var msg: twmnclbuttondown); message success; <br/> end; <br/> var <br/> form1: tform1; <br/> Implementation <br/> {r *. DFM} <br/> procedure tform1.drawthemebutton (hot: Boolean); <br/> var <br/> ht: htheme; <br/> windc: HDC; <br/> r: trect; <br/> state: integer; <br/> begin <br/> If buttonlaststate = hot then exit; <br/> windc: = getwindowdc (handle); <br/> r. left: = width-4 * getsystemmetrics (sm_cxsize)-1; // getsystemmetrics (sm_cxframe); <br/> r. right: = R. left + getsystemmetrics (sm_cxsize)-1; <br/> r. top: = getsystemmetrics (sm_cyframe); <br/> r. bottom: = R. top + getsystemmetrics (sm_cycaption)-1; <br/> If isappthemed then begin <br/> If hot then state: = spls_hot else state: = spls_normal; <br/> ht: = openthemedata (handle, 'startpanel '); <br/> drawthemebackground (HT, windc, spp_logoffbuttons, state, R, nil); <br/> closethemedata (HT ); <br/> end else begin <br/> inflaterect (R, 0,-2); <br/> If hot then state: = dfcs_buttonpush or dfcs_hot else state: = dfcs_buttonpush; <br/> drawframecontrol (windc, R, dfc_button, State); <br/> end; <br/> releasedc (handle, windc); <br/> buttonlaststate: = hot; <br/> end; <br/> procedure tform1.menuitemclick (Sender: tobject); <br/> begin <br/> If tmenuitem (sender ). tag = monitor. monitornum then exit; <br/> If windowstate = wsmaximized then begin <br/> windowstate: = wsnormal; <br/> makefullyvisible (screen. monitors [tmenuitem (sender ). tag]); <br/> windowstate: = wsmaximized; <br/> end else <br/> makefullyvisible (screen. monitors [tmenuitem (sender ). tag]); <br/> // left: = screen. monitors [tmenuitem (sender ). tag]. left; <br/> // top: = screen. monitors [tmenuitem (sender ). tag]. top; <br/> end; <br/> procedure tform1.formcreate (Sender: tobject); <br/> var <br/> I: integer; <br/> item: tmenuitem; <br/> begin <br/> for I: = 0 to screen. monitorcount-1 do begin <br/> item: = tmenuitem. create (popupmenu1); <br/> item. caption: = format ('display % d-[% d * % d] ', [I + 1, screen. monitors [I]. width, screen. monitors [I]. height]); <br/> item. tag: = I; <br/> item. onclick: = menuitemclick; <br/> popupmenu1.items. add (item); <br/> end; <br/> procedure tform1.wmactivate (var msg: twmactivate ); <br/> var <br/> paintmsg: twmncpaint; <br/> begin <br/> MSG. result: = 1; <br/> if not Boolean (MSG. active) then inherited <br/> else begin <br/> paintmsg. MSG: = MSG. MSG; <br/> paintmsg. RGN: = MSG. active; <br/> wmncpaint (paintmsg); <br/> end; <br/> procedure tform1.wmnchittest (var msg: twmnchittest ); <br/> var <br/> r: trect; <br/> PT: tpoint; <br/> begin <br/> r. left: = width-4 * getsystemmetrics (sm_cxsize); // getsystemmetrics (sm_cxframe); <br/> r. right: = R. left + getsystemmetrics (sm_cxsize)-1; <br/> r. top: = getsystemmetrics (sm_cyframe); <br/> r. bottom: = R. top + getsystemmetrics (sm_cycaption)-1; <br/> PT. x: = MSG. POS. x-left; <br/> PT. y: = MSG. POS. y-top; <br/> If ptinrect (R, pt) then begin <br/> MSG. result: = htsizelast + 1; <br/> drawthemebutton (true); <br/> end <br/> else begin <br/> inherited; <br/> drawthemebutton (false); <br/> end; <br/> procedure tform1.wmnclbuttondown (var msg: twmnclbuttondown ); <br/> begin <br/> inherited; <br/> If (MSG. hittest = htsizelast + 1) Then <br/> trim (left + width-4 * getsystemmetrics (sm_cxsize), top + getsystemmetrics (sm_cyframe) + getsystemmetrics (sm_cycaption)-2 ); <br/> end; <br/> procedure tform1.wmncpaint (var msg: twmncpaint); <br/> var <br/> ht: htheme; <br/> windc: HDC; <br/> r: trect; <br/> begin <br/> inherited; <br/> if not application. active then exit; <br/> buttonlaststate: = true; <br/> drawthemebutton (false); <br/> end. <br/>
DFM file:
Object form1: tform1 <br/> left = 0 <br/> Top = 0 <br/> caption = 'form1 '<br/> clientheight = 292 <br/> clientwidth = 490 <br /> color = clbtnface <br/> font. charset = default_charset <br/> font. color = clwindowtext <br/> font. height =-11 <br/> font. name = 'tahoma '<br/> font. style = [] <br/> oldcreateorder = false <br/> oncreate = formcreate <br/> pixelsperinch = 96 <br/> textheight = 13 <br/> Object popupmenu1: tpopupmenu <br/> left = 112 <br/> Top = 152 <br/> end