Solved

vbMAXIMIZE

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 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

18 Experts available now in Live!

Get 1:1 Help Now