2008. december 29., hétfő

How to draw text on the Windows taskbar


Problem/Question/Abstract:

Does anyone know how to write a text on the main taskbar in Win95 using Delphi 3.0?

Answer:

This modified splash procedure that I use draws text directly on the Start button. Perhaps it helps. I normally use it to draw splash text directly on screen. To do that, use DC:= GetDC(0):


procedure TForm1.Button1Click(Sender: TObject);
var
  DC: hDC;
  Size: TSize;
  Font: hFont;
const
  DispText = 'Test';
begin
  DC := GetDC(GetDlgItem(FindWindow(PChar('Shell_TrayWnd'), nil), $130));
  ShowMessage(IntToStr(GetDlgItem(FindWindow(PChar('Shell_TrayWnd'), nil), $130)));
  SetBkMode(DC, TRANSPARENT);
  Font := CreateFont(12, 10, 0, 0, 1000, 0, 0, 0, ANSI_CHARSET, OUT_DEVICE_PRECIS,
    CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, 'ARIAL');
  SelectObject(DC, Font);
  SetTextColor(DC, RGB(128, 128, 0));
  GetTextExtentPoint(DC, PChar(DispText), Length(DispText), Size);
  TextOut(DC, 0, 0, PChar(DispText), Length(DispText));
  DeleteObject(Font);
  ReleaseDC(GetDlgItem(FindWindow(PChar('Shell_TrayWnd'), nil), $130), DC);
end;

Nincsenek megjegyzések:

Megjegyzés küldése