Results 1 to 9 of 9

Thread: borderless form help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    2

    Arrow borderless form help

    I have a form with no border (and has to stay that way). But I want to be able to move the form around by clicking on it and dragging it around or something, and it should also show up in the taskbar, which it doesn't when borderstyle = 0.
    Thanks.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: borderless form help

    There isn't any conventional way to accomplish this task so use of some api will be in order:
    VB Code:
    1. Private Const GWL_STYLE = (-16)
    2. Private Const WS_SYSMENU = &H80000
    3. Private Const WS_MINIMIZEBOX = &H20000
    4. Private Const WM_NCLBUTTONDOWN = &HA1
    5. Private Const HTCAPTION = 2
    6.  
    7. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    8. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    9.  
    10. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
    11.                         (ByVal hwnd As Long, ByVal wMsg As Long, _
    12.                          ByVal wParam As Long, ByVal lParam As Long) As Long
    13. Private Declare Function ReleaseCapture Lib "user32" () As Long
    14.  
    15. Private Sub Form_Load()
    16. '=======================
    17. Dim lStyle As Long
    18.  
    19.     'ensure taskbar icon visibility
    20.     lStyle = GetWindowLong(hwnd, GWL_STYLE) Or WS_SYSMENU Or WS_MINIMIZEBOX
    21.     SetWindowLong hwnd, GWL_STYLE, lStyle
    22.  
    23. End Sub
    24.  
    25. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    26.     If Button = vbLeftButton Then
    27.         ReleaseCapture
    28.         SendMessageLong Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    29.     End If
    30. End Sub

  3. #3

    Re: borderless form help

    Thanks Works Great!

  4. #4

  5. #5
    Junior Member
    Join Date
    Jul 2011
    Posts
    31

    Re: borderless form help

    Can you help me how to put this in my form?

  6. #6

  7. #7
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: borderless form help

    Rhino,
    There isn't any conventional way to accomplish this task so use of some api will be in order:
    just in curious i m asking, is this method doing the right job?
    Code:
    Dim x1 As Single, y1 As Single
    
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        x1 = X
        y1 = Y
    End If
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        Me.Left = Me.Left - (x1 - X)
        Me.Top = Me.Top - (y1 - Y)
    End If
    End Sub
    and we can chage the ShowInTaskBar property at design time according to the need,
    am i right rhino?

    edited: just code changed abt left button click
    Last edited by seenu_1st; Jul 24th, 2011 at 10:37 PM.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  8. #8
    New Member
    Join Date
    Jul 2011
    Location
    varies from time to time
    Posts
    9

    Re: borderless form help

    Hey Seenu_1st,

    You are right and I've been using this code since last three years... Me and my friend made it on our own The problem with this code is that the form is always visible while moving (even if you have a theme that show only borders while moving a window). The ShowInTaskbar can be set to true in design time but it won't be able to minimize/restore/close/maximize as a normal program in taskbar does... Like if you click on it's taskbar icon, it is minimized and if you right click, you find various options (close/maximize, etc.)

  9. #9
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: borderless form help

    ATH, thanks for the info, so the diff is taskbar proprties.
    Rhino, i got it.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


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