'Done in Excel
Private Sub SetFormStyle()
Dim lStyle As Long, hMenu As Long
'Have we got a form to set?
If mhWndForm = 0 Then Exit Sub
'Get the basic window style
lStyle = GetWindowLong(mhWndForm, GWL_STYLE)
'Build up the basic window style flags for the form
SetBit lStyle, WS_CAPTION, mbCaption
SetBit lStyle, WS_SYSMENU, mbSysMenu
SetBit lStyle, WS_THICKFRAME, mbSizeable
SetBit lStyle, WS_MINIMIZEBOX, mbMinimize
SetBit lStyle, WS_MAXIMIZEBOX, mbMaximize
'Set the basic window styles
SetWindowLong mhWndForm, GWL_STYLE, lStyle
'Get the extended window style
lStyle = GetWindowLong(mhWndForm, GWL_EXSTYLE)
'Build up and set the extended window style
SetBit lStyle, WS_EX_APPWINDOW, mbAppWindow
SetBit lStyle, WS_EX_TOOLWINDOW, mbToolWindow
SetWindowLong mhWndForm, GWL_EXSTYLE, lStyle
'Handle the close button differently
If mbCloseBtn Then
'We want it, so reset the control menu
hMenu = GetSystemMenu(mhWndForm, 1)
Else
'We don't want it, so delete it from the control menu
hMenu = GetSystemMenu(mhWndForm, 0)
DeleteMenu hMenu, SC_CLOSE, 0&
End If
'Update the window with the changes
DrawMenuBar mhWndForm
SetFocus mhWndForm
End Sub
Very good work. Ill run it and see if it works.
ReplyDeleteAwele: Thank you, the codes are not complete yet. I'll update soon and you can try the code when completed.
ReplyDelete