Results 1 to 25 of 25

Thread: Is there any way to stop Window-Resize Animation for my Form only ?

Threaded View

  1. #10

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    VB6 Code To Remove TitleBar at Runtime

    Found it somewhere on the web. (may be in mvps.org)


    VB Code:
    1. Option Explicit
    2.  
    3. ' Win32 APIs used to toggle border styles.
    4. Private Declare Function GetWindowLong Lib "user32" _
    5.     Alias "GetWindowLongA" _
    6.         (ByVal hwnd As Long, _
    7.          ByVal nIndex As Long) As Long
    8.    
    9. Private Declare Function SetWindowPos Lib "user32" _
    10.         (ByVal hwnd As Long, _
    11.          ByVal hWndInsertAfter As Long, _
    12.          ByVal x As Long, _
    13.          ByVal y As Long, _
    14.          ByVal cx As Long, _
    15.          ByVal cy As Long, _
    16.          ByVal wFlags As Long) As Long
    17.  
    18. Private Const GWL_STYLE = (-16)
    19. Private Const WS_CAPTION = &HC00000
    20.  
    21. 'Force total pRedraw that shows new styles.
    22. Private Const SWP_FRAMECHANGED = &H20
    23. Private Const SWP_NOMOVE = &H2
    24. Private Const SWP_NOZORDER = &H4
    25. Private Const SWP_NOSIZE = &H1
    26.  
    27. '==================================================================
    28.  
    29. Private Function fStyle(mhWnd As Long, _
    30.                         Optional ByVal NewBits As Long = 0) As Long
    31.  
    32.     ' Set new style bits.
    33.     If NewBits Then
    34.         Call SetWindowLong(mhWnd, GWL_STYLE, NewBits)
    35.     End If
    36.  
    37.     ' Retrieve current style bits.
    38.     fStyle = GetWindowLong(mhWnd, GWL_STYLE)
    39.  
    40. End Function
    41.  
    42. '==================================================================
    43.  
    44. Private Sub pRedraw(mhWnd As Long)
    45.  
    46.     ' Redraw window with new style.
    47.     Const swpFlags As Long = SWP_FRAMECHANGED Or SWP_NOMOVE Or _
    48.        SWP_NOZORDER Or SWP_NOSIZE
    49.     Call SetWindowPos(mhWnd, 0, 0, 0, 0, 0, swpFlags)
    50.  
    51. End Sub
    52.  
    53. '==================================================================
    54.  
    55. Public Sub ShowTitlebar(ByVal Value As Boolean, mhWnd As Long)
    56.  
    57.     ' Set WS_CAPTION On or Off as requested.
    58.     If CBool(fStyle(mhWnd) And WS_CAPTION) And Value = False Then
    59.         'Hide the titkebar
    60.         Call fFlipBit(WS_CAPTION, Value, mhWnd)
    61.     ElseIf Not CBool(fStyle(mhWnd) And WS_CAPTION) And Value = True Then
    62.         'Show the titkebar
    63.         Call fFlipBit(WS_CAPTION, Value, mhWnd)
    64.     End If
    65.  
    66. End Sub
    67.  
    68. '==================================================================
    69.  
    70. Private Function fFlipBit(ByVal Bit As Long, _
    71.                           ByVal Value As Boolean, _
    72.                           mhWnd As Long) As Boolean
    73.  
    74.     Dim lStyle As Long
    75.     ' Retrieve current style bits.
    76.     lStyle = GetWindowLong(mhWnd, GWL_STYLE)
    77.     ' Set requested bit On or Off and Redraw.
    78.  
    79.     If Value Then
    80.         lStyle = lStyle Or Bit
    81.     Else
    82.         lStyle = lStyle And Not Bit
    83.     End If
    84.  
    85.     Call SetWindowLong(mhWnd, GWL_STYLE, lStyle)
    86.     Call pRedraw(mhWnd)
    87.     ' Return success code.
    88.     fFlipBit = (lStyle = GetWindowLong(mhWnd, GWL_STYLE))
    89.  
    90. End Function

    Edit: Someone posted this cool tip on VBF a few days ago. I couldn't find the thread.

    VB Code:
    1. Me.BorderStyle = vbBSNone
    2. [b]Me.Caption = Me.Caption[/b]
    The trick is the second statement.
    From User's point of view it doesn't change anything, but it actually forces the TitleBar to be redrawn.
    Last edited by iPrank; Jan 17th, 2007 at 02:20 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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