Solved

vbMAXIMIZE

Posted on 2001-06-25
3
316 Views
Last Modified: 2012-05-04
I have a command button on a form with the following code in it

me.windowstate = 2 'this maximizes the form

the problem is that it maximizez the form to the screen height and witdth and covers the taskbar how can i prevent this from happening
0
Comment
Question by:RYMENHOUT
3 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6224630
I've seen this type of problem before.  You most likely need to change the size of the form in the development environment.  Make the form smaller (smaller than the current window size) and try it again.

cheers
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6224955
I think if you add a system object, one of the methods is the screensize excluding the taskbar, so you can simply resize your app to those settings.
0
 
LVL 2

Accepted Solution

by:
egsemsem earned 50 total points
ID: 6230556
Hi,
  try this code, it will give u the left, top,width and height of windows taskbar:

'In module
Option Explicit

Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long

Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type


Public Type APPBARDATA
    cbSize As Long
    hwnd As Long
    uCallbackMessage As Long
    uEdge As Long
    Rc As RECT
    lParam As Long ' message specific
End Type
Public Const ABM_GETTASKBARPOS = &H5

Public Function GetScreenRect(hwnd As Long) As RECT
    Dim enuAPPBARDATA As APPBARDATA
       
    enuAPPBARDATA.cbSize = Len(enuAPPBARDATA)
    enuAPPBARDATA.hwnd = hwnd
       
    SHAppBarMessage ABM_GETTASKBARPOS, enuAPPBARDATA
       
    With enuAPPBARDATA.Rc
        'transform to twips
        GetScreenRect.Left = .Left * Screen.TwipsPerPixelX
        GetScreenRect.Top = .Top * Screen.TwipsPerPixelY
        GetScreenRect.Right = .Right * Screen.TwipsPerPixelX
        GetScreenRect.Bottom = .Bottom * Screen.TwipsPerPixelY
    End With

End Function


'In form
Private Sub Form_Click()
    Debug.Print "left: " & GetScreenRect(Me.hwnd).Left
    Debug.Print "top: " & GetScreenRect(Me.hwnd).Top
    Debug.Print "Width: " & GetScreenRect(Me.hwnd).Right - GetScreenRect(Me.hwnd).Left
    Debug.Print "Height: " & GetScreenRect(Me.hwnd).Bottom - GetScreenRect(Me.hwnd).Top
End Sub




0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now