cyberwarpy
May 2nd, 2001, 02:49 AM
When the border style of a Form is set to "None" or "Fixed ToolWindow", the Icon for the Form on the Taskbar disappears. How do you make it appear, in this border style...? :confused:
Tygur
May 3rd, 2001, 04:02 AM
If you want the icon to stay, you have to convert the form to the desired borderstyle using the api. When you do this, the BorderStyle property will not change, but the form will appear to be in the borderstyle that you want. I don't know how to change the form to a toolwindow, or if it is even possible, but if you want to change the borderstyle to zero, here's the code:
'These are the API declarations
'Put this in the area above the rest of the form code (the General Declarations area)
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 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 Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_BORDER = &H800000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_DLGFRAME = &H400000
Private Const WS_THICKFRAME = &H40000
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
'This is the code to take out the border
'You probably want it in Form_Load
Dim lStyle As Long
lStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
lStyle = lStyle And Not (WS_BORDER Or WS_DLGFRAME Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX Or WS_THICKFRAME)
Call SetWindowLong(Me.hwnd, GWL_STYLE, lStyle)
SetWindowPos Me.hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER
The icon will stay in the taskbar and the form will appear to have a borderstyle of zero. This is especially useful if you want the form to have a menu but no titlebar.