form size


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: form size

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    form size

    [Originally posted by sumit]

    i want to set the height, width, top and left of my form equal to the same of the window in focus.
    how can i do that.
    please help.

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:form size

    [Originally posted by Mrugendra Bhure]

    You will have to use some API functions first for finding the in-Focus window, then find its co-ordinates and then set your form accordingly. Here is how you should go about it.

    Use the Api Functions:
    GetForegroundWindow() -: Retrives the handle to active window

    GetWindowPlacement for gettting co-ordinates for the active window and then set them

    Here is an example
    Private Declare Function GetForegroundWindow Lib "user32" () As Long

    Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long

    rivate Const SW_MINIMIZE = 6
    Private Type POINTAPI
    x As Long
    y As Long
    End Type
    Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type
    Private Type WINDOWPLACEMENT
    Length As Long
    flags As Long
    showCmd As Long
    ptMinPosition As POINTAPI
    ptMaxPosition As POINTAPI
    rcNormalPosition As RECT
    End Type

    Dim Rectan As RECT
    Private Sub Resize()
    Dim WinEst As WINDOWPLACEMENT
    Dim rtn As Long,dim Hnd as long

    WinEst.Length = Len(WinEst)
    'get the current window placement
    hnd=getForeGroundWindow()
    rtn = GetWindowPlacement(hnd, WinEst)
    Rectan = WinEst.rcNormalPosition

    me.Left= Rectan.Left
    me.Top=Rectan.Top
    me.Width=Rectan.Right-Rectan.Left
    me.Height=Rectan.Bottom-Rectan.Top
    End Sub

    Hopefully , it solves the problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center