Changing form-properties while running before loading the form 
Author Message
 Changing form-properties while running before loading the form

Hello,

I want to be able to change the properties of a form, such as borderstyle
and controlbox, during runtime. If it's possible I even want to change the
properties of the form while it is already loaded (visible or not). Is this
possible? If Yes, how?

Thanx...



Wed, 31 Mar 2004 22:43:50 GMT  
 Changing form-properties while running before loading the form


Quote:
> Hello,

> I want to be able to change the properties of a form, such as borderstyle
> and controlbox, during runtime. If it's possible I even want to change the
> properties of the form while it is already loaded (visible or not). Is
this
> possible? If Yes, how?

> Thanx...

Very possible:
    myform.Borderstyle =
    myform.Controlbox =


Wed, 31 Mar 2004 23:23:08 GMT  
 Changing form-properties while running before loading the form
Doesn't seem te work: when I try to change the controlbox setting
(true/false) I get the following error:
"Functions or interface marked as restricted, or the function uses an
automation type not supported in VB."
Changing the borderstyle is allowed, but doesn't do anything. No changes
occur!
Quote:
> Very possible:
>     myform.Borderstyle =
>     myform.Controlbox =



Thu, 01 Apr 2004 01:03:12 GMT  
 Changing form-properties while running before loading the form


Quote:
>Changing the borderstyle is allowed, but doesn't do anything. No changes
>occur!

Wouter, from the VB6 Help File...

ControlBox Property

Returns or sets a value indicating whether a Control-menu box is
displayed on a form at run time. Read-only at run time.

Regards.

--
Martin Trump



Thu, 01 Apr 2004 01:16:55 GMT  
 Changing form-properties while running before loading the form
You may find what you want in this.

Add a multi line textbox, a normal textbox, and two command buttons

Option Explicit

Private Const GWL_STYLE = (-16)

' Window styles
Private Const WS_OVERLAPPED = &H0&
Private Const WS_POPUP = &H80000000
Private Const WS_CHILD = &H40000000
Private Const WS_MINIMIZE = &H20000000
Private Const WS_VISIBLE = &H10000000
Private Const WS_DISABLED = &H8000000
Private Const WS_CLIPSIBLINGS = &H4000000
Private Const WS_CLIPCHILDREN = &H2000000
Private Const WS_MAXIMIZE = &H1000000
Private Const WS_CAPTION = &HC00000                  '  WS_BORDER Or
WS_DLGFRAME
Private Const WS_BORDER = &H800000
Private Const WS_DLGFRAME = &H400000
Private Const WS_VSCROLL = &H200000
Private Const WS_HSCROLL = &H100000
Private Const WS_SYSMENU = &H80000
Private Const WS_THICKFRAME = &H40000
Private Const WS_GROUP = &H20000
Private Const WS_TABSTOP = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_TILED = WS_OVERLAPPED
Private Const WS_ICONIC = WS_MINIMIZE
Private Const WS_SIZEBOX = WS_THICKFRAME
Private Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or
WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
Private Const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
Private Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Private Const WS_CHILDWINDOW = (WS_CHILD)

Private Const ES_AUTOHSCROLL = &H80&
Private Const ES_AUTOVSCROLL = &H40&
Private Const ES_CENTER = &H1&
Private Const ES_CONTINUOUS = (&H80000000)
Private Const ES_DISABLENOSCROLL = &H2000
Private Const ES_DISPLAY_REQUIRED = (&H2)
Private Const ES_EX_NOCALLOLEINIT = &H1000000
Private Const ES_LEFT = &H0&
Private Const ES_LOWERCASE = &H10&
Private Const ES_MULTILINE = &H4&
Private Const ES_NOHIDESEL = &H100&
Private Const ES_NOIME = &H80000
Private Const ES_NOOLEDRAGDROP = &H8
Private Const ES_NUMBER = &H2000&
Private Const ES_OEMCONVERT = &H400&
Private Const ES_PASSWORD = &H20&
Private Const ES_READONLY = &H800&
Private Const ES_RIGHT = &H2&
Private Const ES_SAVESEL = &H8000
Private Const ES_SELECTIONBAR = &H1000000
Private Const ES_SELFIME = &H40000
Private Const ES_SUNKEN = &H4000
Private Const ES_SYSTEM_REQUIRED = (&H1)
Private Const ES_UPPERCASE = &H8&
Private Const ES_USER_PRESENT = (&H4)
Private Const ES_VERTICAL = &H400000
Private Const ES_WANTRETURN = &H1000&
Private Const ESB_DISABLE_BOTH = &H3
Private Const ESB_DISABLE_DOWN = &H2
Private Const ESB_DISABLE_LEFT = &H1
Private Const ESB_DISABLE_LTUP = ESB_DISABLE_LEFT
Private Const ESB_DISABLE_RIGHT = &H2
Private Const ESB_DISABLE_RTDN = ESB_DISABLE_RIGHT
Private Const ESB_DISABLE_UP = &H1
Private Const ESB_ENABLE_BOTH = &H0

