-
Nov 29th, 2004, 10:24 AM
#1
Thread Starter
PowerPoster
SetParent problem [resolved]
Hello everyone.
I'm working on a windows extension that adds a "Minimize to tray" button to each window. I got everything to work but there's one problem remaining:
For the button I use a UserControl because of several reasons. However I found out when using SetParent( handle, 0 ) a tab in the taskbar appears. Try it by creating a new project, adding a PictureBox and using SetParent with 0 as parent handle.
Now the question is how can I avoid this taskbar tab? Thanks for hints,
Fox
Last edited by Fox; Dec 1st, 2004 at 08:49 AM.
-
Nov 29th, 2004, 11:52 AM
#2
Hyperactive Member
You could use the SetParent as you are, then SetWindowAttributes (I think that's the right API) and tell the object not to display in the task bar.
"I don't want to live alone until I'm married" - M.M.R.P
-
Nov 29th, 2004, 12:23 PM
#3
Thread Starter
PowerPoster
Yes I already tried this but it doesn't work. The code to hide the taskbar button works on other windows but not on the one I changed the parent to 0...
-
Nov 29th, 2004, 12:52 PM
#4
Hyperactive Member
have you tried setting the desktop winodw as the parent?
"I don't want to live alone until I'm married" - M.M.R.P
-
Nov 29th, 2004, 01:30 PM
#5
Thread Starter
PowerPoster
Yes, this also creates one more tab in the taskbar...
-
Nov 30th, 2004, 08:58 PM
#6
Software Eng.
Apply the WS_EX_TOOLWINDOW extended style to your window. This will trick windows into thinking it's a tool window, and thus remove it from the task bar.
Here's a quick example
VB Code:
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Const GWL_EXSTYLE = -20
Private Const WS_EX_TOOLWINDOW As Long = &H80&
Private Sub Command1_Click()
' make the picturebox a top-level parent window
Dim lstyle As Long
'apply the tool window extended style
lstyle = GetWindowLong(Picture1.hwnd, GWL_EXSTYLE)
lstyle = lstyle Or WS_EX_TOOLWINDOW
SetWindowLong Picture1.hwnd, GWL_EXSTYLE, lstyle
SetParent Picture1.hwnd, 0
End Sub
Private Sub Picture1_Click()
'close the form
Unload Me
End Sub
-
Dec 1st, 2004, 04:15 AM
#7
Thread Starter
PowerPoster
Thanks alot, that works
-
Dec 1st, 2004, 09:44 AM
#8
Hyperactive Member
When you finish this program Fox could you please post it for download? This type of project has been on the back of my mind for months now but I adhore subclassing.
"I don't want to live alone until I'm married" - M.M.R.P
-
Dec 1st, 2004, 10:41 AM
#9
Thread Starter
PowerPoster
Of course. It's not just a minimize to tray, it's a whole windows manager suite (thus called "WinMan"). You can show/hide/rename/set alpha/whatever on each window. Also you can apply bots to automate those actions (eg. "Set ICQ's alpha to 20% when it's running").
This is the 2nd edition btw, the original code was written in 2001 - even it's crappy coded ever since, it's one of the most-used tools I got.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|