Re: cffi.e

new topic     » goto parent     » topic index » view thread      » older message » newer message

I made a working layout, the icon is displayed, but when you hover the mouse disappears. I didn't understand c-struct, if you can show a working example, I didn't find anything in the demo

include cffi.e
include ..\demo\arwen\arwen.ew 
 
constant SM_SYSTRAY  = #400 + 5 
with trace 
--trace(1) 
constant tLoadImageA = """ 

HANDLE LoadImageA( 
  HINSTANCE hInst, 
  LPCSTR    name, 
  UINT      type, 
  int       cx, 
  int       cy, 
  UINT      fuLoad 
); 
""" 

set_unicode(0) 
constant SHELL32 = open_dll("shell32") 
constant USER32 = open_dll("user32") 
constant LoadImageA = define_cffi_func(USER32,tLoadImageA) 
atom lpszName=allocate_string("test.ico") 
constant icon_t=c_func(LoadImageA,{0,lpszName,1,0,0,0x00000010}) 
 ? icon_t 
 
constant tShell_NotifyIconA = """  

BOOL Shell_NotifyIcon( 
    DWORD dwMessage, 
    NOTIFYICONDATA* lpData 
    ); 
""" 

constant NIM_ADD     = 0, 
         NIM_MODIFY  = 1, 
         NIM_DELETE  = 2, 
         NIF_MESSAGE = 1, 
         NIF_ICON    = 2, 
         NIF_TIP     = 4 
 
constant Shell_NotifyIconA = define_cffi_func(SHELL32,tShell_NotifyIconA)  
 
constant tNOTIFYICONDATA="""  

 
typedef struct _NOTIFYICONDATA {   
    DWORD cbSize;   
    HWND hWnd;   
    UINT uID;   
    UINT uFlags;   
    UINT uCallbackMessage;   
    HICON hIcon; 			  
    TCHAR szTip[128];      
} NOTIFYICONDATA, *PNOTIFYICONDATA;  
"""  

constant integer idNOTIFYICONDATA = define_struct(tNOTIFYICONDATA)  
atom pNOTIFYICONDATA = allocate_struct(idNOTIFYICONDATA)  
 
--/* 
struct t_NOTIFYICONDATAA """ 

typedef struct _NOTIFYICONDATAA { 
  DWORD cbSize; 
  HWND  hWnd; 
  UINT  uID; 
  UINT  uFlags; 
  UINT  uCallbackMessage; 
  HICON hIcon; 
  CHAR  szTip[128]; 
  DWORD dwState; 
  DWORD dwStateMask; 
  CHAR  szInfo[256]; 
  CHAR  szInfoTitle[64]; 
  DWORD dwInfoFlags; 
  GUID  guidItem; 
  HICON hBalloonIcon; 
} NOTIFYICONDATAA, *PNOTIFYICONDATAA; 
""" 

end struct 
--*/ 
------------------------------------------------------------------------- 
constant MainWin = create(Window, "Example 02", 0, NULL, 25, 25, 300, 200, 0) 
 
object flags={NIF_MESSAGE,NIF_ICON,NIF_TIP} 
       
integer size = get_struct_size(idNOTIFYICONDATA)  
  set_struct_field(idNOTIFYICONDATA,pNOTIFYICONDATA,"cbSize",size)  
   
        flags = or_all(flags) 
atom pStr=allocate_string("My icon")        
  set_struct_field(idNOTIFYICONDATA,pNOTIFYICONDATA,"hWnd",MainWin) 
  set_struct_field(idNOTIFYICONDATA,pNOTIFYICONDATA,"uFlags",flags)  
  set_struct_field(idNOTIFYICONDATA,pNOTIFYICONDATA,"uCallbackMessage",SM_SYSTRAY) 
  set_struct_field(idNOTIFYICONDATA,pNOTIFYICONDATA,"szTip",pStr)  
  set_struct_field(idNOTIFYICONDATA,pNOTIFYICONDATA,"hIcon",icon_t)   
  atom a=c_func(Shell_NotifyIconA,{NIM_ADD,pNOTIFYICONDATA}) 
  ? a 
   
function MainHandler(integer id, integer msg, atom wParam, object lParam) 
         
	if msg = SM_SYSTRAY then   
      ? "fsdfsafsfa" 
    end if 
     
    return 0 
end function 
setHandler(MainWin,routine_id("MainHandler")) 
 
  WinMain(MainWin, SW_NORMAL) 
  free(pNOTIFYICONDATA)  
  free (pStr) 
  free(lpszName) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu