Results 1 to 9 of 9

Thread: Resize Borderless

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482

    Resize Borderless

    Hello, I have borderless forms using API - and I would like to know if there is any code to help RESIZE the form when it has no border

    like, is there api or could someone create some code so if the mouse is so far off the form, the mouse cursor changes, and u can RESIZE?

    thanks alot

  2. #2
    Hyperactive Member techman2553's Avatar
    Join Date
    Mar 2001
    Location
    <- To your left.
    Posts
    362
    From one of my previous posts:

    You can use an API call to "Erase" the Title Bar from the form, while still leaving the BoarderStyle set to 2-Sizable. Another set of API calls will then allow you to move the form with the mouse, even without the Title Bar. This will allow you to have a graphic, sizable, movable form without a Title Bar, and still keep both the caption and icon in the taskbar.

    Create a new project, and place this code in the form. (Leave the BoarderStyle set to 2-Sizable.


    Code:
    Option Explicit
    
    'API Calls Used To Remove The Title Bar From Window (Make A Sizeable Borderless Form)
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Const GWL_STYLE = (-16)
    Private Const WS_DLGFRAME = &H400000
    
    'API Calls Used To Move A Form With The Mouse
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const HTCAPTION = 2
    Private Const WM_NCLBUTTONDOWN = &HA1
    
    Private Sub Form_Load()
      'ERASE the Title Bar
      SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) + WS_DLGFRAME
    End Sub
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
      'Move the form with the Left Mouse Button
      If Button = 1 Then
        Me.MousePointer = vbSizeAll
        Call ReleaseCapture
        Call SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
        Me.MousePointer = vbArrow
      End If
    End Sub

    Have Fun !!!!
    ----------

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    yes, but I have an API to make it BORDERLESS at runtime..
    so there is no way to RESIZE it (altho you can use code like me.width = "100" and it resizes)

    i just need a way to find if the mouse is in the right position, and then if the mouse is down on that position, then resize as they move mouse

  4. #4
    Matthew Gates
    Guest
    Try this:


    Code:
     Submitted on: 9/13/2000 3:01:24 PM
    By: Kevin Wiegand
    Level: Beginner
    User Rating: Unrated 
    Compatibility:VB 4.0 (32-bit), VB 5.0, VB 6.0
    Task:  Creates a form that is sizeable, but has no border, so to speak.
    
    
    Option Explicit
    
    
    Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As _
    Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
    
    Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As _
    RECT) As Long
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As _
    POINTAPI) As Long
    
    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 fXPos As Single
        Private fYPos As Single
        Private fX As Single
        Private fY As Single
        Private fbolDrag As Boolean
        'The size of the title area On the form
        Private Const fcTitleSize = 22
        'the offset needed To make the form Move
        '     smoothly
        Private Const fcBorderSize = 4
    
    
    Private Sub Form_Load()
        Dim rRect As RECT
        Dim ret As Long
        rRect.Left = 0
        rRect.Top = fcTitleSize
        rRect.Right = Me.Width
        rRect.Bottom = Me.Height
        ret = CreateRectRgnIndirect(rRect)
        SetWindowRgn Me.hWnd, ret, True
    End Sub
    
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim rPos As POINTAPI
        GetCursorPos rPos
        fX = X * 15
        fY = Y * 15
        fXPos = (rPos.X * 15) - X
        fYPos = (rPos.Y * 15) - Y
        fbolDrag = True
    End Sub
    
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    
        If fbolDrag = True Then
            Me.Move fXPos, fYPos
        End If
    End Sub
    
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        fbolDrag = False
    End Sub
    
    
    Private Sub Timer1_Timer()
        Dim rPos As POINTAPI
    
    
        If fbolDrag = True Then
            GetCursorPos rPos
            fXPos = (rPos.X * 15) - (fX + (fcBorderSize * 15))
            fYPos = (rPos.Y * 15) - (fY + ((fcTitleSize + 1) * 15))
            Me.Move fXPos, fYPos
        End If
    End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    Excellent. Works nicely

    gotta remove the "DRAGGING" parts tho
    and put it in

    nice work

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    I removed everything i needed to to make it only resize, it looks as if all it does is remove everything BUT the resize borders..

    how about if i made my own little "REGION" and you hold mouse down, and it'll move the right,left,bottom,top,or corners of the form to where the mouse is - without moving the whole form

    anyone have any ideas?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    ohh, NM!
    I am working on it now =)

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    wait.. need some help still lol

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I need help to get this working. There's a little border (that can be seen), and the moving is not working a 100%.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width