WindowHeight and WindowWidth problem

  • Thread starter Thread starter Domac
  • Start date Start date
D

Domac

HI,

How to set window height and window width from code??

I would like to increase Height property of form to show controls below.
Window border is set to dialog.

WindowHeight and WindowWidth properties are read-only.

So, how to change window size???


Thanks,
Domac
 
Hi,

I've solved my problem with SetWindowPos API function, now I have another
problem;

SetWindowPos works with pixels as argument , how to convert pixels to twips
and vice versa.


Thanks a lot!

Domac
 
Domac said:
Hi,

I've solved my problem with SetWindowPos API function, now I have another
problem;

SetWindowPos works with pixels as argument , how to convert pixels to twips
and vice versa.


Thanks a lot!

Domac

The GetDeviceCaps function returns data about your computer's display.
This information includes the display type (plotter, raster screen, and
so forth), the size of the display, and whether the device can rotate
text 90 degrees. Take a look at the online help for a complete list of
this function's abilities.

GetDeviceCaps takes as parameters a device context and a flag indicating
the kind of information you want to retrieve. If you use the RASTERCAPS
flag, the function returns a long integer containing the sum of several
possible values.

-- Visual Basic Graphics Programming, Rod Stephens, Wiley 2000, ISBN
0-471-35599-2


Useful flags:
HORZRES Screen width in pixels
VERTRES Screen height in raster lines
LOGPIXELSX Width pixels per logical inch
LOGPIXELSY Height pixels per logical inch


pixels * inches/pixel * twips/inch = twips
twips * inches/twips * pixels/inch = pixels

(BTW, I think the DeviceCapabilities API can return a list of all
possible screen resolutions for the video adapter.)

twips/inch = 1440
inches/twips = 1 / 1440

GetDeviceCaps should be able to get you the inches/pixel in each
direction to get the last number needed for this conversion.

Sample declaration:

Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hdc As
Long, ByVal nIndex As Long) As Long

I think GetDeviceCaps is available on all 32-bit windows OS's. I'm not
sure if there's an easier way to do this.

James A. Fortune
(e-mail address removed)

Disclaimer: I'm not responsible if using an API function causes your
computer to crash, so please verify these statements for yourself before
using the GetDeviceCaps or DeviceCapabilities API functions.
 
Hi James,
the issue facing the OP will be obtaining a handle to a screen Device
Context. Access does not expose one so the OP will have to create a temp DC.
Many of my projects contain the code to convert TWIPS to PIXELS and vice
versa.
Something like:

Private Sub GetScreenDPI()
Dim lngDC As Long
Dim lngPixelsPerInch As Long
Const nTwipsPerInch = 1440

lngDC = GetDC(0)

'Horizontal
m_ScreenXdpi = apiGetDeviceCaps(lngDC, LOGPIXELSX)
'Vertical
m_ScreenYdpi = apiGetDeviceCaps(lngDC, LOGPIXELSY)

lngDC = ReleaseDC(0, lngDC)
End Sub

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Stephen said:
Hi James,
the issue facing the OP will be obtaining a handle to a screen Device
Context. Access does not expose one so the OP will have to create a temp DC.
Many of my projects contain the code to convert TWIPS to PIXELS and vice
versa.
Something like:

Private Sub GetScreenDPI()
Dim lngDC As Long
Dim lngPixelsPerInch As Long
Const nTwipsPerInch = 1440

lngDC = GetDC(0)

'Horizontal
m_ScreenXdpi = apiGetDeviceCaps(lngDC, LOGPIXELSX)
'Vertical
m_ScreenYdpi = apiGetDeviceCaps(lngDC, LOGPIXELSY)

lngDC = ReleaseDC(0, lngDC)
End Sub

Good point. Also, the "logical inch" is not intuitive. Some
information about it can be found here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnprogwin/html/ch17-02.asp

James A. Fortune
(e-mail address removed)
 
I don't have "getdevicecaps", twipstopixels, or any of the other functions that people say I can use. I am using access 2003. I have a visio drawing control on a form. I want the form to be anchored in the obvious manner.

Private Sub Form_Resize()
DrawingControl0.Width = TwipsToPixels(Form.Width) - 2000 '11000
DrawingControl0.Height = TwipsToPixels(Form.Detail.Height) - 2000 '8000
End Sub

I tried this for the twipstopixels function, but the graphics type is not recognized.
Private Function TwipsToPixels(ByVal intPixels As Integer) As Integer

Dim g As Graphics
Set g = Me.CreateGraphics()

TwipsToPixels = intPixels * g.Dpi / 1440
g.Dispose
End Function

I can't beleive these idiots would release a programming lagguage without sufficient conversion tools.
 
I don't have "getdevicecaps", twipstopixels, or any of the other functions that people say I can use. I am using access 2003. I have a visio drawing control on a form. I want the form to be anchored in the obvious manner.

Private Sub Form_Resize()
DrawingControl0.Width = TwipsToPixels(Form.Width) - 2000 '11000
DrawingControl0.Height = TwipsToPixels(Form.Detail.Height) - 2000 '8000
End Sub

I tried this for the twipstopixels function, but the graphics type is not recognized.
Private Function TwipsToPixels(ByVal intPixels As Integer) As Integer

Dim g As Graphics
Set g = Me.CreateGraphics()

TwipsToPixels = intPixels * g.Dpi / 1440
g.Dispose
End Function

I can't beleive these idiots would release a programming lagguage without sufficient conversion tools.

Check Tools... References in the VBA editor, and make sure that the
appropriate graphics library is loaded.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top