This document is currently under construction, however it will contain a
number of "How To" guides that will focus on how to perform specific tasks
using CapeSoft Draw. The will range from common basic tasks, to using the
more advanced functions, along with the tools that Draw provides to manage
fonts on the system, handle multiple displays and so on.
Draw provides a number of methods to handle multiple monitors. See the
MultiMonitor example for a complete demonstration. In
addition the
GoFullScreen show how to just make a window
full screen (this is also demonstrated in the
MultiMonitor
example which demonstrates all of the methods below).
ListMonitors - Retrieves information
about all of the monitors on the system and fill a queue with the details
include the monitor handle, the coordinates and the workarea.
ListDisplayDevices - Lists all
display devices on the system and populates a queue with the details
Fullscreen - uses the built in functions to get the
metrics for the current monitor and resizes the window to the full size of
the screen.
MonitorFromRect - returns a handle
to the monitor that the passed Rect is on
GetMonitorInfo - retrieve
information about the monitor based on the passed handle (including the
monitor size and workspace size).
The
Fullscreen method serves as an excellent example of
using both
MonitorFromRect to get the monitor that a
window and
GetMonitorInfo to retrieve the metrics for that
monitor:
The method takes a Window as a parameter, allowing any window to be
resized to be full screen. For an application that works as a "Fullscreen"
application the window should have no caption (window text) and the frame
type should be set to "none". The GoFullscreen example provided with Draw
demonstrates this.
Using the method in an application is simple. It it's simplest form it is
just a one liner:
Drawer.FullScreen(Window)
It is then easy to expand it to resize the Draw control and draw whatever
is required:
Drawer.FullScreen(Window)
! Resize the Draw control
?Draw{prop:width} = Window{prop:width}
?Draw{prop:height} = Window{prop:height}
Drawer.Resize()
!Do any drawing required
Drawer.ShadeBox(1, 1, Drawer.width, Drawer.height, 0CACACAh, color:white)
Drawer.fontName = 'Tahoma'
Drawer.fontSize = 32
Drawer.Show(100, Drawer.height/2, 'Draw Fullscreen. Press Esc to close the window')
Drawer.Display()
For those who are interested in the underlying workings, the FullScreen method itself serves as an excellent example of using the
MonitorFromRect and
GetMonitorInfo
methods, both of which wrap a number of API calls. Below is a commented
version of the method:
Draw.FullScreen Procedure(*WINDOW Wnd)
hMonitor unsigned ! A handle to the monitor
prc like(DRAW_RECT) ! A rectangle to store the display coordinates of the monitor
mi like(DRAW_MONITORINFO) ! The monitor information
pp long
pt long
code
pp = Wnd{Prop:Pixels} ! Save and restore units being used
pt = Wnd{Prop:Thous}
Wnd{prop:pixels} = 1
! Get the coordinates for the window and store them in the RECT structure
prc.left = Wnd{prop:xpos}
prc.right = Wnd{prop:xpos} + Wnd{prop:width}
prc.top = Wnd{prop:ypos}
prc.bottom = Wnd{prop:ypos} + Wnd{prop:height}
hMonitor = self.MonitorFromRect(prc, DRAW:MONITOR_DEFAULTTONEAREST)
if not hMonitor
self.ErrorTrap('Failed to retrieve the Monitor handle. Error ' & drwGetLastError() |
& ': ' & self.FormatMessage(drwGetLastError()), 'Fullscreen')
return False
end
mi.cbSize = Size(mi)
if not self.GetMonitorInfo(hMonitor, mi)
self.ErrorTrap('Failed to retrieve the Monitor info. Error ' & drwGetLastError() |
& ': ' & self.FormatMessage(drwGetLastError()), 'Fullscreen')
return False
end
! Set the window position to the full size of the screen
Wnd{prop:xpos} = mi.rcMonitor.left
Wnd{prop:ypos} = mi.rcMonitor.top
Wnd{prop:width} = mi.rcMonitor.right - mi.rcMonitor.left
Wnd{prop:height} = mi.rcMonitor.bottom - mi.rcMonitor.top
! Restore the window units
Wnd{Prop:Thous} = pt
Wnd{prop:pixels} = pp
return True