Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hide Top-Level Form Taskbar button
Message
 
 
To
10/07/2001 03:22:29
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00528500
Message ID:
00528536
Views:
22
>I am attempting to create a top-level form that still has it's caption/title bar but does not appear in the windows taskbar.
>
>I don't want to use Titlebar=0 because it removes the caption and title bar of the form but I want the same effect. I found an API and tons of VB examples but I don't know how to translate it to FoxPro. Here's the VB code. Can anyone help to translate it to FoxPro?
>
>*** VB Code for hiding Taskbar Buttons for forms
>
>Option Explicit
>Public Declare Function ShowWindow Lib "user32" _
>(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
>
>Public Declare Function SetWindowLong Lib "user32" _
>Alias "SetWindowLongA" (ByVal hwnd As Long, _
>ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
>
>Declare Function GetWindowLong Lib "user32" Alias _
>"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex
>As Long) _
>As Long
>
>'**********************************
>'** Constant Definitions:
>Public Const WS_EX_APPWINDOW = &H40000
>Public Const SW_HIDE = 0
>Public Const SW_SHOW = 5
>Public Const GWL_EXSTYLE = (-20)
>
>Public Sub ToggleTaskbarButton(hwnd As Long)
>Dim lCurrent As Long
>Dim lAppWin As Long
>
>lCurrent = GetWindowLong(hwnd, GWL_EXSTYLE)
>
>If lCurrent And WS_EX_APPWINDOW Then
> lAppWin = lCurrent And (Not WS_EX_APPWINDOW)
>Else
> lAppWin = lCurrent Or WS_EX_APPWINDOW
>End If
>
>ShowWindow hwnd, SW_HIDE
>SetWindowLong hwnd, GWL_EXSTYLE, lAppWin
>ShowWindow hwnd, SW_SHOW
>
>End Sub
Program called ToggleTaskbarButton
lparameter thwnd
**********************************
**  Constant Definitions:
#define WS_EX_APPWINDOW  0x40000
#define SW_HIDE  0
#define SW_SHOW  5
#define GWL_EXSTYLE -20

Declare integer ShowWindow in "user32" integer hwnd, integer nCmdShow
Declare integer SetWindowLong in "user32" integer hwnd, integer nIndex, integer dwNewLong
Declare integer GetWindowLong in "user32" integer hwnd, integer nIndex


local lCurrent, lAppWin

lCurrent = GetWindowLong(thwnd, GWL_EXSTYLE)

* Use Bitwise functions in VFP instead of simple And/Or in VB
If BitAnd(lCurrent,WS_EX_APPWINDOW) = WS_EX_APPWINDOW Then
    * take out WS_EX_APPWINDOW attribute if it exists
    lAppWin = BitXOr(lCurrent,WS_EX_APPWINDOW)
Else
    * add WS_EX_APPWINDOW attribute
    lAppWin = BitOr(lCurrent,WS_EX_APPWINDOW)
EndIf

ShowWindow(thwnd, SW_HIDE)
SetWindowLong(thwnd, GWL_EXSTYLE, lAppWin)
ShowWindow(thwnd, SW_SHOW)
You need to pass in the window handle to the form. You can use Foxtools to get this or use the API function FindWindow (documented in the WinAPI section).

As far as toggling the appearance in the taskbar, I don't think this works. This flag is used to force a form to display in the taskbar if it otherwise wouldn't. It does not prevent a form from displaying there if the default behavior is to do so. By default, top-level forms (windows) having the Windows Desktop as its owner displays in the taskbar.

FWIW, there is a new property of forms in VFP 7 that gives you the ability to configure if you want the form to show in the taskbar or not. Wait a few weeks. :-)

IAC, HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform