Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vbMAXIMIZE

Posted on 2001-06-25
3
Medium Priority
?
332 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 150 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

886 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