forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Minimize to System Tray

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Hippo
Contributor
Contributor


Joined: 08 Feb 2005
Posts: 53

PostPosted: Thu Feb 10, 2005 3:11 pm    Post subject: Minimize to System Tray Reply with quote

How do I go about minimizing my application to the system tray. The VDS help file doesnt really mention anything about doing this. Is it possible?
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Thu Feb 10, 2005 3:32 pm    Post subject: Reply with quote

yes it is

1. create your interface but don't put DIALOG SHOW at the end

2. add DIALOG ADD,TASKICON,SystemTray to your interface code

2. before :EVLOOP use WINDOW HIDE, ... to hide your window

3. add :SystemTrayCLICK to handle the event when someone clicks on the icon in the system tray - for example, you will want to use WINDOW NORMAL,... to show the interface of your program

4. add a button to minimise the window to the system tray which is just another WINDOW HIDE,... command

it all comes down to "using mirrors" - minimising the program to the system tray is really about hiding it, while maximising it from the system tray is just making it appear

that's what i do anyway - may be someone else has a better way of doing it

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Feb 10, 2005 11:34 pm    Post subject: Reply with quote

Posted a simple example that uses the window's regular
minimize button:

http://www.vdsworld.com/forum/viewtopic.php?p=25238

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Fri May 20, 2005 4:04 pm    Post subject: Minimize to System Tray Taskicon Reply with quote

I found a more efficient way to minimize a window to a system tray icon using the MSGEVENT OPTION(see attached). The WM_STYLECHANGED ($0000007D) message would be ideal for this purpose but the VDS runtime doesn't pass it to the msgevent. The WM_NCLBUTTONDOWN message is only sent when the user clicks on the window's non-client area (title bar or buttons) so it's a good alternative.

Code:

rem MSGEVENTs to capture non-client mouse clicks
  rem Trap LEFT mouse button down
  option msgevent,$000000A1,WM_NCLBUTTONDOWN
  rem Trap RIGHT mouse button down to capture sysmenu/Minimize
  option msgevent,$000000A4,WM_NCRBUTTONDOWN
  option scale,96
 
title Min2Tray Demo
  dialog create,Min2Tray Demo,-1,0,240,82
  dialog add,check,minCK,30,14,180,18,Mininize to system tray,1
  dialog show
  %%dlg0 = @winexists(Min2Tray Demo)

:evloop
  wait event
  goto @event()
 
:TiconRestoreCLICK
  dialog remove,TiconRestore
  dialog show
  window activate,%%dlg0
  goto evloop

:WM_NCRBUTTONDOWN 
:WM_NCLBUTTONDOWN
  rem Non-standard window behaviors should be user optional
  If @dlgtext(minCK)
    rem Test if window status is 2 = iconized / hide taskbar button
    rem info @msgparams(WL)
    if @equal(@winpos(%%dlg0,S),2)
      dialog hide
      dialog add,taskicon,TiconRestore,,Restore
    end
  End 
  goto evloop

:Close
  exit
Back to top
View user's profile Send private message Send e-mail
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Wed Oct 19, 2005 7:50 pm    Post subject: Question Reply with quote

In this previous example what is the purpose of

If @dlgtext(minCK)


Where is that text minCK located? I had to rem it out to get this to work with my scripts.

WD

_________________
K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Oct 19, 2005 9:14 pm    Post subject: Reply with quote

The "minCK" was just the name given to the Checkbox element which allows the user to select whether to Minimize to Tray or not. If the checkbox is not selected function "@dlgtext(minCK)" will return null and the window will minimize in the normal fashion.

To answer your question it really serves no purpose with respect to the example's main goal of minimizing a window to the Tray. I included it only as an example of how to make the Min-2-Tray feature optional for the end-user.

A word of caution if your using VDS's TaskIcon and Explorer were to crash and recover as it often does your TaskIcon will disappear leaving your program's window inaccessible to the user. I would recommend using the VDSGUI extension for creating your TaskIcon because it has an "TASKICONCRASHED" event that will notify your program when the Icon needs to be recreated.

When Explorer recreates the taskbar notification area (tray) it sends the following registered window message "TaskBarCreated" but I have NOT been able to successfully trap the message with the following code.
Code:
rem obtain message number set msgevent
  loadlib user32.dll
  %X = @lib(user32, RegisterWindowMessageA, INT:, TaskbarCreated)
  freelib user32.dll
  option msgevent,%X,TaskBarCreated
 
:TaskBarCreated
  rem replace icon here
  goto evloop
 
rem Does anyone have any ideas on how this can be done within VDS?
Back to top
View user's profile Send private message Send e-mail
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Wed Oct 19, 2005 11:34 pm    Post subject: Thanks Reply with quote

I will look and see if I can figure out how to intercept the message. I tried using a similar method but it too failed. I believe there might be a message event for this in user32. Will check and see if I can find it. I stumbled over it the other day.
_________________
K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Wed Oct 19, 2005 11:35 pm    Post subject: Wow Im Stupid Reply with quote

Oh i'm sorry that IS how you are trying to do it. I missed that fact that you were calling user32. Good luck. Will see if I can figure it out as well. If I do I'll post it to the forum for you.
_________________
K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Thu Oct 20, 2005 6:00 am    Post subject: option msgevent Reply with quote

Since this approach works in Delphi I'm thinking the VDS runtime just isn't passing messages onto the "option msgevent". Wininspector shows that the window like all top level windows does receive the "TaskbarCreated" message. I hope msgevent's deficiencies get addressed in version 6.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group