CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Resizing Buttons and SnapToGrid

    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


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Resizing Buttons and SnapToGrid

    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

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

Featured