Re: System Tray Icon - anyone got the latest app?



Tim, I'm using this one...
regards,
Sebastian
PD: the mouse clicks are not being detected, if you can fix it I'll
have interest on the patch. Regards.
____________________________________
| package |
package := Package name: 'TaskbarIcons'.
package paxVersion: 1;
basicComment: 'Copy this expression into a workspace and evalute it to
see the (rather boring) example in action. When you''ve finished close
the window and the tray icon should disappear too.

TrayApplicationShell showOn: Locale.

Without the window...

trayShell := TrayApplicationShell createOn: Presenter.
trayShell exit.


'.

package basicScriptAt: #postuninstall put: ' "Remove the constants"
Win32Constants
removeKey: ''NIM_ADD'';
removeKey: ''NIM_MODIFY'';
removeKey: ''NIM_DELETE'';
removeKey: ''NIF_MESSAGE'';
removeKey: ''NIF_ICON'';
removeKey: ''NIF_TIP''
'.
package basicScriptAt: #preinstall put: ' "Add the necessary constants"
Win32Constants
at: ''NIM_ADD'' put: 16r0;
at: ''NIM_MODIFY'' put: 16r1;
at: ''NIM_DELETE'' put: 16r2;
at: ''NIF_MESSAGE'' put: 16r1;
at: ''NIF_ICON'' put: 16r2;
at: ''NIF_TIP'' put: 16r4'.

package classNames
add: #NOTIFYICONDATA;
add: #ShellNotifyView;
add: #TrayApplicationShell;
yourself.

package methodNames
add: #ShellLibrary -> #shell_NotifyIcon:pnid:;
yourself.

package binaryGlobalNames: (Set new
yourself).

package globalAliases: (Set new
yourself).

package setPrerequisites: (IdentitySet new
add: '..\..\Object Arts\Dolphin\Base\Dolphin';
add: '..\..\Object Arts\Dolphin\MVP\Base\Dolphin MVP Base';
yourself).

package!

"Class Definitions"!

Win32Structure subclass: #NOTIFYICONDATA
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!
Shell subclass: #TrayApplicationShell
instanceVariableNames: 'tipText registerMessage'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!
ShellView subclass: #ShellNotifyView
instanceVariableNames: 'struct notifyMsg'
classVariableNames: ''
poolDictionaries: ''
classInstanceVariableNames: ''!

"Global Aliases"!


"Loose Methods"!

!ShellLibrary methodsFor!

shell_NotifyIcon: dwMessage pnid: pnid
"Add, modify, or delete an icon from the taskbar status area.
WINSHELLAPI BOOL WINAPI Shell_NotifyIcon(
DWORD dwMessage, // message identifier
PNOTIFYICONDATA pnid // pointer to structure
); "

<stdcall: bool Shell_NotifyIconA dword NOTIFYICONDATA* >
^self invalidCall! !
!ShellLibrary categoriesFor: #shell_NotifyIcon:pnid:!public!win32
functions-taskbar! !

"End of package definition"!

"Source Globals"!

"Classes"!

NOTIFYICONDATA guid: (GUID fromString:
'{9D51D1A9-0A75-43CD-8949-572558A9C983}')!
NOTIFYICONDATA comment: ''!
!NOTIFYICONDATA categoriesForClass!No category! !
!NOTIFYICONDATA methodsFor!

cbSize: anObject
"Set the receiver's cbSize field to the value of anObject."

bytes dwordAtOffset: 0 put: anObject!

dwSize: anObject
"Set the receiver's dwSize field to the value of anObject."

bytes dwordAtOffset: 0 put: anObject!

hIcon: anObject
"Set the receiver's hIcon field to the value of anObject."

bytes dwordAtOffset: 20 put: anObject!

hWnd: anObject
"Set the receiver's hWnd field to the value of anObject."

bytes dwordAtOffset: 4 put: anObject!

icon: anIconOrHandle
"Set the receiver's hIcon field."

self hIcon: anIconOrHandle asParameter.
self uFlags: (self uFlags bitOr: NIF_ICON)!

initialize: anInteger
"Private - Initialize the state of the receiver."

super initialize: anInteger.
self cbSize: anInteger!

message: anIntegerMessageNumber
"Set the receiver's uCallbackMessage (message sent to window when
mouse over
the icon in the taskbar) field."

self uCallbackMessage: anIntegerMessageNumber.
self uFlags: (self uFlags bitOr: NIF_MESSAGE)!

szTip
"Answer the receiver's szTip field as a Smalltalk object."

^String fromAddress: (bytes yourAddress + 24)!

szTip: anObject
"Set the receiver's szTip field to the value of anObject."

| size |
size := anObject byteSize - 1 min: (63 * 1).
anObject replaceBytesOf: bytes from: 25 to: 24 + size startingAt: 1.
bytes at: size+25 put: 0!

tipText: aString
"Set the receiver's szTip (tip text) field."

self szTip: aString.
self uFlags: (self uFlags bitOr: NIF_TIP)!

