Click to See Complete Forum and Search --> : Resizing Buttons and SnapToGrid


October 21st, 1999, 02:09 PM
I have programmed a menu option on my form (which contains a tab ctrl) that allows a user of the form to add buttons dynamically to the form. I set the newly created button's parent to be the tab control.

What I need to know is how does one make the newly added button resizable. In the command buttons list of methods, I don't see a resize method, leading me to believe that perhaps I have to design an ActiveX controls. I am unfamiliar with ActiveX so I don't want to involve myself in this learning curve if I don't have to do so. Also, along these same lines, when I have two newly created buttons, and I want to line them up side by side it is extremely difficult to do so. I need some sort of snap to grid thing or some other idea to make the lining up of buttons easier for the user.

My form has a Tab control on it. I've made the tab controls drag and drop method do this:

SSTab1_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move (X - Source.Width / 2), (Y - Source.Height / 2)

This works fine for regular old dragging and dropping, but like I said, it is extremely difficult for me to line buttons up and get them to behave.

Thanks in advance for any suggestions,
KD

Chris Eastwood
October 21st, 1999, 02:28 PM
Here's some nifty code to move controls at run-time :

Get a form and place a picture box (picture1) on it - then paste in the following code to the form :


option Explicit
'
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
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
'
private Sub Picture1_MouseDown(Button as Integer, Shift as Integer, X as
Single, Y as Single)
'
ReleaseCapture
SendMessage Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
'
End Sub




As for resizing - soft-circuits have (had?) a really good 'form-designer' demo (with source code) at http://www.softcircuits.com.


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb