Hallo,
Ich möchtest einfach nur die (Tray)Icons, die in der Prozedure erstellt werden, nebeneinander auf eine Form bringen, als TImage oder sonstiges. Ich möchte also keine Listbox mehr benutzen müssen.
Wie mache ich das?
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| for x := 1 to LV.items.count-1 do begin task[1]:= TImage.Create(nil); with task[1] do begin Parent := frmMain; Height := 27; Width := 100; Top := 12; Picture.Icon := TIcon.Create; Stretch := true; if x <> 0 then Left := Width * x + (x-2)*Height else Left := Parent.Width - Width * 3 div 2; Show; Repaint end; end; |
Der gesamte Code:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116:
| procedure TfrmMain.FillLV(); var ticons: arrTray; LI: TListItem; x: Cardinal; hTray: Cardinal; stdico: TIcon; sys: Systray; begin
hTray := GethWndTray();
IL.Clear; IL.Height := 16; IL.Width := 16; LV.SmallImages := IL;
LV.Items.Clear;
if IsWindowsNT = True then begin InitPSAPI; ticons := GetTrayIcons; for x := 0 to High(ticons) do begin stdico := TIcon.Create; stdico.Handle := ticons[x].hIcon; if IL.AddIcon(stdico) = -1 then begin stdico.Handle := GetTrayIcon_NT(hTray, ticons[x].iBitmap); IL.AddIcon(stdico); DestroyIcon(stdico.Handle); end; stdico.ReleaseHandle; stdico.Free;
LI := LV.Items.Add; LI.ImageIndex := x; LI.Caption := ticons[x].uniPath;
LI.SubItems.Add(ticons[x].sTip); LI.SubItems.Add(IntToStr(ticons[x].hwnd)); LI.SubItems.Add(IntToStr(ticons[x].uID)); LI.SubItems.Add(IntToStr(ticons[x].idCommand)); LI.SubItems.Add(GetState(ticons[x].fsState)); LI.SubItems.Add('Bouton'); LI.SubItems.Add(IntToStr(ticons[x].iBitmap)); LI.SubItems.Add('$' + IntToHex(ticons[x].uCallbackMessage, 8)); end; UninitPSAPI; end else begin sys := GetTrayIcons_9x();
for x := 0 to sys.lpsysListHeader.dwCount - 1 do begin stdico := TIcon.Create; stdico.Handle := GetTrayIcon_9x(hTray, sys.hImageList, sys.lpsysListHeader.lpNotifyDataList[x].dwImageIndex); IL.AddIcon(stdico); DestroyIcon(stdico.Handle); stdico.ReleaseHandle; stdico.Free;
LI := LV.Items.Add; LI.ImageIndex := x; LI.Caption := sys.lpsysListHeader.lpNotifyDataList[x].Path;
LI.SubItems.Add(sys.lpsysListHeader.lpNotifyDataList[x].NotifyDataA.szTip); LI.SubItems.Add(IntToStr(sys.lpsysListHeader.lpNotifyDataList[x].NotifyDataA.hwnd)); LI.SubItems.Add(IntToStr(sys.lpsysListHeader.lpNotifyDataList[x].NotifyDataA.uID)); LI.SubItems.Add(IntToStr(sys.lpsysListHeader.lpNotifyDataList[x].NotifyDataA.uID)); LI.SubItems.Add('No'); LI.SubItems.Add('Bouton'); LI.SubItems.Add(IntToStr(sys.lpsysListHeader.lpNotifyDataList[x].dwImageIndex)); LI.SubItems.Add('$' + IntToHex(sys.lpsysListHeader.lpNotifyDataList[x].NotifyDataA.uCallbackMessage, 8)); end; end;
for x := 1 to LV.items.count-1 do begin task[1]:= TImage.Create(nil); with task[1] do begin Parent := frmMain; Height := 27; Width := 100; Top := 12; Picture.Icon := TIcon.Create; Stretch := true; if x <> 0 then Left := Width * x + (x-2)*Height else Left := Parent.Width - Width * 3 div 2; Show; Repaint end; end;
UninstallHook; end; |