Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21282

GetDeviceCaps Returning 0 for hdc

$
0
0
Hi there,

Getting 0 back in this code:

Code:

Public Property Let hDC(newHdc As Long)
HDCStored = newHdc
End Property

Where newHdc is passed as the dc property of a formObj in the loading phase- but not yet shown.
Code:

Public Property Get DCWidth() As Long
DCWidth = GetDeviceCaps(HDCStored, HORZRES)
End Property

Fairly sure that GetDC and ReleaseDC is not required for this use, but what's found in testing is this:
DCWidth (or DCHeight) will return values if the dimensions of the form are not changed. Haven't tested other properties being changed.
If the formObj width or height is changed before another call of GetDeviceCaps, DCWidth (or DCHeight) will then return 0.
Not a big drama, any corrections welcome- but it's out there if anyone is interested. :)

Viewing all articles
Browse latest Browse all 21282


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>