uCallbackMessage: anObject
"Set the receiver's uCallbackMessage field to the value of anObject."

bytes dwordAtOffset: 16 put: anObject!

uFlags
"Answer the receiver's uFlags field as a Smalltalk object."

^(bytes dwordAtOffset: 12)!

uFlags: anObject
"Set the receiver's uFlags field to the value of anObject."

bytes dwordAtOffset: 12 put: anObject!

uID: anObject
"Set the receiver's uID field to the value of anObject."

bytes dwordAtOffset: 8 put: anObject! !
!NOTIFYICONDATA categoriesFor: #cbSize:!**compiled accessors**!public!
!
!NOTIFYICONDATA categoriesFor: #dwSize:!**compiled accessors**!public!
!
!NOTIFYICONDATA categoriesFor: #hIcon:!**compiled accessors**!public! !
!NOTIFYICONDATA categoriesFor: #hWnd:!**compiled accessors**!public! !
!NOTIFYICONDATA categoriesFor: #icon:!accessing!public! !
!NOTIFYICONDATA categoriesFor: #initialize:!initializing!public! !
!NOTIFYICONDATA categoriesFor: #message:!accessing!public! !
!NOTIFYICONDATA categoriesFor: #szTip!**compiled accessors**!public! !
!NOTIFYICONDATA categoriesFor: #szTip:!**compiled accessors**!public! !
!NOTIFYICONDATA categoriesFor: #tipText:!accessing!public! !
!NOTIFYICONDATA categoriesFor: #uCallbackMessage:!**compiled
accessors**!public! !
!NOTIFYICONDATA categoriesFor: #uFlags!**compiled accessors**!public! !
!NOTIFYICONDATA categoriesFor: #uFlags:!**compiled accessors**!public!
!
!NOTIFYICONDATA categoriesFor: #uID:!**compiled accessors**!public! !

!NOTIFYICONDATA class methodsFor!

defineFields
"Define the fields of the NOTIFYICONDATA 'structure'.

NOTIFYICONDATA decompileDefinition;defineTemplate

struct {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
char szTip[64];
} NOTIFYICONDATA;
"

self
defineField: #cbSize type: DWORDField writeOnly;
defineField: #hWnd type: DWORDField writeOnly;
defineField: #uID type: DWORDField writeOnly;
defineField: #uFlags type: DWORDField new;
defineField: #uCallbackMessage type: DWORDField writeOnly;
defineField: #hIcon type: DWORDField writeOnly;
defineField: #szTip type: (StringField length: 64)!

initialize
"TEMPORARY initialize method
NOTIFYICONDATA initialize
"

Win32Constants
at: 'NIM_ADD' put: 16r0;
at: 'NIM_MODIFY' put: 16r1;
at: 'NIM_DELETE' put: 16r2;
at: 'NIF_MESSAGE' put: 16r1;
at: 'NIF_ICON' put: 16r2;
at: 'NIF_TIP' put: 16r4
! !
!NOTIFYICONDATA class categoriesFor: #defineFields!initializing!public!
!
!NOTIFYICONDATA class categoriesFor: #initialize!initializing!public! !

TrayApplicationShell guid: (GUID fromString:
'{D3F70398-A836-4813-80AD-BEB4363BC3A2}')!
TrayApplicationShell comment: ''!
!TrayApplicationShell categoriesForClass!Unclassified! !
!TrayApplicationShell methodsFor!

createSchematicWiring
super createSchematicWiring.
self
when: #rightButtonReleased:
send: #onRightButtonReleased:
to: self!

icon
^ model icon!

onCursorAtTray

!

onRightButtonReleased: anObject

Transcript nextPutAll: TimeStamp current printShort ;cr.
!

onViewClosed

super onViewClosed.

self view unregister.!

onViewOpened

| struct notifyMsg |

super onViewOpened.

self view struct: self struct.
self view notifyMsg: notifyMsg.
self view register.!

registerMessage

