C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 팁&트릭
C++Builder Programming Tip&Tricks
[745] [Win32] 풍선(balloon)모양 도움말 - 펌
장성호 [nasilso] 9188 읽음    2008-02-23 19:05
첨부한 그림처럼 풍선모양으로 힌트(도움말)이 나타납니다.





[출처]
http://blog.naver.com/cscn2000?Redirect=Log&logNo=30005896949
http://blog.naver.com/cscn2000?Redirect=Log&logNo=30005896933

uses
   Commctrl;

procedure ShowBalloonTip(Control: TWinControl; Icon: integer; Title: pchar; Text: PWideChar;
BackCL, TextCL: TColor);
const
  TOOLTIPS_CLASS = 'tooltips_class32';
  TTS_ALWAYSTIP = $01;
  TTS_NOPREFIX = $02;
  TTS_BALLOON = $40;
  TTF_SUBCLASS = $0010;
  TTF_TRANSPARENT = $0100;
  TTF_CENTERTIP = $0002;
  TTM_ADDTOOL = $0400 + 50;
  TTM_SETTITLE = (WM_USER + 32);
  ICC_WIN95_CLASSES = $000000FF;
type
  TOOLINFO = packed record
    cbSize: Integer;
    uFlags: Integer;
    hwnd: THandle;
    uId: Integer;
    rect: TRect;
    hinst: THandle;
    lpszText: PWideChar;
    lParam: Integer;
  end;
var
  hWndTip: THandle;
  ti: TOOLINFO;
  hWnd: THandle;
begin
  hWnd    := Control.Handle;
  hWndTip := CreateWindow(TOOLTIPS_CLASS, nil,
    WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP,
    0, 0, 0, 0, hWnd, 0, HInstance, nil);
  if hWndTip <> 0 then
  begin
    SetWindowPos(hWndTip, HWND_TOPMOST, 0, 0, 0, 0,
      SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
    ti.cbSize := SizeOf(ti);
    ti.uFlags := TTF_CENTERTIP or TTF_TRANSPARENT or TTF_SUBCLASS;
    ti.hwnd := hWnd;
    ti.lpszText := Text;
    Windows.GetClientRect(hWnd, ti.rect);
    SendMessage(hWndTip, TTM_SETTIPBKCOLOR, BackCL, 0);
    SendMessage(hWndTip, TTM_SETTIPTEXTCOLOR, TextCL, 0);
    SendMessage(hWndTip, TTM_ADDTOOL, 1, Integer(@ti));
    SendMessage(hWndTip, TTM_SETTITLE, Icon mod 4, Integer(Title));
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowBalloonTip(Button1, 1, 'Title',
  'Balloon tooltip,http://kingron.myetang.com; updated by Calin', clBlue, clNavy);
end;



//  C++Builder 로 변환하면...
void __fastcall ShowBalloonTip(TWinControl *Control,int  Icon,char *Title,char *Text,TColor BackCL,TColor TextCL)
{
    HWND hWndTip;
    TOOLINFO ti;
    HWND hWnd;

    hWnd    = Control->Handle;
    hWndTip = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_BALLOON | TTS_ALWAYSTIP, 0, 0, 0, 0, hWnd, 0, HInstance, NULL);
    if( hWndTip )
    {
        SetWindowPos(hWndTip, HWND_TOPMOST, 0, 0, 0, 0,
          SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
        ti.cbSize = sizeof(ti);
        ti.uFlags = TTF_CENTERTIP | TTF_TRANSPARENT | TTF_SUBCLASS;
        ti.hwnd = hWnd;
        ti.lpszText = Text;
        GetClientRect(hWnd, &ti.rect);
        SendMessage(hWndTip, TTM_SETTIPBKCOLOR, BackCL, 0);
        SendMessage(hWndTip, TTM_SETTIPTEXTCOLOR, TextCL, 0);
        SendMessage(hWndTip, TTM_ADDTOOL, 1, Integer(&ti));
        SendMessage(hWndTip, TTM_SETTITLE, Icon % 4, Integer(Title));
    }
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
    ShowBalloonTip(Button1, 1, "Title","Balloon tooltip,http://kingron.myetang.com; updated by Calin", clGreen, clNavy);
}


그런데 아쉬운점은 Application 전체에 적용되는것이 아니라
설정한 Control에서만  그렇게 보인다는것입니다.

누가 "tooltips_class32" 를 슈퍼클래싱해서  HintWindowClass에 등록할수 있도록 해주실수 없나요?
Application 전체에 적용되도록...

그럼...
김태선 [cppbuilder]   2008-02-25 20:38 X
저도 부탁. 누가 좀 해주세요.
시삽님. plz @..@;

+ -

관련 글 리스트
745 [Win32] 풍선(balloon)모양 도움말 - 펌 장성호 9188 2008/02/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.