Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSStatusItem/Logintime in menubar


Required plugins for this example: MBS MacCocoa Plugin, MBS Util Plugin, MBS MacBase Plugin, MBS MacCF Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSStatusItem/Logintime in menubar

This example is the version from Thu, 6th Feb 2013.

Project "Logintime in menubar.xojo_binary_project"
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem AppleAboutthisapplication = "About this application..."
End MenuBar
Class App Inherits Application
EventHandler Sub Close() if s<>nil then s.Close DelayMBS 0.2 // wait for events to flush end if End EventHandler
EventHandler Sub Open() dim f as FolderItem dim t as String s=new NSStatusItemMBS t=GetLoginTimeString if t="" then quit end if // Create statusitem call s.CreateMenu s.Title=t Exception quit End EventHandler
Function GetLoginTimeString() As string dim p as ProcessMBS dim d as CFDictionaryMBS dim cd as CFDateMBS dim co as CFObjectMBS dim g as CFGregorianDateMBS p=GetSystemUIServer d=cfdictionarymbs(p.ProcessInformationCFDictionary) co=d.Value(NewCFStringMBS("LSLaunchTime")) if co = nil then co = d.Value(NewCFStringMBS("LSCheckInTime*")) end if cd=new CFDateMBS cd.Handle=co.Handle cd.RetainObject g=cd.AbsoluteTime.GregorianDate(SystemCFTimeZoneMBS) return Format(g.Hour,"0")+":"+Format(g.Minute,"00") Exception End Function
Function GetSystemUIServer() As ProcessMBS dim p as ProcessMBS dim m as MemoryBlock p=new ProcessMBS p.GetFirstProcess if p.Name="SystemUIServer" then Return p end if while p.GetNextProcess if p.Name="SystemUIServer" then Return p end if wend Exception End Function
Property last As string
Property Protected s As NSStatusItemMBS
End Class
End Project

The items on this page are in the following plugins: MBS MacCocoa Plugin.


The biggest plugin in space...