registerMessage isNil ifTrue:[ registerMessage := 'A tray icon
application powered by Dolphin Smalltalk'].
^registerMessage!

registerMessage: anObject
registerMessage := anObject!

struct

|struct notifyMsg |

^ struct := NOTIFYICONDATA new.
notifyMsg := self view registerMessage: self registerMessage.
struct
uID: 1;
icon: self icon;
message: notifyMsg;
tipText: self tipText.!

tipText
tipText isNil ifTrue:[ tipText := 'A default tip text.'].
^tipText!

tipText: anObject
tipText := anObject! !
!TrayApplicationShell categoriesFor:
#createSchematicWiring!initializing!private! !
!TrayApplicationShell categoriesFor: #icon!public! !
!TrayApplicationShell categoriesFor: #onCursorAtTray!public! !
!TrayApplicationShell categoriesFor: #onRightButtonReleased:!public! !
!TrayApplicationShell categoriesFor: #onViewClosed!public! !
!TrayApplicationShell categoriesFor: #onViewOpened!public! !
!TrayApplicationShell categoriesFor:
#registerMessage!accessing!private! !
!TrayApplicationShell categoriesFor:
#registerMessage:!accessing!private! !
!TrayApplicationShell categoriesFor: #struct!private! !
!TrayApplicationShell categoriesFor: #tipText!accessing!private! !
!TrayApplicationShell categoriesFor: #tipText:!accessing!private! !

!TrayApplicationShell class methodsFor!

resource_Default_view
"Answer the literal data from which the 'Default view' resource can be
reconstituted.
DO NOT EDIT OR RECATEGORIZE THIS METHOD.

If you wish to modify this resource evaluate:
ViewComposer openOn: (ResourceIdentifier class: self selector:
#resource_Default_view)
"

^#(#'!!STL' 3 788558 10 ##(Smalltalk.STBViewProxy) 8
##(Smalltalk.ShellNotifyView) 98 29 0 0 98 2 27131905 131073 416 0
524550 ##(Smalltalk.ColorRef) 8 4278190080 0 5 0 0 0 416 0 234 256 98
0 0 0 0 0 0 1 0 0 0 0 1 0 0 917766 ##(Smalltalk.NOTIFYICONDATA) 8 #[88
0 0 0 0 0 0 0 1 0 0 0 7 0 0 0 156 193 0 0 13 2 12 0 68 111 108 112 104
105 110 32 83 109 97 108 108 116 97 108 107 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
99129 983302 ##(Smalltalk.MessageSequence) 202 208 98 2 721670
##(Smalltalk.MessageSend) 8 #createAt:extent: 98 2 328198
##(Smalltalk.Point) 89 117 738 1021 561 416 674 8 #updateMenuBar 544
416 983302 ##(Smalltalk.WINDOWPLACEMENT) 8 #[44 0 0 0 0 0 0 0 0 0 0 0
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 44 0 0
0 58 0 0 0 42 2 0 0 82 1 0 0] 98 0 738 193 193 0 27 )! !
!TrayApplicationShell class categoriesFor:
#resource_Default_view!public!resources-views! !

ShellNotifyView guid: (GUID fromString:
'{3328B4F9-D699-4A8D-BA31-0C16D8F1B1FB}')!
ShellNotifyView comment: ''!
!ShellNotifyView categoriesForClass!No category! !
!ShellNotifyView methodsFor!

dispatchRegistered: registeredId wParam: wParam lParam: lParam
"Private - Dispatch the registered message which was sent to the
receiver.
To be overridden by subclasses which implement registered messages in
an appropriate
manner (e.g. by a secondary message map, or, if few in number, by
conditional tests)"

| canvas |

^registeredId = notifyMsg
ifTrue:[self presenter onCursorAtTray]
ifFalse:[ super dispatchRegistered: registeredId wParam: wParam
lParam: lParam]

" ^registeredId = notifyMsg
ifTrue: [
self canvas
text: Cursor position printString
at: 10@10;
free.
Sound bell]"!

notifyMsg
^notifyMsg!

notifyMsg: anObject
notifyMsg := anObject!

onDestroyed

self unregister.
^super onDestroyed
!

register
struct hWnd: self asParameter.
^ShellLibrary default shell_NotifyIcon: NIM_ADD pnid: struct
!

registerMessage: aString

^ self class registerMessage: aString
!

struct
^struct!

struct: anObject
struct := anObject!

unregister
^ShellLibrary default shell_NotifyIcon: NIM_DELETE pnid: struct.
! !
!ShellNotifyView categoriesFor: #dispatchRegistered:wParam:lParam:!must
not strip!public! !
!ShellNotifyView categoriesFor: #notifyMsg!accessing!private! !
!ShellNotifyView categoriesFor: #notifyMsg:!accessing!must not
strip!private! !
!ShellNotifyView categoriesFor: #onDestroyed!public! !
!ShellNotifyView categoriesFor: #register!must not strip!public! !
!ShellNotifyView categoriesFor: #registerMessage:!must not
strip!public! !
!ShellNotifyView categoriesFor: #struct!accessing!private! !
!ShellNotifyView categoriesFor: #struct:!accessing!must not
strip!private! !
!ShellNotifyView categoriesFor: #unregister!public! !

!ShellNotifyView class methodsFor!

example
"Example usage of this example class
ShellNotifyView example
"
| inst struct notifyMsg |

inst := self new.
struct := NOTIFYICONDATA new.
notifyMsg := self registerMessage: 'Dolphin Shell Notification'.
struct
uID: 1;
icon: Transcript icon;
message: notifyMsg;
tipText: 'Dolphin Smalltalk'.
inst create show register.!

example2
"Example usage of this example class
ShellNotifyView example
"

^ self new create register; yourself!

registerMessage: aString
"Register a named window message, answering the message id to use."

^UserLibrary default registerWindowMessage: aString! !
!ShellNotifyView class categoriesFor: #example!public! !
!ShellNotifyView class categoriesFor: #example2!public! !
!ShellNotifyView class categoriesFor:
#registerMessage:!dispatching!public! !

"Binary Globals"!

.


Quantcast