Results 1 to 9 of 9

Thread: BorderStyle at runtime

  1. #1
    spetnik
    Guest

    Unhappy

    How do I change the border style of a form during runtime?

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    You can't - it's read only !
    All the API calls I looked at allow you to add borders / rectangles around a window, but I don't think there's any way you can set this !

    Why do you need this ?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Although the MSDN says so, but you can change the border style fo a form at run time. Just call the statement changing the borderstyle of the form repeatedly for 3-4 times, and it will change the border style. I have done this using the inbuilt BorderStyle property of vb.

  4. #4
    spetnik
    Guest
    Sorry, it didnt work. I need this to create a floating/docking toolbar window like in MS-Office and VB

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Doesn't this work
    Code:
    'assuming that the initial BorderStyle was 2
    Private Sub Command1_Click()
         Form1.BorderStyle = 0
         Form1.Refresh
    End Sub
    Click the Button 3 - 4 times one after the other.

  6. #6
    spetnik
    Guest
    It does not work. In VB5, it even gives an error, and in VB6, nothing happens. Ther must be an API call 4 this!

  7. #7
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Strange, I had VB6 and it worked for me.

  8. #8
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    if you want the api to do it, here it is:


    Code:
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Const GWL_STYLE = (-16)
    
    'choices For style
    
    Const WS_SIZEBOX = &H40000 '2-sizeable
    'don't have other consts
    
    Private Sub Command1_Click()
        Dim curstyle As Long, newstyle As Long
    
        'retrieve the window style
        curstyle = GetWindowLong(Me.hwnd, GWL_STYLE)
        
        curstyle = curstyle Or WS_SIZEBOX
        'will make fixed single/fixed dialog windows sizeable
    
        'Set the New style
        newstyle = SetWindowLong(Me.hwnd, GWL_STYLE, curstyle)
        'refresh
        Me.Refresh
    End Sub
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  9. #9
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    but if you want a floating, docking toolbar, do it the windows way with a class avalible from www.vbaccelerator.com
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

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