Mega Code Archive

 
Categories / Delphi / VCL
 

DisplayItemOnStatusPanel

Title: DisplayItemOnStatusPanel Question: I like to put CapsLock, NumLock, Time, and whether user is in INS or Overwrite mode. Developed this function to assign the text for a particular StatusPanel at runtime, and to have it toggle the information based on the keyboard status. Answer: procedure DisplayItemOnStatusPanel(item : string; pnlName : TStatusPanel); var StartTime : TDateTime; begin if item = 'CAPS' then begin if odd (GetKeyState (VK_CAPITAL)) then pnlName.text := 'CAPS' else pnlName.text := ''; end; if item = 'NUM' then begin if odd (GetKeyState (VK_NUMLOCK)) then pnlName.text := 'NUM' else pnlName.text := ''; end; if item = 'INS' then begin if odd (GetKeyState (VK_INSERT)) then pnlName.text := 'INS' else pnlName.text := 'OVR'; end; if item = 'SCROLL' then begin if odd (GetKeyState (VK_SCROLL)) then pnlName.text := 'Scroll' else pnlName.text := ''; end; if item = 'TIME' then begin pnlName.text := TimeToStr(Time); end; end;