KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

NotifyIcon and close window

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Radimus
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 05 Mar 2003
Posts: 157
Location: Tampa, Florida

PostPosted: Wed Oct 05, 2005 5:28 pm    Post subject: NotifyIcon and close window Reply with quote

how do you setup the form so that when opening the form via NotifyIcon, you can close the form from the X but it will still run and can open again from the Notify Icon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed Oct 05, 2005 7:14 pm    Post subject: Reply with quote

Would have to trap on the Form closing event, cancel that event, then just hide the form ...

Code:

Break On

$System = CreateObject("Kixforms.System")

;; create an icon for the taskbar...

$TimeIcon = $System.Icon.FromBase64String(TimeIconString())

$Form = $System.Form()
$Form.Text = "The Current Time is ..."
$Form.Closing = "FormClosing()"
$Form.Icon = $TimeIcon

$Label = $Form.Controls.Add($System.Label())
$Label.BorderStyle = $System.BorderStyle_Fixed3D
$Label.Size = $Form.ClientSize
$Label.Center
$Label.Font = $System.Font("Courier New", 24, $System.FontStyle_Bold)
$Label.Dock = $System.DockStyle_Fill
$Label.TextAlign = $System.ContentAlignment_MiddleCenter

;; create our notifyicon...

$NotifyIcon = $System.NotifyIcon()
$NotifyIcon.Icon = $TimeIcon
$NotifyIcon.Text = "Displays the current time"
$NotifyIcon.DoubleClick = "DoubleClick()"

;; create a contextmenu for notifyicon...

$ContextMenu = $System.ContextMenu()

$ShowTimeMenu = $ContextMenu.MenuItems.Add($System.MenuItem("Show Current Time..."))
$ShowTimeMenu.Click = "ShowTimeClick()"

$= $ContextMenu.MenuItems.Add($System.MenuItem("-"))

$ExitMenu = $ContextMenu.MenuItems.Add($System.MenuItem("Exit"))
$ExitMenu.Click = "ExitClick()"

;; assign the menu to notifyicon...

$NotifyIcon.ContextMenu = $ContextMenu

;; make the notifyicon visible in the system tray...

$NotifyIcon.Visible = 1

;; while the notifyicon is visible, process events ...

While $NotifyIcon.Visible
 $= Execute($System.Application.DoEvents)
Loop

$NotifyIcon.Dispose

Exit 0

Function ExitClick()
 $NotifyIcon.Visible = 0
EndFunction

Function DoubleClick()
 ShowTimeClick()
EndFunction

Function ShowTimeClick()
 $Form.Center
 $Form.Show
 $Label.Text = @TIME
EndFunction

Function FormClosing()

 $e = $Form.ClosingEventArgs

 $e.Cancel = 1

 $Form.Visible = 0

EndFunction

Function TimeIconString() ;; time.ico
$TimeIconString = "
AAABAAEAEBAQAAAAAAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAwAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD/
/wD/AAAA/wD/AP//AAD///8AAAAAAAAAAAAAAAD7+/AAAAAAv7+/v7AAAAv7+/v7+wAAD7C/
v7+/AAD7+wv7+/vwAL+/sL+/v7AA+/v7AAAA8AC/v7+/v7+wAPv7+/v7+/AAD7+/v7+/AAAL
+/v7+/sAAAC/vw+/sAAAAAD7+/AAAAAAAAAAAAAAAAAAAAAAAAD8HwAA8AcAAOADAADAAQAA
wAEAAIAAAACAAAAAgAAAAIAAAACAAAAAwAEAAMABAADgAwAA8AcAAPwfAAD//wAA
"
EndFunction


-Shawn
Back to top
View user's profile Send private message
Radimus
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 05 Mar 2003
Posts: 157
Location: Tampa, Florida

PostPosted: Wed Oct 05, 2005 7:44 pm    Post subject: Reply with quote

cool...

which is better to do:
$Form.Visible = 0
or
$form.hide()
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed Oct 05, 2005 8:15 pm    Post subject: Reply with quote

same diff afaik
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed Oct 05, 2005 8:16 pm    Post subject: Reply with quote

just dont Close it - thats different. Thats actually destroys the form and releases all resources.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Oct 06, 2005 12:02 am    Post subject: Reply with quote

but that doesn't hurt if you recreate it anyways... Wink
_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion 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 cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group