EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   dialogs.g

   edit.g

   events.g

   fonts.g

   form.g

   gray.g

   grey.g

   images.g

   label.g

   labeled.g

   locustr.g

   menu.g

   panel.g

   picture.g

   s.txt

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Cell Phone Batteries
Batteries Plus offers batteries for laptop, camcorder, cell phone, camera.

Gentee needs your help!
How to advertise with us
 
laptop battery

source\lib\vis\tray.g
  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2004-2008, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: vis.ctrl 25.03.08 0.0.A.
 11 *
 12 * Author: Alexander Krivonogov ( gentee )
 13 *
 14 ******************************************************************************/
 15 /*------------------------------------------------------------------------------
 16    Import
 17 */
 18 type NOTIFYICONDATA {
 19    uint cbSize
 20    uint hWnd
 21    uint uID
 22    uint uFlags
 23    uint uCallbackMessage
 24    uint hIcon
 25    reserved  szTip[128*2]
 26    uint dwState
 27    uint dwStateMask
 28    reserved  szInfo[256*2]
 29    uint  uTimeout        
 30    reserved  szInfoTitle[64*2]
 31    uint dwInfoFlags        
 32 } 
 33 
 34 import "shell32.dll" {
 35    uint Shell_NotifyIconW( uint, NOTIFYICONDATA )->Shell_NotifyIcon
 36 }
 37 
 38 define {
 39    NIM_ADD         = 0x00000000
 40    NIM_MODIFY      = 0x00000001
 41    NIM_DELETE      = 0x00000002   
 42    NIM_SETFOCUS    = 0x00000003
 43    NIM_SETVERSION  = 0x00000004
 44    
 45    NIF_MESSAGE     = 0x00000001
 46    NIF_ICON        = 0x00000002
 47    NIF_TIP         = 0x00000004   
 48    NIF_STATE       = 0x00000008
 49    NIF_INFO        = 0x00000010
 50    
 51    WM_USERTRAY     = $WM_USER + 1
 52 }
 53 
 54 /* Компонент vTray, порождена от vComp
 55 События
 56    onMouse - вызывается при сообщении от мышки над иконкой  
 57 */
 58 
 59 type vTray <inherit = vComp>
 60 {
 61 //Hidden Fields
 62    locustr  pCaption  
 63    uint     pVisible
 64    ustr     pImage
 65    uint     pLBtnPopupMenu
 66    uint     pRBtnPopupMenu   
 67    uint     flgShow
 68    uint     flgDeleting  
 69    uint     oldProc   
 70    
 71 //Events     
 72    evMouse  OnMouse
 73 }
 74 
 75 /*------------------------------------------------------------------------------
 76    Internal Methods
 77 */
 78 /* Метод iUpdateTray
 79 Обновляет настройки иконки
 80 */
 81 method vTray.iUpdateTray( )
 82 {   
 83    if this.p_designing : return 
 84    
 85    NOTIFYICONDATA nid
 86    uint nim   
 87    uint form as  this.GetForm()->vForm
 88    uint ptrImage as .GetImage( .pImage )
 89    uint caption as this.pCaption.Text( this )  
 90 
 91    if !.flgShow && .pOwner && .pVisible && !.flgDeleting   
 92    {
 93       nim = $NIM_ADD
 94       .flgShow = 1
 95    }
 96    elif .flgShow
 97    {
 98       if !.pOwner || !.pVisible || .flgDeleting
 99       {  
100          nim = $NIM_DELETE
101          .flgShow = 0
102       }
103       else
104       {
105          nim = $NIM_MODIFY
106       }
107    }
108    else : return 
109        
110    nid.cbSize = sizeof( NOTIFYICONDATA )
111    nid.hWnd = ?( &form, form.hwnd, 0 )
112    nid.uCallbackMessage = $WM_USERTRAY
113    nid.uID = &this   
114    if &ptrImage
115    {       
116       nid.hIcon = ptrImage.hImage
117    } 
118    nid.uFlags = $NIF_TIP | $NIF_ICON | $NIF_MESSAGE
119   
120    if *caption > 127 : caption.setlen( 127 )   
121    mcopy( &nid.szTip, caption.ptr(), *caption->buf )  
122      
123    Shell_NotifyIcon( nim, nid )
124 }
125 
126 /*------------------------------------------------------------------------------
127    Properties
128 */
129 /* Свойство str vTray.Image - Get Set
130 Усотанавливает или получает картинку
131 */
132 property ustr vTray.Image <result>
133 {
134    result = this.pImage
135 }
136 
137 property vTray.Image( ustr val )
138 {
139    if val != this.pImage
140    { 
141       this.pImage = val
142       .iUpdateTray()
143    }  
144 }
145 
146 /* Свойство uint vTray.Visible - Get Set
147 0 - иконка в трэе не видна
148 1 - иконка в трэе видна
149 */
150 property uint vTray.Visible
151 {   
152    return .pVisible
153 }
154 
155 property vTray.Visible( uint val )
156 {
157    if .pVisible != val
158    {
159       .pVisible = val      
160       .iUpdateTray()            
161    }
162 }
163 
164 /* Свойство ustr vTray.Caption - Get Set
165 Устанавливает или определяет заголовок иконки
166 */
167 property ustr vTray.Caption <result>
168 {
169    result = this.pCaption.Value
170 }
171 
172 property vTray.Caption( ustr val )
173 {  
174    if val != this.pCaption.Value
175    { 
176       this.pCaption.Value = val
177       .iUpdateTray()
178    }         
179 }
180 
181 
182 /* Свойство uint LBtnPopupMenu - Get Set
183 Меню по левой кнопке мыши
184 */
185 property vPopupMenu vTray.LBtnPopupMenu()
186 {
187    return this.pLBtnPopupMenu->vPopupMenu
188 }
189 
190 property vTray.LBtnPopupMenu( vPopupMenu val )
191 {     
192    if this.pLBtnPopupMenu != &val
193    {   
194       this.pLBtnPopupMenu = &val           
195    }     
196 }
197 
198 /* Свойство uint RBtnPopupMenu - Get Set
199 Меню по правой кнопке мыши
200 */
201 property vPopupMenu vTray.RBtnPopupMenu()
202 {
203    return this.pRBtnPopupMenu->vPopupMenu
204 }
205 
206 property vTray.RBtnPopupMenu( vPopupMenu val )
207 {     
208    if this.pRBtnPopupMenu != &val
209    {   
210       this.pRBtnPopupMenu = &val           
211    }     
212 }
213 
214 /*------------------------------------------------------------------------------
215    Virtual Methods
216 */
217 /*Виртуальный метод uint vCustomBtn.mLangChanged - Изменение текущего языка
218 */
219 method vTray.mLangChanged <alias=vTray_mLangChanged>()
220 {
221    this->vCtrl.mLangChanged()
222    .iUpdateTray()       
223 }
224 
225 
226 method uint vForm.wmusertray <alias=vForm_wmusertray>( winmsg wmsg )
227 {
228    uint tray as wmsg.wpar->vTray   
229    if &tray && tray.GetForm() == &this 
230    {  
231       if wmsg.msg == $WM_USERTRAY 
232       {      
233          winmsg mmsg
234          mmsg.msg = wmsg.lpar
235          evparMouse em
236          if MouseMsg( mmsg, em )
237          {       
238             if em.evmtype == $evmRUp && &tray.RBtnPopupMenu  
239             {
240                SetForegroundWindow( this.hwnd )  
241                tray.RBtnPopupMenu.Show( )
242                return 0  
243             }
244             elif em.evmtype == $evmLUp && &tray.LBtnPopupMenu
245             {
246                SetForegroundWindow( this.hwnd )  
247                tray.LBtnPopupMenu.Show( )
248                return 0
249             }  
250             
251             return tray.OnMouse.Run( em )  
252          }         
253       }
254       /*elif tray.oldProc 
255       {
256          return tray.oldProc->func( &this, &wmsg )
257       }*/
258    }   
259    return 0  
260 }
261 
262 method vTray.mSetOwner <alias = vTray_mSetOwner>( vComp newowner )
263 {       
264    //print( "tray setowner 0 \(this.pOwner)\n" )   
265    if this.pOwner
266    {
267       //print( "tray setowner 1 \(&gettypedef( this.Owner->vCtrl.GetForm()->vComp.pTypeId))\n" )
268       gettypedef( this.Owner->vCtrl.GetForm()->vComp.pTypeId ).delproc( $WM_USERTRAY, .oldProc )
269       //print( "tray setowner 2\n" )
270       //gettypedef( this.Owner->vCtrl.GetForm()->vComp.pTypeId ).ProcTbl[ $WM_USER ]  = .oldProc    
271    }   
272    this->vComp.mSetOwner( newowner )   
273    if &newowner
274    {
275       .oldProc = gettypedef( this.Owner->vCtrl.GetForm()->vComp.pTypeId ).setproc( $WM_USERTRAY, vForm_wmusertray )  
276       /*uint addr = &gettypedef( newowner.GetForm()->vComp.pTypeId ).ProcTbl[ $WM_USER ]
277       
278       .oldProc = addr->uint
279       print( "\(addr) \(.oldProc)\n" ) 
280       addr->uint = vForm_wmusertray*/
281    }   
282    .iUpdateTray()
283 }
284 
285 method vTray.mPreDel <alias=vTray_mPreDel>
286 {  
287    .flgDeleting = 1
288    .iUpdateTray()
289    this->vComp.mPreDel()
290 }
291 
292 
293 
294 /*------------------------------------------------------------------------------
295    Registration
296 */
297 method vTray vTray.init( )
298 {
299    this.pTypeId = vTray
300    return this 
301 }
302 
303 func init_vTray <entry>()
304 {     
305    regcomp( vTray,      "vTray", vComp, $vComp_last, 
306       %{ %{$mSetOwner,     vTray_mSetOwner }, 
307          %{$mPreDel,       vTray_mPreDel },
308          %{$mLangChanged,  vTray_mLangChanged }
309       },
310       0->collection )
311             
312             
313 ifdef $DESIGNING {
314    cm.AddComp( vTray, 1, "Windows", "tray" )   
315    
316    cm.AddProps( vTray, %{ 
317 "Caption", ustr, 0,
318 "Visible", uint, 0,
319 "Image"  , ustr, 0,
320 "LBtnPopupMenu", vPopupMenu, $PROP_LOADAFTERCREATE,
321 "RBtnPopupMenu", vPopupMenu, $PROP_LOADAFTERCREATE
322    }) 
323    
324    cm.AddEvents( vTray, %{
325 "OnMouse"      , "evparMouse"
326    })
327                
328 }
329       
330 }
Edit