News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Startbar Programming

Started by Retsim_X, June 13, 2007, 01:18:59 AM

Previous topic - Next topic

Retsim_X

hello

i have seen in a few new windows and google updates of late, that have the ability to add a custom skinned window to the start menu. for example the latest media player, sets up a little window right on the task bar to the left of the shell tray, that allows the user to just click any butons to control the media player.

google also is able to do the same thing and has added a google search bar to my startbar.

any ideas about how this is acheived? it would be great to play with this.

thanks

Rx

donkey

This is a fairly easy thing to do using Shell_NotifyIcon, for example for playback controls you might try something like this...

AddTaskBarButton proc
LOCAL NID :NOTIFYICONDATA2

invoke ShowWindow,hDlg,SW_HIDE


invoke LoadIcon,hInst,ICO_APPICON

mov NID.hIcon,eax
mov NID.cbSize,SIZEOF NOTIFYICONDATA
mov eax,hDlg
mov NID.hwnd,eax
mov NID.uID,5
mov NID.uFlags,NIF_ICON or NIF_MESSAGE or NIF_TIP
mov NID.uCallbackMessage,WM_USER + 27
invoke LoadString,hInst,5014,ADDR NID.szTip,SIZEOF NID.szTip
invoke Shell_NotifyIcon,NIM_ADD,ADDR NID

.IF eax == 0
invoke RemoveTaskBarButton
invoke ShowWindow,hDlg,SW_SHOW
ret
.endif

invoke LoadIcon,hInst,ICO_TRAYPREV

mov NID.hIcon,eax
mov NID.cbSize,SIZEOF NOTIFYICONDATA
mov eax,hDlg
mov NID.hwnd,eax
mov NID.uID,4
mov NID.uFlags,NIF_ICON or NIF_MESSAGE or NIF_TIP
mov NID.uCallbackMessage,WM_USER + 27
invoke LoadString,hInst,IDC_PREV,ADDR NID.szTip,SIZEOF NID.szTip
invoke Shell_NotifyIcon,NIM_ADD,ADDR NID

.IF eax == 0
invoke RemoveTaskBarButton
invoke ShowWindow,hDlg,SW_SHOW
ret
.endif

invoke LoadIcon,hInst,ICO_TRAYPAUSE

mov NID.hIcon,eax
mov NID.cbSize,SIZEOF NOTIFYICONDATA
mov eax,hDlg
mov NID.hwnd,eax
mov NID.uID,3
mov NID.uFlags,NIF_ICON or NIF_MESSAGE or NIF_TIP
mov NID.uCallbackMessage,WM_USER + 27
invoke LoadString,hInst,IDC_PAUSE,ADDR NID.szTip,SIZEOF NID.szTip
invoke Shell_NotifyIcon,NIM_ADD,ADDR NID

.IF eax == 0
invoke RemoveTaskBarButton
invoke ShowWindow,hDlg,SW_SHOW
ret
.endif

invoke LoadIcon,hInst,ICO_TRAYPLAY

mov NID.hIcon,eax
mov NID.cbSize,SIZEOF NOTIFYICONDATA
mov eax,hDlg
mov NID.hwnd,eax
mov NID.uID,6
mov NID.uFlags,NIF_ICON or NIF_MESSAGE or NIF_TIP
mov NID.uCallbackMessage,WM_USER + 27
invoke LoadString,hInst,IDC_PLAY,ADDR NID.szTip,SIZEOF NID.szTip
invoke Shell_NotifyIcon,NIM_ADD,ADDR NID

.IF eax == 0
invoke RemoveTaskBarButton
invoke ShowWindow,hDlg,SW_SHOW
ret
.endif

invoke LoadIcon,hInst,ICO_TRAYSTOP

mov NID.hIcon,eax
mov NID.cbSize,SIZEOF NOTIFYICONDATA
mov eax,hDlg
mov NID.hwnd,eax
mov NID.uID,2
mov NID.uFlags,NIF_ICON or NIF_MESSAGE or NIF_TIP
mov NID.uCallbackMessage,WM_USER + 27
invoke LoadString,hInst,IDC_STOP,ADDR NID.szTip,SIZEOF NID.szTip
invoke Shell_NotifyIcon,NIM_ADD,ADDR NID

.IF eax == 0
invoke RemoveTaskBarButton
invoke ShowWindow,hDlg,SW_SHOW
ret
.endif

invoke LoadIcon,hInst,ICO_TRAYNEXT

mov NID.hIcon,eax
mov NID.cbSize,SIZEOF NOTIFYICONDATA
mov eax,hDlg
mov NID.hwnd,eax
mov NID.uID,1
mov NID.uFlags,NIF_ICON or NIF_MESSAGE or NIF_TIP
mov NID.uCallbackMessage,WM_USER + 27

invoke LoadString,hInst,IDC_NEXT,ADDR NID.szTip,SIZEOF NID.szTip
invoke Shell_NotifyIcon,NIM_ADD,ADDR NID

.IF eax == 0
invoke RemoveTaskBarButton
invoke ShowWindow,hDlg,SW_SHOW
ret
.endif

invoke GetDesktopWindow
invoke SetFocus,eax
ret

AddTaskBarButton endp

RemoveTaskBarButton proc
LOCAL NID :NOTIFYICONDATA

mov NID.cbSize,SIZEOF NOTIFYICONDATA
mov eax,hDlg
mov NID.hwnd,eax
mov NID.uID,1
invoke Shell_NotifyIcon,NIM_DELETE,ADDR NID

mov NID.uID,2
invoke Shell_NotifyIcon,NIM_DELETE,ADDR NID
mov NID.uID,3
invoke Shell_NotifyIcon,NIM_DELETE,ADDR NID
mov NID.uID,4
invoke Shell_NotifyIcon,NIM_DELETE,ADDR NID
mov NID.uID,5
invoke Shell_NotifyIcon,NIM_DELETE,ADDR NID
mov NID.uID,6
invoke Shell_NotifyIcon,NIM_DELETE,ADDR NID
ret

RemoveTaskBarButton endp


Ofcourse you will have to have the icons in your resource section but that is fairly easy to do. The main window will be sent a custom message (WM_USER + 27) and passes the identifier in the message (NID.uID) each time a button is pressed. I should note that this is written in MASM so I wrote it quite a long time ago for an MP3 library program I was playing around with. If I was to write it again it would probably be more efficient and clear but I have no need of it any more.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Retsim_X

oh i see thank you :)

so its just an extension of shell? i would have thought it would be substatially more difficult to do that that some simple shell :)

thanks again

Rx

donkey

Quote from: Retsim x86 on June 13, 2007, 01:46:09 AM
oh i see thank you :)

so its just an extension of shell? i would have thought it would be substatially more difficult to do that that some simple shell :)

thanks again

Rx

No problem.

As I said, pretty easy and direct. But that code snippet is a very old one and could easily be improved upon, I don't use MASM any more but there shouldn't be any need to reload the static values in the structure each time etc... (I don't think the API writes back to the structure so things like hDlg can be loaded once and save you some reading)

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

zooba

I think you're actually talking about deskbands - like the Language Bar and the Quick Start toolbar (though more advanced than simply a list of shortcuts).

See this MSDN page for information on how to do it, but be warned. It involves quite a bit of COM work. Good luck :thumbu

Cheers,

Zooba :U

Retsim_X

great resource thank you :)

Rx