Solved

vbMAXIMIZE

Posted on 2001-06-25
3
322 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

828 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