|
-
May 9th, 2001, 01:51 PM
#1
Thread Starter
Hyperactive Member
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
-
May 9th, 2001, 03:36 PM
#2
Hyperactive Member
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 !!!!
-
May 9th, 2001, 03:48 PM
#3
Thread Starter
Hyperactive Member
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
-
May 9th, 2001, 03:53 PM
#4
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
-
May 9th, 2001, 04:46 PM
#5
Thread Starter
Hyperactive Member
Excellent. Works nicely
gotta remove the "DRAGGING" parts tho
and put it in
nice work
-
May 9th, 2001, 05:09 PM
#6
Thread Starter
Hyperactive Member
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?
-
May 9th, 2001, 05:19 PM
#7
Thread Starter
Hyperactive Member
ohh, NM!
I am working on it now =)
-
May 9th, 2001, 05:31 PM
#8
Thread Starter
Hyperactive Member
wait.. need some help still lol
-
May 31st, 2002, 03:03 PM
#9
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|