

PRect-> left = LogicalToDeviceUnitsX(pRect-> left) Void CDpiHelper::LogicalToDeviceUnits(_Inout_ RECT * pRect) const Converts from logical units to device units. Return MulDiv(y, m_LogicalDpiY, m_DeviceDpiY) Int CDpiHelper::DeviceToLogicalUnitsY( int y) const Return MulDiv(x, m_LogicalDpiX, m_DeviceDpiX) Int CDpiHelper::DeviceToLogicalUnitsX( int x) const Converts between device and logical units. Return MulDiv(y, m_DeviceDpiY, m_LogicalDpiY) Int CDpiHelper::LogicalToDeviceUnitsY( int y) const Return MulDiv(x, m_DeviceDpiX, m_LogicalDpiX) Int CDpiHelper::LogicalToDeviceUnitsX( int x) const

Converts between logical and device units.

Return ( double)m_DeviceDpiY / m_LogicalDpiY Return ( double)m_DeviceDpiX / m_LogicalDpiX ĭouble CDpiHelper::LogicalToDeviceUnitsScalingFactorY() const Return ( double)m_LogicalDpiY / m_DeviceDpiY ĭouble CDpiHelper::LogicalToDeviceUnitsScalingFactorX() const Return ( double)m_LogicalDpiX / m_DeviceDpiX ĭouble CDpiHelper::DeviceToLogicalUnitsScalingFactorY() const Return horizontal and vertical scaling factorsĭouble CDpiHelper::DeviceToLogicalUnitsScalingFactorX() const Return (m_DeviceDpiX != m_LogicalDpiX || m_DeviceDpiY != m_LogicalDpiY) M_DeviceDpiX(iDeviceDpiX), m_DeviceDpiY(iDeviceDpiY), m_LogicalDpiX(iLogicalDpiX), m_LogicalDpiY(iLogicalDpiY), m_PreferredScalingMode(ImageScalingMode::Default)īool CDpiHelper::IsScalingRequired() const # define REGKEY_IMAGESCALING L"ImageScaling%d "ĬDpiHelper::CDpiHelper( int iDeviceDpiX, int iDeviceDpiY, int iLogicalDpiX, int iLogicalDpiY) :
Stretchblt copyimage full#
See LICENSE file in the project root for full license information. ' Release the bitmap's and desktop's DCs.//Copyright (c) Microsoft. Private Function DesktopImage() As Bitmapĭim desktop_win As Int32 = GetDesktopWindow()ĭim desktop_dc As Int32 = GetDC(desktop_win)ĭim desktop_bounds As Rectangle = Screen.GetBounds(New _ĭim desktop_wid As Int32 = desktop_bounds.Widthĭim desktop_hgt As Int32 = desktop_bounds.Heightĭim bm As New Bitmap(desktop_wid, desktop_hgt)ĭim bm_gr As Graphics = Graphics.FromImage(bm)īm_hdc, 0, 0, desktop_wid, desktop_hgt, _ĭesktop_dc, 0, 0, desktop_wid, desktop_hgt, _ It releases the Bitmap's and desktop's device context, and returns the Bitmap. The function then uses StretchBlt to copy the desktop window's image onto the Bitmap. Next the function makes a Bitmap big enough to hold the desktop's image, creates a Graphics object attached to it, and gets the Bitmap's device context. It uses Screen.GetBounds to see how big the desktop is. It uses GetDC to get a device context for that window. The DesktopImage function uses the GetDesktopWindow API function to get the hWnd of the desktop window. Private Sub btnGo_Click(ByVal sender As System.Object, _īyVal e As System.EventArgs) Handles btnGo.ClickĭesktopImage().Save(txtFile.Text, ImageFormat.Bmp)

When the user clicks Go, the program simply calls the function to get the Bitmap and then uses the Bitmap's Save method to save it into a file. The key to the program is the DesktopImage function, which returns a Bitmap holding the desktop's image.
Stretchblt copyimage how to#
This example shows how to grab the desktop image in VB. VB Helper: HowTo: Grab the desktop image in VB.
