How to determine the dimensions of a DC in VB? 
Author Message
 How to determine the dimensions of a DC in VB?

Hello--

I've got the handle to a device context for a window and I'm trying to find
its dimensions, everything I try seems to be returning the screen's
dimensions, not the window's.  Here's what I'm using:

    Dim lpSize As size, lPreviousMapMode As Long
    hDCSrc = GetWindowDC(hWndSrc)
    If hDCSrc = 0 Then
        MsgBox "Problem getting a handle to the device context"
        Exit Function
    End If

    ' Set the map mode to Isotropic to enable the extents functions
    lPreviousMapMode = SetMapMode(hDCSrc, MM_ISOTROPIC)
    If lPreviousMapMode = 0 Then
        MsgBox "Problem setting the mapping mode to Isotropic"
        Exit Function
    End If
    If GetViewportExtEx(hDCSrc, lpSize) = 0 Then
        MsgBox "Problem getting window extents"
        Exit Function
    End If

    ' Create an array of points to send to LPtoDP, to convert the number
from logical
    ' units to device units.
    Dim auPoints(0) As POINTAPI
    With auPoints(0)
        .x = lpSize.cx
        .y = lpSize.cy
    End With

    If LPtoDP(hDCSrc, auPoints(0), 1) = 0 Then
        MsgBox "Problem translating the point from logical units to device
units"
        Exit Function
    End If

    ' Reset map mode to whatever it was previously
    SetMapMode hDCSrc, lPreviousMapMode

    WidthSrc = auPoints(0).x
    HeightSrc = auPoints(0).y

Any help would be greatly appreciated!

thanks,
randy childers



Sat, 17 Mar 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Determine the Dimensions of an VB Array

2. Determining if an array has dimensions

3. Q:Determining number of dimensions (not elements) in an array, VB3

4. Determining the number of dimensions in an array

5. DC-DC Converter

6. Can't create mask DC for off-screen DC.

7. bitmap to memory dc to picture box dc

8. single dimension array into multiple dimension array

9. Dimensioning of single dimension arrays within a class

10. Dimensioning a Picture Control to the dimensions of a variable dimension video With MMControl.

11. US DC/MD Access VB programmer FT/PT

12. DC Area VB Area Programers

 

 
Powered by phpBB® Forum Software