Make a form completely borderless during runtime. (1 Viewer)

AHeyne

Registered User.
Local time
Today, 08:20
Joined
Jan 27, 2006
Messages
96
Hi.

As you know it's not possible to set the "BorderStyle"-property of a form during runtime.
But thats a kind of functionality, i need to use in my Access 2003 application.

I need to 'simulate' the value "none" during runtime, that means that there is absolutely no frame/border around the form.
Design-mode is not possible, because i need to use a MDE file.

So i dealed with the APIs and nearly got it.
But i always have had a kind of very thin 'sunken'-frame around my form.
I also played with the extended window-styles, but the result was that i got a 'raised'-frame around the form.

Over all i really got wired in my head.

Maybe someone already did that too and can post the right api-calls / styles here?

I would be really thankful, because i quit that now after hours...

Regards,
AtzeX
 

AHeyne

Registered User.
Local time
Today, 08:20
Joined
Jan 27, 2006
Messages
96
No one?
Are my requests so irregular? ;)
 

Laurentech

Registered User.
Local time
Today, 00:20
Joined
Nov 7, 2005
Messages
107
Is the form modal? That's the only time I see a border around a form that has the border set to none.

Larry
 

AHeyne

Registered User.
Local time
Today, 08:20
Joined
Jan 27, 2006
Messages
96
Hi.

Thanks for replying.

No, it isn't.

I wanted to prepare a sample for you, so i spent an hour again.
And now i got it.

Here is the code:
Code:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Any) As Long
Private Declare Function SetWindowPos Lib "user32" (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 GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)

Private Const WS_EX_CLIENTEDGE = &H200&
Private Const WS_THICKFRAME = &H40000
Private Const WS_CAPTION = &HC00000

Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOSIZE = &H1

Private Sub RemoveBorderFromForm(ByVal parLngHwnd As Long)

    Dim lngWindowStyle As Long

    lngWindowStyle = GetWindowLong(parLngHwnd, GWL_EXSTYLE)
    lngWindowStyle = lngWindowStyle And Not WS_EX_CLIENTEDGE
    Call SetWindowLong(parLngHwnd, GWL_EXSTYLE, lngWindowStyle)

    lngWindowStyle = GetWindowLong(parLngHwnd, GWL_STYLE)
    lngWindowStyle = lngWindowStyle And Not WS_THICKFRAME
    lngWindowStyle = lngWindowStyle And Not WS_CAPTION
    Call SetWindowLong(parLngHwnd, GWL_STYLE, lngWindowStyle)

    Call SetWindowPos(parLngHwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_NOSIZE)

End Sub

Regards,
AtzeX
 

Laurentech

Registered User.
Local time
Today, 00:20
Joined
Nov 7, 2005
Messages
107
Thanks for posting the code. I'll give it a try and see if it takes care of the problem I've been having with one of my forms.

Larry
 

Users who are viewing this thread

Top Bottom