silent
05-28-2002, 11:57 AM
while my program is running, I would like to allow the user to resize the different controls on the form. Is there an API or some other way that I can implement this?
thanks!
thanks!
resizing controlssilent 05-28-2002, 11:57 AM while my program is running, I would like to allow the user to resize the different controls on the form. Is there an API or some other way that I can implement this? thanks! BillSoo 05-28-2002, 11:59 AM You can write your own code by detecting the mousedown and mousemove events. There are also splitterbar controls available that can do some resizing. It depends on what you want to do exactly.... VB6Newbie 05-28-2002, 12:00 PM I think there is an api function for that... resizeall or something like that.... try doing a search.. or go to www.allapi.net silent 05-28-2002, 12:04 PM well, my program is sort of like a VERY slimmed down Visual Basic...after the program starts, a user can create a form, and then drag and drop different controls from one form to their new form. I then want to allow them to resize the controls after they drop them on the form they are creating. I have an edit menu which allows them to manually enter values for the different properties, but it would be much nicer if they could do it all with the mouse. VB6Newbie 05-28-2002, 12:07 PM idk myself.. but if you are makeing a version like vb then make sure to include api functions..... lol silent 05-28-2002, 12:10 PM haha! this is just a little project where the users can create forms with different buttons and text boxes, etc. it doesnt realy do anything. lol BillSoo 05-28-2002, 01:22 PM Here is an example of using mousedown and mousemove to move and resize a picturebox. As you can see, there is a fair amount of code.... Option Explicit 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 Dim MouseXY As POINTAPI Dim MouseState As Integer Dim OldSize As RECT Private Const BORDERWIDTH As Integer = 60 Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim edgemask As Integer GetCursorPos MouseXY With Picture1 MouseXY.X = MouseXY.X - .Left / Screen.TwipsPerPixelX MouseXY.Y = MouseXY.Y - .Top / Screen.TwipsPerPixelY OldSize.Left = .Left OldSize.Top = .Top OldSize.Right = .Width + .Left OldSize.Bottom = .Height + .Top edgemask = 0 If X < BORDERWIDTH Then edgemask = edgemask Or 1 If Y < BORDERWIDTH Then edgemask = edgemask Or 2 If X > (.ScaleWidth - BORDERWIDTH) Then edgemask = edgemask Or 4 If Y > (.ScaleHeight - BORDERWIDTH) Then edgemask = edgemask Or 8 MouseState = edgemask Select Case edgemask Case 1, 4: .MousePointer = vbSizeWE 'left edge or right edge Case 2, 8: .MousePointer = vbSizeNS 'top edge or bottom edge Case 3, 12: .MousePointer = vbSizeNWSE 'topleft corner or bottom right Case 6, 9: .MousePointer = vbSizeNESW 'top right corner or bottom left Case Else 'not near any of the edges, or odd combination... .MousePointer = vbSizeAll MouseState = 0 End Select End With End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim XY As POINTAPI Dim l!, t!, w!, h! Dim dx!, dy! With Picture1 l = .Left: t = .Top: w = .Width: h = .Height End With GetCursorPos XY If Button = 1 Then dx = (XY.X - MouseXY.X) * Screen.TwipsPerPixelX dy = (XY.Y - MouseXY.Y) * Screen.TwipsPerPixelY Select Case MouseState Case 0 'move l = dx t = dy Case 1 'left edge l = dx w = OldSize.Right - l Case 2 'top edge t = dy h = OldSize.Bottom - t Case 3 'top left l = dx t = dy w = OldSize.Right - l h = OldSize.Bottom - t Case 4 'right edge w = OldSize.Right + dx - 2 * OldSize.Left Case 6 'top right t = dy h = OldSize.Bottom - t w = OldSize.Right + dx - 2 * OldSize.Left Case 8 'bottom edge h = OldSize.Bottom + dy - 2 * OldSize.Top Case 9 'bottom left l = dx w = OldSize.Right - l h = OldSize.Bottom + dy - 2 * OldSize.Top Case 12 'bottom right w = OldSize.Right + dx - 2 * OldSize.Left h = OldSize.Bottom + dy - 2 * OldSize.Top End Select Picture1.Move l, t, w, h End If End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Picture1.MousePointer = vbNormal End Sub silent 05-28-2002, 01:47 PM well I think that I understand most of what you are doing. But, when I implemented it, I get an error on the line: If X > (.ScaleWidth - BORDERWIDTH) Then..... with the .ScaleWidth...the error says: "Method or Data Member not Found" any ideas as to what is wrong? silent 05-29-2002, 07:55 AM well, let's see if anyone can help with this problem this morning :D Squirm 05-29-2002, 08:01 AM Pictureboxes have a ScaleWidth property, other controls do not. What were you trying to resize? silent 05-29-2002, 09:58 AM ahhh, right now I am trying to resize buttons, labels, text boxes, and eventually check boxes and combo boxes. BillSoo 05-29-2002, 10:16 AM In most cases, you can use the WIDTH property instead of SCALEWIDTH |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum