Example: /MacCocoa/NSStatusItem/Logintime in menubar

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

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.


💬 Ask a question or report a problem