Results 1 to 4 of 4

Thread: VBA form border *SEMI-SOLVED*

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    VBA form border *SEMI-SOLVED*

    I posted a question in the Maths Forum and managed to solve the basic problem.
    http://www.vbforums.com/showthread.p...65#post1486865

    However, my solution was to make a macro to function like an Excel Wizard.
    The thing that I can't get right, is removing the borders on the form to
    make it look like the usual function Wizards.

    I have a feeling it is one of the things that is cut out of VB for VBA

    Have I missed something or can it be done another way?
    API?

  2. #2
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    I ran your wizard form and then I checked the "Lookup Wizard" form. They look the same, I guess I am not sure what type of effect you are looking for (I ran it on Win2K, Excel 97)

    Can you post an image of the type of wizard border you are looking for?
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  3. #3

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    hmmm, maybe Wizard is the wrong word
    This is what I am trying to achieve



  4. #4

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    Credit to Stephen Bullen for this as I learned how to do it from his formfun.zip demo
    http://www.bmsltd.co.uk/Excel/Default.htm

    Create a Class Module called cTitleBarHider and put the following code in it
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetWindowLong Lib "user32" _
    4.   Alias "GetWindowLongA" (ByVal hWnd As Long, _
    5.   ByVal nIndex As Long) As Long
    6.  
    7.  
    8. 'Windows API calls to do all the dirty work!
    9. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    10. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    11. Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
    12. Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
    13. Private Declare Function SetFocus Lib "user32" (ByVal hWnd As Long) As Long
    14.  
    15. Private Const GWL_STYLE As Long = (-16)           'The offset of a window's style
    16. Private Const WS_CAPTION As Long = &HC00000       'Style to add a titlebar
    17.  
    18. 'Constants for hide or show a window
    19. Private Const SW_SHOW As Long = 5
    20.  
    21.  
    22. 'Variables to store the various selections/options
    23. Dim hWndForm As Long, mbSizeable As Boolean, mbCaption As Boolean, mbIcon As Boolean, miModal As Integer
    24. Dim oForm As Object
    25.  
    26.  
    27. Public Property Set Form(oForm As Object)
    28.  Dim iStyle As Long
    29.  Dim hWndForm As Long
    30. ' If Val(Application.Version) < 9 Then
    31. '  'XL97
    32. '  hWndForm = FindWindow("ThunderXFrame", oForm.Caption)
    33. ' Else
    34. '  'XL2000
    35. '  hWndForm = FindWindow("ThunderDFrame", oForm.Caption)
    36. ' End If
    37.  hWndForm = FindWindow("ThunderDFrame", oForm.Caption)
    38.  iStyle = GetWindowLong(hWndForm, GWL_STYLE)
    39.  
    40. iStyle = iStyle And Not WS_CAPTION
    41.  SetWindowLong hWndForm, GWL_STYLE, iStyle
    42.  DrawMenuBar hWndForm
    43. End Property

    Then put this is in the form that you dont want to have a title bar
    VB Code:
    1. Dim oTitleBarHider As New cTitleBarHider
    2.  
    3. Private Sub UserForm_Activate()
    4.  Set oTitleBarHider.Form = Me
    5. End Sub

    Im pretty sure that does it all!
    Just need to work out how to fix the form in place in cell A1

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