Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Delphi программирование > Общие вопросы Delphi
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 08.12.2011, 20:15   #1
hon
Форумчанин
 
Регистрация: 08.06.2011
Сообщений: 693
По умолчанию Как сделать Hint над Edit'ом

Как такое реализовать в Delphi?
Пример:
Изображения
Тип файла: jpg Hint над Edit'ом.jpg (68.9 Кб, 126 просмотров)
hon вне форума Ответить с цитированием
Старый 09.12.2011, 01:57   #2
Баламут
Баламучу слегка...
Участник клуба
 
Аватар для Баламут
 
Регистрация: 01.11.2006
Сообщений: 1,585
По умолчанию

Примерно так. С деталями думаю разберешься
Код:
var
  hnw: THintWindow;
  r: TRect;
..........................
    hnw := THintWindow.Create(Self);
    hnw.ActivateHint(r, 'Недопустимый символ');
    .................
    hnw.ReleaseHandle;
Баламут вне форума Ответить с цитированием
Старый 09.12.2011, 04:40   #3
GunSmoker
Старожил
 
Регистрация: 13.08.2009
Сообщений: 2,581
По умолчанию

EM_SHOWBALLOONTIP
Опытный программист на C++ легко решает любые не существующие в Паскале проблемы.
GunSmoker вне форума Ответить с цитированием
Старый 09.12.2011, 04:46   #4
GunSmoker
Старожил
 
Регистрация: 13.08.2009
Сообщений: 2,581
По умолчанию

Код:
unit BalloonTooltips;

interface

uses
  Windows, SysUtils, Dialogs, Controls;

procedure BTMessageDlg(const Msg: WideString; DlgType: TMsgDlgType;
                        AEditorControl : TWinControl);
procedure BTShowMessage(const Msg: string;
                        AEditorControl : TWinControl); 
procedure BTShowMessageFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
procedure BTShowError(const Msg: string;
                        AEditorControl : TWinControl);
procedure BTShowErrorFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
procedure BTShowWarning(const Msg: String;
                        AEditorControl: TWinControl);
procedure BTShowWarningFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
procedure BTShowInfo(const Msg: string;
                        AEditorControl : TWinControl);
procedure BTShowInfoFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
function  BTCancel(AEditorControl : TWinControl): Boolean;

implementation

uses
  Messages;

type
  _tagEDITBALLOONTIP = packed record
    cbStruct: DWORD;
    pszTitle: LPCWSTR;
    pszText: LPCWSTR;
    ttiIcon: Integer;
  end;
  PEditBalloonTip = ^TEditBalloonTip;
  TEditBalloonTip = _tagEDITBALLOONTIP;

const
  ECM_FIRST                   = $1500;
  EM_SHOWBALLOONTIP           = ECM_FIRST + 3;
  EM_HIDEBALLOONTIP           = ECM_FIRST + 4;
  TTI_NONE                    = 0;
  TTI_INFO                    = 1;
  TTI_WARNING                 = 2;
  TTI_ERROR                   = 3;

resourcestring
  BTError = 'Ошибка';
  BTInfo = 'Информация';
  BTWarning = 'Предупреждение';

function Edit_ShowBalloonTip(hwnd: HWND; const peditballoontip: TEditBalloonTip): BOOL;
begin
  Result := BOOL(SendMessage(hwnd, EM_SHOWBALLOONTIP, 0, lParam(@peditballoontip)));
end;

function Edit_HideBalloonTip(hwnd: HWND): BOOL; 
begin
  Result := BOOL(SendMessage(hwnd, EM_HIDEBALLOONTIP, 0, 0));
end;

procedure BTMessageDlg(const Msg: WideString; DlgType: TMsgDlgType;
                        AEditorControl : TWinControl);
var
  Caption: WideString;
  Params: TEditBalloonTip;
begin
  Assert(AEditorControl <> nil);
  FillChar(Params, SizeOf(Params), 0);
  Params.cbStruct := SizeOf(Params);
  case DlgType of
    mtWarning:
    begin
      Caption := BTWarning;
      Params.pszTitle := PWideChar(Caption);
      Params.pszText := PWideChar(Msg);
      Params.ttiIcon := TTI_WARNING;
    end;
    mtError:
    begin
      Caption := BTError;
      Params.pszTitle := PWideChar(Caption);
      Params.pszText := PWideChar(Msg);
      Params.ttiIcon := TTI_ERROR;
    end;
    mtInformation, mtConfirmation:
    begin
      Caption := BTInfo;
      Params.pszTitle := PWideChar(Caption);
      Params.pszText := PWideChar(Msg);
      Params.ttiIcon := TTI_INFO;
    end;
  else
    begin
      Params.pszTitle := nil;
      Params.pszText := PWideChar(Msg);
      Params.ttiIcon := TTI_NONE;
    end;
  end;
  Edit_ShowBalloonTip(AEditorControl.Handle, Params);
end;

procedure BTShowMessage(const Msg: string;
                        AEditorControl : TWinControl);
begin
  BTMessageDlg(Msg, mtCustom, AEditorControl);
end;

procedure BTShowMessageFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
begin
  BTMessageDlg(Format(Msg, Params), mtCustom, AEditorControl);
end;

procedure BTShowError(const Msg: string;
                        AEditorControl : TWinControl); 
begin
  BTMessageDlg(Msg, mtError, AEditorControl);
end;

procedure BTShowErrorFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
begin
  BTMessageDlg(Format(Msg, Params), mtError, AEditorControl);
end;

procedure BTShowWarning(const Msg: String;
                        AEditorControl: TWinControl);
begin
  BTMessageDlg(Msg, mtWarning, AEditorControl);
end;

procedure BTShowWarningFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
begin
  BTMessageDlg(Format(Msg, Params), mtWarning, AEditorControl);
end;

procedure BTShowInfo(const Msg: string;
                        AEditorControl : TWinControl);
begin
  BTMessageDlg(Msg, mtInformation, AEditorControl);
end;

procedure BTShowInfoFmt(const Msg: string; Params : array of const;
                        AEditorControl : TWinControl);
begin
  BTMessageDlg(Format(Msg, Params), mtInformation, AEditorControl);
end;

function  BTCancel(AEditorControl : TWinControl): Boolean;
begin
  Result := Edit_HideBalloonTip(AEditorControl.Handle);
end;

end.
Опытный программист на C++ легко решает любые не существующие в Паскале проблемы.
GunSmoker вне форума Ответить с цитированием
Старый 09.12.2011, 10:57   #5
FaTaL
Участник клуба
 
Аватар для FaTaL
 
Регистрация: 09.11.2007
Сообщений: 1,761
По умолчанию

В последних версиях Delphi если Едиту поставить свойство не помню как точно, но примерно NumberOnly в True, то такой хинт сам по себе будет выходить.
FaTaL вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Над изменить или помочь сделать 2 программки... SilverShield Помощь студентам 0 29.12.2010 00:30
Как вызвать Message с Edit'ом? Port 111 Общие вопросы Delphi 7 02.02.2009 02:18
Как сделать чтобы форма была над трэем Bigtyoma Общие вопросы Delphi 2 24.09.2008 17:40
проблема с пустым edit'ом SMERSH Помощь студентам 2 15.09.2008 19:26
Как сделать подсказку? (Hint) Aboltus Общие вопросы Delphi 2 29.07.2008 21:30