EnglishРусский  

   ..

   addustr.g

   app.g

   btn.g

   btnpic.g

   comp.g

   ctrl.g

   ctrlci.g

   dialogs.g

   dlgbtns.g

   edit.g

   events.g

   fonts.g

   form.g

   gray.g

   grey.g

   header.g

   images.g

   label.g

   labeled.g

   locustr.g

   menu.g

   panel.g

   picture.g

   styles.g

   tab.g

   tabitem.g

   tabpage.g

   timer.g

   toolbar.g

   tray.g

   url.g

   vis.g

   viswin.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

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.GetMainForm()->vForm
 88    uint ptrImage as .GetImage( .pImage )
 89    uint caption as this.pCaption.Text( this )  
 90    if !.flgShow && .pOwner && form.hwnd && .pVisible && !.flgDeleting   
 91    {
 92       nim = $NIM_ADD
 93       .flgShow = 1
 94    }
 95    elif .flgShow
 96    {
 97       if !.pOwner || !.pVisible || .flgDeleting
 98       {     
 99          nim = $NIM_DELETE
100          .flgShow = 0
101       }
102       else
103       {
104          nim = $NIM_MODIFY
105       }
106    }
107    else : return 
108    nid.cbSize = sizeof( NOTIFYICONDATA )
109    
110    nid.uCallbackMessage = $WM_USERTRAY
111    if &ptrImage
112    {       
113       nid.hIcon = ptrImage.hImage
114    } 
115    nid.uFlags = $NIF_TIP | $NIF_ICON | $NIF_MESSAGE
116    
117    if *caption > 127 : caption.setlen( 127 )   
118    mcopy( &nid.szTip, caption.ptr(), *caption->buf )
119    nid.hWnd = ?( &form, form.hwnd, 0 )
120       
121    nid.uID = &this  
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 == $evmRDown && &tray.RBtnPopupMenu  
239             {
240                SetForegroundWindow( this.hwndTip )
241                tray.RBtnPopupMenu.Show( )               
242                return 0  
243             }
244             elif em.evmtype == $evmLDown && &tray.LBtnPopupMenu
245             {
246                SetForegroundWindow( this.hwndTip )
247                tray.LBtnPopupMenu.Show( )
248                return 0               
249             }  
250             return tray.OnMouse.Run( em )  
251          }  
252          /*elif wmsg.lpar == $WM_CONTEXT
253          {
254             
255          }  */     
256       }
257       /*elif tray.oldProc 
258       {
259          return tray.oldProc->func( &this, &wmsg )
260       }*/
261    }   
262    return 0  
263 }
264 
265 method vTray.mSetOwner <alias = vTray_mSetOwner>( vComp newowner )
266 {       
267    if this.pOwner
268    {
269       gettypedef( this.Owner->vCtrl.GetForm()->vComp.pTypeId ).delproc( $WM_USERTRAY, .oldProc )
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       addr->uint = vForm_wmusertray*/
280    }   
281    .iUpdateTray()
282 }
283 
284 method vTray.mPreDel <alias=vTray_mPreDel>
285 {   
286    .flgDeleting = 1
287    .iUpdateTray()
288    this->vComp.mPreDel()
289 }
290 
291 method vTray.mOwnerCreateWin <alias=vTray_mOwnerCreateWin>
292 {  
293    .iUpdateTray()   
294 }
295 
296 /*------------------------------------------------------------------------------
297    Registration
298 */
299 method vTray vTray.init( )
300 {
301    this.pTypeId = vTray
302    return this 
303 }
304 
305 func init_vTray <entry>()
306 {     
307    regcomp( vTray,      "vTray", vComp, $vComp_last, 
308       %{ %{$mSetOwner,     vTray_mSetOwner }, 
309          %{$mPreDel,       vTray_mPreDel },
310          %{$mLangChanged,  vTray_mLangChanged },
311          %{$mOwnerCreateWin,  vTray_mOwnerCreateWin }
312       },
313       0->collection )
314             
315             
316 ifdef $DESIGNING {
317    cm.AddComp( vTray, 1, "Windows", "tray" )   
318    
319    cm.AddProps( vTray, %{ 
320 "Caption", ustr, 0,
321 "Visible", uint, 0,
322 "Image"  , ustr, 0,
323 "LBtnPopupMenu", vPopupMenu, $PROP_LOADAFTERCREATE,
324 "RBtnPopupMenu", vPopupMenu, $PROP_LOADAFTERCREATE
325    }) 
326    
327    cm.AddEvents( vTray, %{
328 "OnMouse"      , "evparMouse"
329    })
330                
331 }
332       
333 }
334