Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form's TaskBar 1

Status
Not open for further replies.

svagelis

Programmer
May 2, 2001
121
GR
I have a menu in my main form and from there i call some other forms. The point is that i dont want those forms to display in the taskbar so i put showintaskbar property to false. The problem then is that then i switch to an other application an then back i see the start menu form and not the one i was before.Also when i display a msgbox through my form which is set to showintaskbar=false, the form disapears and when msgbox is off it appears again.
Do you know that the problem is?
Thanks
 
I see you left this message nearly a year ago, with no response.

I too have been struggling with this problem for a long time. The msgbox issue is documented in a Microsoft KBase article; I suspect both problems are related. Making all forms modal seems to solve the problem but that's a headache I'd rather not deal with.

In the months since you've posted, have you come up with any solution?
 
A good practice to get into is setting the properties while the code is running. There are tons of events to choose from.
Try putting showintaskbar=false
in form events like GotFocus,LostFocus
Should work
--Sunr¿se

 
Actually Showintaskbar is read-only at run time; it can only be set at design time (though there is a Win API function that will allow it to be set at runtime, FYI).

However, in this case, that isn't the issue. Showintaskbar is set to false. The problem is that when:

1. Showintaskbar=false;
2. The form is *not* modal;
3. The form is the second form shown (with another form behind it); and
4. The user switches to another application--

Then when the user switches back to the app, the second form is *behind* the first form. Since it doesn't show in the taskbar, there's no way to bring it back!

A similar problem exists when calling up a msgbox from a showintaskbar=false, nonmodal form. Microsoft has documented this problem, without a very practical workaround. Since the symptoms are so similar I suspect it's caused by the same issue.

If anyone has come across this problem and resolved it I would appreciate hearing about it!

ELanger
 
I've managed to solve the problem...though my problem encountered was a different but similar case..
My problem was to have only one "application taskbar window" with the focus despite having a focused seondary form displayed outside the main window in the desktop.

To tackle the problem, the Main Window must be set as a child(NOT MDI CHILD) to a Invisible Window.
Afterwhich, all secondary forms are to be set the child as the Main Window.

To set the child to a invisible window, the Setwindowlong function declared in the user32.dll must be used with the parent arguement set as 0&. A window style of WS_POPUPWINDOW must also be set...

I've tested the solution against the 9x/Me/NT/2000 platform, and it works!

create 2 forms...Form1 & Form2
place a command button on each of the form
add a module to the project and place the code as follows..

'Place this in a module file **************************

Private Const GWL_HWNDPARENT As Long = (-8&)
Private Const WS_BORDER = &H800000
Private Const WS_POPUP = &H80000000
Private Const WS_SYSMENU = &H80000
Private Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&) As Long

Public Sub SetOwner(ByVal bSetOrRestore As Boolean, ByVal hParent&, ByVal hMe&)

If bSetOrRestore Then
SetWindowLong hMe, GWL_HWNDPARENT Or -16, hParent Or WS_POPUPWINDOW
'WS_TILEDWINDOW is the same as WS_OVERLAPPEDWINDOW
'WS_POPUP has the same effect as the 2 styles
ElseIf bSetOrRestore = False Then
SetWindowLong hMe, GWL_HWNDPARENT, 0&
End If

End Sub
'end of Declaration of the module******************

'Declaration for form1 ****************************
Private Sub Command1_Click()
Form2.Show 1, Me
End Sub

Private Sub Form_Load()
SetOwner True, 0&, Me.hwnd
End Sub
'End of Declaration for form1 ****************************


'Declaration for form2 ***********************************
Private Sub Command1_Click()
MsgBox "Form2 does not hide behind Form1 anymore"
End Sub

Private Sub Form_Load()
SetOwner True, Form1.hwnd, Me.hwnd
End Sub

Private Sub Form_Unload(Cancel As Integer)
SetOwner False, Form1.hwnd, Me.hwnd
End Sub
'End of declaration **************************************

David Yang
 
The Secondary form (form2) should idealy have a Fixed Dialog Box Style.. as minimizing the secondary form will produce undesirable effects (the minimized form will be ONTOP of the taskbar and not in the taskbar...)

it is infact that all secondary forms in Windows are all Fixed dialog boxes..i'm not sure if u guys noticed but every option or about window that you open in an application has a fixed width which you can't resize or minimize...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top