Mirage Source
Borderstyle.. - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Borderstyle.. (/showthread.php?tid=169)



Borderstyle.. - Matt - 05-07-2006

Shouldn't this work?

frmMain.BorderStyle = 2

If I call that in a form load or something?
Cause, it won't.

No border when the form loads.

(Note: The form is set to have no border.)


- Robin - 06-07-2006

Heh. I tried that so that people who turn fullscreen off don't have a border, but it didn't work for me either Sad


- Minatours - 06-07-2006

The borderstyle property is read only at run time so you cant change it that easily.

I searched and found a sample project Change_BorderStyle_Demo.zip, might help abit.

The website is here.


- Dr. Spoon - 06-07-2006

we have obtained a working module for this..
which i have personally tested
it seems to be in proper order and does exactly what we want it to do
if advocate doesn't mind i can post a link to the simple module here
just to share it..


- GodSentDeath - 06-07-2006

Using the code Minatours posted I managed to change the code to allow changing between Borderstyle 1-5 without problems.

Put this code into any module:
Code:
Option Explicit
Private Const GWL_STYLE As Long = (-16&)
Private Const GWL_EXSTYLE As Long = (-20&)
Private Const WS_THICKFRAME As Long = &H40000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000

Private Const WS_EX_TOOLWINDOW As Long = &H80&

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd&, ByVal nIndex&) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&) As Long
    

' SetWindowPos Flags
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOREDRAW = &H8
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_FRAMECHANGED = &H20        '  The frame changed: send WM_NCCALCSIZE
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_NOCOPYBITS = &H100
Private Const SWP_NOOWNERZORDER = &H200      '  Don't do owner Z ordering

Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER

' SetWindowPos() hwndInsertAfter values
Private Const HWND_TOP = 0
Private Const HWND_BOTTOM = 1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd&, ByVal hWndInsertAfter&, ByVal x&, ByVal y&, ByVal cx&, ByVal cy&, ByVal wFlags&) As Long


Public Sub ChangeBorderStyle(TheForm As Form, Style As Byte)
Dim bToggleStyle As Boolean, bToggleExStyle As Boolean, cStyle As Byte
    
    'This makes sure the selected style is within acceptable range
    If Style > 5 Or Style < 0 Then Style = TheForm.BorderStyle
    
    cStyle = TheForm.BorderStyle
    TheForm.BorderStyle = Style
    
    'Checks the current BorderStyle and changes the variables to comply with selected style
    If Style = 0 Then
        'Don't know yet >_>...
    ElseIf Style = 1 Then
        If cStyle = 2 Then
            bToggleStyle = True
        ElseIf cStyle = 3 Then
            bToggleStyle = False
        ElseIf cStyle = 4 Then
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = True
            bToggleExStyle = True
        End If
    ElseIf Style = 2 Then
        If cStyle = 1 Then
            bToggleStyle = True
            bToggleExStyle = False
        ElseIf cStyle = 3 Then
            bToggleStyle = True
        ElseIf cStyle = 4 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = False
            bToggleExStyle = True
        End If
    ElseIf Style = 3 Then
        If cStyle = 1 Then
            bToggleStyle = False
        ElseIf cStyle = 2 Then
            bToggleStyle = True
        ElseIf cStyle = 4 Then
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = True
            bToggleExStyle = True
        End If
    ElseIf Style = 4 Then
        If cStyle = 1 Then
            bToggleExStyle = True
        ElseIf cStyle = 2 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 3 Then
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = True
            bToggleExStyle = False
        End If
    Else
        If cStyle = 1 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 2 Then
            bToggleExStyle = True
        ElseIf cStyle = 3 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 4 Then
            bToggleStyle = True
            bToggleExStyle = False
        End If
    End If
    
    If bToggleStyle Then 'Toggles between Fixed and Sizeable
        Call SetWindowLong(TheForm.hWnd, GWL_STYLE, GetWindowLong(TheForm.hWnd, GWL_STYLE) Xor (WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX))
    End If
    
    If bToggleExStyle Then 'Toggles between ToolWindow and Regular Window
        Call SetWindowLong(TheForm.hWnd, GWL_EXSTYLE, GetWindowLong(TheForm.hWnd, GWL_EXSTYLE) Xor WS_EX_TOOLWINDOW)
    End If

    Call SetWindowPos(TheForm.hWnd, 0&, 0&, 0&, 0&, 0&, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED)
End Sub

Example of using this code:
Code:
ChangeBorderStyle frmChangeBorderStyle, 1
frmChangeBorderStyle is the form that I'm changing the Border Style.
1 is the style number.

Probably not the best way or code, but it works Smile


- Minatours - 07-07-2006

Ace, knew someone would use it Tongue


- Misunderstood - 08-07-2006

Why do you want to do this?


- Tosuxo - 08-07-2006

Misunderstood Wrote:Why do you want to do this?

ahhh but the real question is.... "why not?" Tongue


- Misunderstood - 08-07-2006

... :!:


- Matt - 08-07-2006

We want to add the border back when a player chooses windowed mode, you seen how it was when I sent you the client. Lol. It's annoying not being able to move the client around.


- Misunderstood - 08-07-2006

there are other ways to move the client around, you just need to implement an api.


- Matt - 08-07-2006

We'd rather have the default border.