Results 1 to 8 of 8

Thread: Userform sizing

  1. #1
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Userform sizing

    I'm kinda use to using standard Visual Basic whereas you can size your userform down to what ever size you want and/or not even show the title bar. Is there a way or a trick to getting the userforms in AutoCAD VBA to do this or at least make them size down smaller than they are? The userform is too wide for what I'm doing and it won't even let me type a small number in the properties box for the form's width. It only goes down to 92.25 width. Ideas? Tricks o' the trade?

  2. #2
    100 Club
    Join Date
    2000-11
    Location
    Adelaide, South Australia
    Posts
    116
    Login to Give a bone
    0

    Default Re: Userform sizing

    Quote Originally Posted by Coolmo
    I'm kinda use to using standard Visual Basic whereas you can size your userform down to what ever size you want and/or not even show the title bar. Is there a way or a trick to getting the userforms in AutoCAD VBA to do this or at least make them size down smaller than they are? The userform is too wide for what I'm doing and it won't even let me type a small number in the properties box for the form's width. It only goes down to 92.25 width. Ideas? Tricks o' the trade?
    I don't know about the width issue but for disbling the close box or removing the titlebar completely I use the following.

    Code:
    Option Explicit
    Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
    Private Declare Function GetSystemMenu Lib "user32.dll" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function RemoveMenu Lib "user32.dll" (ByVal hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long) As Long
    Private Declare Function DrawMenuBar Lib "user32.dll" (ByVal hwnd As Long) As Long
    Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    
    Public Sub DisableClose()
    Dim hwnd As Long
    Dim hMenu As Long
    hwnd = GetActiveWindow()
    hMenu = GetSystemMenu(hwnd, 0)
    Call RemoveMenu(hMenu, 6, &H400)
    Call RemoveMenu(hMenu, 5, &H400)
    Call DrawMenuBar(hwnd)
    End Sub
    
    Public Sub Remove()
    Dim hwnd As Long
    Dim dwNewLong As Long
    hwnd = GetActiveWindow()
    dwNewLong = GetWindowLong(hwnd, -16)
    dwNewLong = dwNewLong And Not &HC00000
    Call SetWindowLong(hwnd, -16, dwNewLong)
    DrawMenuBar hwnd
    End Sub
    Regards - Nathan

  3. #3
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Userform sizing

    Quote Originally Posted by Coolmo
    I'm kinda use to using standard Visual Basic whereas you can size your userform down to what ever size you want and/or not even show the title bar. Is there a way or a trick to getting the userforms in AutoCAD VBA to do this or at least make them size down smaller than they are?
    No tricks that I am aware of. VBA forms can be resized in the same manner

    Quote Originally Posted by Coolmo
    The userform is too wide for what I'm doing and it won't even let me type a small number in the properties box for the form's width. It only goes down to 92.25 width.
    This works fine here

    Code:
     UserForm1.Width = 40
     UserForm1.Height = 60
    R.K. McSwain | CAD Panacea |

  4. #4
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Userform sizing

    You must have magic forms or something or I'm just doing something wrong. I can't physically size it below 92.25 and when I use Userform1.Width = 40 (or anything below 92.25) it just sizes it back to 92.25. I've started with a new userform, set the caption of the form to "" (nothing) just in case the text was making it a certain size, made the form's width a least 200 and then made it so when the form is clicked, it sets the width of the form down to 40. When I then click the form, it sizes down to 92.25 again. Could my resolution be affecting something? Is there some sort of "Twip" setting or switch I can toggle? Why does your form size down and mine doesn't? It's just a standard userform.

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Userform sizing

    Quote Originally Posted by Coolmo
    You must have magic forms or something or I'm just doing something wrong. I can't physically size it below 92.25 and when I use Userform1.Width = 40 (or anything below 92.25) it just sizes it back to 92.25.
    My apologies. The code ran fine of course, but I never bothered to check the form width after resizing. I just saw that it got very small. Actually, mine will not go any smaller than 84 points. Not sure why you get 92.25. I have noticed now that I cannot even resize it manually smaller than 84 at design-time.

    The 84 number is confirmed by these posts:

    http://groups.google.com/group/micro...379239b?hl=en&

    http://visualbasic.ittoolbox.com/gro...b-vba-l/205313

    ...but maybe you are getting 92.25 based on some Windows setting?
    R.K. McSwain | CAD Panacea |

  6. #6
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Userform sizing

    That's the same thing I'm getting. It's weird too because stand alone Visual Basic will let you turn off the top bar and size the userform down to virtually nothing. I guess VBA just doesn't do this because it's meant to run inside of other applications... hence the name

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,396
    Login to Give a bone
    0

    Default Re: Userform sizing

    VBA uses a different Forms object model than does VB.
    C:> ED WORKING....

  8. #8
    100 Club
    Join Date
    2000-11
    Location
    Adelaide, South Australia
    Posts
    116
    Login to Give a bone
    0

    Default Re: Userform sizing

    Quote Originally Posted by Coolmo
    I'm kinda use to using standard Visual Basic whereas you can size your userform down to what ever size you want and/or not even show the title bar. Is there a way or a trick to getting the userforms in AutoCAD VBA to do this or at least make them size down smaller than they are? The userform is too wide for what I'm doing and it won't even let me type a small number in the properties box for the form's width. It only goes down to 92.25 width. Ideas? Tricks o' the trade?
    Here is my solution using the Windows API. Note the measurements are pixels where as VBA uses twips.
    Code:
    Option Explicit
    Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
    Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Private Const HWND_TOPMOST = -1
    Private Const SWP_NOMOVE = &H2
    
    Private Sub UserForm_Click()
    Dim hwnd As Long
    Dim lngWidth As Long
    Dim lngHeight As Long
    lngWidth = 400
    lngHeight = 200
    hwnd = GetActiveWindow()
    SetWindowPos hwnd, HWND_TOPMOST, 0, 0, lngWidth, lngHeight, SWP_NOMOVE
    End Sub

    Regards - Nathan

Similar Threads

  1. Parameters from Userform
    By CADfunk MC in forum VBA/COM Interop
    Replies: 2
    Last Post: 2010-04-26, 06:25 PM
  2. Unload a userform
    By mikeosborne in forum VBA/COM Interop
    Replies: 2
    Last Post: 2009-09-28, 08:35 PM
  3. All I want is a Userform to show..
    By Coolmo in forum Dot Net API
    Replies: 5
    Last Post: 2009-07-23, 02:03 PM
  4. VBA userform in excel
    By Streng in forum VBA/COM Interop
    Replies: 3
    Last Post: 2009-02-17, 07:02 PM
  5. Userform limit
    By Coolmo in forum VBA/COM Interop
    Replies: 8
    Last Post: 2007-06-22, 06:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •