Page 4 of 4

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 11:32 am
by whertz
SROD YOU ARE A GENIUS!!!

You code didn't work at first, findwindow kept returning 0, until I changed from this: FindWindow_("Windowname", 0) to this: FindWindow_(0,"Windowname")

I always thought the string you are searching for with findwindow is the second parameter. Anyway, it works, thank you so much.

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 11:38 am
by srod
Okay, just keep in mind that FindWindow_(0,"Windowname") can be unsafe/unreliable because window titles can change. Take a look at IE for example, the window title changes to reflect whichever page I am currently viewing. Also, the window title could be language dependent etc.

You are better off using the window class name. Use the following code to determine the classname (using the hWnd value you have found) :

Code: Select all

a$ = space(256)
GetClassName_(hWnd, @a$, 256)
debug a$
Once you have the classname, modify your FindWindow_() to :

Code: Select all

FindWindow_("Insert Classname here", 0)
With my Trillian example, I used the classname "trillian" which the application had registered etc.

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 11:53 am
by infratec
Hi,

here is my small try for a solution

Code: Select all

Procedure Refresh(hTray.l)
 
 Result = #False
 
 If hTray
  rRect.RECT
  ;get the size of the window
  If GetClientRect_(hTray, rRect)
   ;loop through each line
;   For z.l = 0 To rRect\bottom
z = rRect\bottom / 2
    ; send a MouseMove to each position
    For x = 0 To rRect\right Step 4
     SendMessage_(hTray, #WM_MOUSEMOVE, 0, (z << 16) | x)
    Next x
;   Next z
   
   Result = #True
  EndIf
 EndIf

 ProcedureReturn Result

EndProcedure


Procedure.l FindSysTray()
 
 hWnd.l = FindWindow_("Shell_TrayWnd", #Null)
 If hWnd
  hWnd = FindWindowEx_(hWnd, 0, "TrayNotifyWnd", #Null)
  If hWnd
   hWnd = FindWindowEx_(hWnd, 0, "SysPager", #Null)
   If hWnd
    hWnd = FindWindowEx_(hWnd, 0, "ToolbarWindow32", #Null)
   EndIf
  EndIf
 EndIf
 
 ProcedureReturn hWnd
 
EndProcedure


Procedure SysTrayRefresh() 
 Result = #False
 
 ;get handle of Systray
 hSystray.l = FindSysTray()
 ;refresh Systray
 If Refresh(hSystray) : Result = #True : EndIf
 
 ProcedureReturn Result
 
EndProcedure

SysTrayRefresh()
Please test it.

Bernd

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 11:57 am
by srod
Yep that works here. :)

Nice solution.

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 12:02 pm
by whertz
Thanks infratec, another good solution.

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 12:16 pm
by infratec
Hi,

it is not neccessary to send a MouseMove to each line,
so I reduced it to the middle line.
I also 'move' now only every 4th pixel.
Since I still hit every icon, it works.

Bernd

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 12:19 pm
by Michael Vogel
RASHAD wrote:Hi Michael
Nice talking to you
Give me some details, like What do you want to do?(may be I can help)
I think XP is in your mind not Win 7, right?
Right !

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 12:21 pm
by infratec
Hi Michael,

my solution 'refreshes' the systray complete.
Like you move the mouse above it :)

Bernd

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 12:31 pm
by RASHAD
Hi Berned
Sorry it does not work here not with XP nor with Windows 7
It seems to me it will work with some special cases
I created a prog. it is only a process no windows it create a system tray icon and using Esc key to quit
When I kill the process the icon stayes in the system tray and no way up to now to clean it specially with 7
It is a kind of a f**** task somehow

Hi Micharl
Ok I will try (may be .... who knows)

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 12:38 pm
by infratec
Hi Rashad,

I use XP 32 bit and the 'notepad' example.
It works without any problems.

The only thing what it does, is to simulate a mousemove across the whole stuff.
So if your icon removes when you use your real mouse, it should also remove with my program.

Please try the latest version.

Bernd

Re: How to remove systray icon?

Posted: Fri Feb 19, 2010 12:48 pm
by RASHAD
Hi Berned
I know that you are testing some special case
Keep tring will you?
whertz just opened the hell



Michael
BTW:Your marvel code for ejecting the USB flash works for me in XP only
But nobody complain about that so I kept quiet check that please.

Re: How to remove systray icon?

Posted: Sat Feb 20, 2010 3:08 pm
by Michael Vogel
Wrote some words like "Thanks Bernd and Rashad" but it seems that I forgot to click on "send" :evil:

Your code snippets work fine here, I'm sure, one of my next programs will use some lines of them :wink:

Michael
RASHAD wrote:Michael
BTW:Your marvel code for ejecting the USB flash works for me in XP only
But nobody complain about that so I kept quiet check that please.
Hm - I'm using the eject routines in a small tool called "Runner", which is something like a swiss knife on my USB stick. I also have included the routine to eject USB devices, which worked fine on all PCs for now (2000, XP, Vista and 7) -- the only difference is, that the LED doesn't get off on Vista :|

The only thing in the eject procedure lines I had to change for Vista was the following (I fear, that has nothing to do with your problems)
Global LocalDrive;=FirstChar(PeekS(GetCommandLine_()))
GetModuleFileName_(0,@LocalDrive,2); <--- 1 works for XP but not for Vista !
LocalDrive&$df;

Re: How to remove systray icon?

Posted: Sat Feb 20, 2010 3:36 pm
by RASHAD
OK Michael
I will give the code another look
Now see next if it will suit you

Sorry if we are hijacking this thread

Code: Select all


    h1 = FindWindow_("Shell_TrayWnd",0)   
    h2 = FindWindowEx_(h1,0,"TrayNotifyWnd",0)
    h3 = FindWindowEx_(h2,0,"SysPager",0)  
    h4 = FindWindowEx_(h3,0,"ToolbarWindow32",0)
    h5 = FindWindowEx_(h2,0,"TrayClockWClass",0)
;********************************( Show Desktop Windows 7 )************************
    
    ;h6 = FindWindowEx_(h2,0,"TrayShowDesktopButtonWClass",0)
    
    
;******************(  Maximize Clock  )**************************

    ShowWindow_(h3,#SW_HIDE)
    ShowWindow_(h5,#SW_MAXIMIZE)
    SHChangeNotify_(134217728,0,0, 0)
    
    
;******************(  Restore Previous  )**************************

;     ShowWindow_(h5,#SW_RESTORE	)
;     ShowWindow_(h3,#SW_SHOW)
;     SHChangeNotify_(134217728,0,0, 0)