|
-
Sep 21st, 2000, 11:44 PM
#1
Thread Starter
Junior Member
Is there any API call that handles the windows taskbar? For instance, I would like to add a combo list box to the taskbar at startup.
-
Sep 22nd, 2000, 03:02 AM
#2
Addicted Member
Try this.
To hide/show the taskbar:
Option Explicit
Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As String, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Option Explicit
Private Sub Command1_Click()
On Error GoTo errhandler
Const SWP_HIDEWINDOW = &H80
Dim Thwnd As Long
Thwnd = FindWindow("Shell_traywnd", "")
Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
On Error GoTo errhandler
errhandler:
MsgBox "You already pressed it!"
End Sub
Private Sub Command2_Click()
Const SWP_SHOWWINDOW = &H40
Dim Thwnd As Long
Thwnd = FindWindow("Shell_traywnd", "")
Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
End Sub
And about adding the combobox to the taskbar on startup...i am guessing you would have to use the findwindow API.
Here is a example to add a extra button to the AOL window: using findwindow..and some other api calls:
Private Sub Form_Load()
Const MF_STRING = &H0&
Const MF_POPUP = &H10&
Const TPM_LEFTALIGN = &H0&
Dim aol As String
Dim a As Integer
Dim x As Integer
Dim b As Integer
Dim c As Integer
aol = FindWindow("AOL Frame25", "America Online")
a = GetMenu(aol)
x = CreatePopupMenu
b = AppendMenuByString(x, MF_POPUP And TPM_LEFTALIGN, 69, "Example PopupMenuItem ")
c = AppendMenu(a, MF_STRING Or MF_POPUP, c, "&**** Aol")
Call DrawMenuBar(aol)
End Sub
Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function CreatePopupMenu Lib "user32" () As Long
Public Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function AppendMenuByString Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
You can customize it to fit the taskbar...
But about actually making the combobox werk like a real combobox..hehe i dont know that yet. i guess it has something to do with sub classing?
"RUH ROH!"
-
Sep 26th, 2000, 07:46 PM
#3
I've been trying, and after some time I've figured out how to do it (a bit because it's not fully functional...)
Maybe this will lead you to a clue:
in a form_load or so:
Code:
Dim x As Long
Dim ret As Long
x = FindWindow("SysTabControl32", "")
ret = SetParent(Combo1.hwnd, x)
(in stead of "SysTabControl32" you might like to try these:
- Shell_TrayWnd
- ReBarWindow32
- ToolbarWindow32
- TrayNotifyWnd
)
and in a module:
Code:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Have a go...
[Edited by RobIII on 09-26-2000 at 08:49 PM]
-
Sep 27th, 2000, 11:29 AM
#4
Likewise, you can use CreateWindowEx to create the ComboBox.
Code:
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Const WS_CHILD = &H40000000
Private Const CBS_DROPDOWN = &H2&
Private Sub Form_Load()
Dim bWnd As Long, trayWnd As Long
'Get hWnd of TaskBar
trayhwnd = FindWindowEx(0, 0, "Shell_TrayWnd", vbNullString)
'Create a combobox
bWnd = CreateWindowEx(0&, "ComboBox", "Button1", WS_CHILD Or CBS_DROPDOWN, 0, 0, 64, 64, 2992, 0, App.hInstance, ByVal 0&)
ShowWindow bWnd, 1
End Sub
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
|