Private Const SB_VERT = 1
Private Const SB_BOTH = 3
Private Const SB_HORZ = 0

Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As
Long, ByVal wBar As Long, ByVal bShow 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

Private Declare Function GetWindowLong Lib "user32" _
        Alias "GetWindowLongA" _
        (ByVal hwnd As Long, _
         ByVal nIndex As Long) As Long

Private Declare Function UpdateWindow Lib "user32" _
                 (ByVal hwnd As Long) As Long

Private Sub Command1_Click()
    Dim L&, S&, O As Object

    Set O = Me

    L = GetWindowLong(O.hwnd, GWL_STYLE)

    'S = WS_MINIMIZEBOX
    'S = WS_MAXIMIZEBOX
    'S = WS_CHILD
    S = WS_SYSMENU
    'S = WS_THICKFRAME
    'S = WS_DLGFRAME
    'S = WS_VSCROLL
    'S = WS_HSCROLL
    'S = WS_CAPTION
    'S = WS_VISIBLE
    'S = WS_BORDER
    'S = WS_DISABLED

    'S = ES_NUMBER      ' this works
    'S = ES_MULTILINE   ' does not work
    'S = ES_UPPERCASE   ' this works
    'S = ES_VERTICAL    ' removes border - unsatisfactory
    'S = ES_SUNKEN      ' does nothing
    'S = ES_RIGHT       ' does nothing
    'S = ES_SELECTIONBAR ' ???
    'S = ES_CENTER      ' does nothing
    'S = ES_PASSWORD    ' does nothing
    'S = ES_READONLY    ' does nothing
    'S = ES_DISPLAY_REQUIRED  ' ???
    'S = ES_NOIME       ' ???
    'S = ES_SYSTEM_REQUIRED ' ???
    'S = ES_NOOLEDRAGDROP ' ???
    'S = WS_BORDER Or ES_VERTICAL  ' no good
    'S = ES_USER_PRESENT
    'S = ES_WANTRETURN

    If (L And S) Then
       L = L And (Not S)
    Else
       L = L Or S
    End If

    Call SetWindowLong(O.hwnd, GWL_STYLE, L&)
    'DoEvents
    UpdateWindow O.hwnd
    O.Refresh
    Me.Visible = False
    'DoEvents
    Me.Visible = True
End Sub

Private Sub Command2_Click()
    Static Flag As Boolean, Q&

    Q = 0
    If Flag Then Q = 1
    Flag = Not Flag

    Call ShowScrollBar(Text1.hwnd, SB_HORZ, Q)
End Sub



Quote:
>Hello,

>I want to be able to change the properties of a form, such as borderstyle
>and controlbox, during runtime. If it's possible I even want to change the
>properties of the form while it is already loaded (visible or not). Is this
>possible? If Yes, how?

>Thanx...



Wed, 07 Apr 2004 16:10:26 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Changing Form's BorderStyle property at run time but before form is loaded

2. Run-Time form loading - form name retrieved from database

3. how to change properties of the main form from a another form

4. load another form form one form

5. Form Load Method and CenterParent property

6. changing the sourceobject of subform when the form and subform are loaded

7. Loading a form at run-time

8. Loading a form at run-time

9. Changing SSTab-tab in Form Load

10. Running a routine after form has loaded

11. Help: Loading forms at run-time.

12. Run-time error '31037': Error load form file

 

 
Powered by phpBB® Forum Software