I was on holiday - you did (finally) get my reply, and glad to hear that it
worked out.
For the others, here's the gist of the reply:
In the absence of a local variable declared named hdc, the use of hdc in
form code is the same as me.hdc, or the hdc of the form (hdc means 'handle
to the display context'). Since in that demo hdc is not a defined variable,
it was anticipated the code would be used in a form that exposed its hdc
property.
The problem is that an MDI form, which does not natively allow drawing on
its container, does not expose the hdc of the form . So if you're going to
put the code in the MDI parent form, you'll need to declare a variable in
the procedure Dim hdc as Long, and then use the GetDc() and
GetDesktopWindow() APIs to obtain an hdc you can use. In air code, like:
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
dim hdc as long
hdc = GetDC(GetDesktopWindow())
..... now use the hdc value with the code for GetDeviceCaps.
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
"Joe-Paul" <Ha*********@comcast.net> wrote in message
news:bf********************@comcast.com...
Randy:
Hope you get this. I am the one that wrote regarding trying to get my boss'
computer screen to fit my program (rather than the other way around).
Thanks for the hint.
I went to the link provided for enumeration of the display. I tried the
program in VB6.0 and it worked (while I had it as a stand alone). I
modified it so that the Public Declare statements and variables were in a
Bas Module. Then I put the procedure to find out what the start up display
is in the MDI form of a program. It worked.. I put it the same way in my
program and it did not work. It keeps stopping and telling me that the
"hDC" is an undefined variable. Yet, "hDC" is part of the Public Declare in
the Module.
Do you have any idea why this is happening? I've gone to the vb site with
the script on it and left a question, but still have had no response.
Hope you find this and have a suggestion.
Thanks
JP