unit DialogRes;

interface

uses
  Windows, Messages, SysUtils;

var
  DialogAtom: TAtom;

const
  MC_MENU_START = 40000;
  MC_ABOUT      = 40000;
  MC_OPTIONS    = 40001;
  MC_REFRESH    = 40002;
  MC_HIDE       = 40003;
  MC_SHOW       = 40004;
  MC_DETAILS    = 40005;
  MC_RESTART    = 40007;
  MC_EXIT       = 40008;
  MC_ADDWIDGET  = 40009;
  MC_DELETE     = 40010;
  MC_LANGUAGES  = 40011;
  MC_PREFRENCES = 40012;
  MC_MENU_END   = MC_LANGUAGES;

  MC_WIDGETS_START  = 50000;
  MC_LANGUAGE_START = 30000;

const
  IDM_MAINMENU      = 101;
  IDM_TRAYMENU      = 102;

  IDD_SETTINGS_DLG  = 101;
  IDD_ADDWIDGET_DLG = 102;

{ GetTextLen }
function GetTextLen(Wnd: HWND): Integer;
{ GetTextBuf }
function GetTextBuf(Wnd: HWND; Buffer: PWideChar; BufSize: Integer): Integer;
{ GetText }
function GetText(Wnd: HWND): WideString;

implementation

{ GetTextLen }
function GetTextLen(Wnd: HWND): Integer;
begin
  Result := SendMessageW(Wnd, WM_GETTEXTLENGTH, 0, 0);
end;

{ GetTextBuf }
function GetTextBuf(Wnd: HWND; Buffer: PWideChar; BufSize: Integer): Integer;
begin
  Result := SendMessageW(Wnd, WM_GETTEXT, BufSize, Longint(Buffer));
end;

{ GetText }
function GetText(Wnd: HWND): WideString;
var
  Len: Integer;
begin
  Len := GetTextLen(Wnd);
  SetString(Result, PWideChar(nil), Len);
  if Len <> 0 then GetTextBuf(Wnd, PWideChar(Result), Len + 1);
end;

end.
