我想在我的应用程序中使用气球类型ui创建一些提示,让用户看到有关特定情况下需要采取的某些操作的信息,但吸取了一些代码,我看着论坛。 我发现的气球提示的一个例子是在以下网站http://www.tek-tips.com/viewthread.cfm?qid=1611641。我认为它是在C++ Builder 2009 IDE中创建的,并且 试图使用C builder 2010 IDE RS编译它,但我无法获得任何气球提示。 首先,当我编译时,它停止在如下行,如
GetClientRect(hWnd, &ti.rect);
然后我将其更改为GetWindowRect的原因GetClientRect
不需要任何参数传递给此方法,虽然我改变了clint到窗口然后我终于跑了它......认为它会显示提示,但没有任何工具提示。如何创建气球提示?
另外我已经提供了我提供的链接代码。
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
typedef struct{
unsigned long cbStruct;
PWChar pszTitle;
PWChar pszText;
int ttiIcon;
} tagEDITBALLOONTIP;
tagEDITBALLOONTIP *EDITHINT;
void __fastcall TForm1::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); // the only problem is here
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::Button1Click(TObject *Sender)
{
ShowBalloonTip(Button1, 1, "ik0","Example on how to create Balloon Tips in C++ Builder", ColorBox1->Selected,ColorBox2->Selected);
}`
然后我问如何让它在builder 2010中工作IDE? 我不知道为什么它通过使用Windows API funcs中像所提供2个PARAMS,当我编译它在C++ Builder在Windows 7 2010 IDE它说没有任何参数预计于2009年IDE工作...
删除方法ShowBalloonTip之前的名称空间并且它已经工作。我认为如果它继承自TCustomForm类'GetClientRect',它将改变它的方法签名而不带参数! :) –
您正尝试从'TForm'方法中调用Win32 API'GetClientRect()'函数。由于'TForm'从'TControl'继承了一个单独的'GetClientRect()'方法,所以你必须告诉编译器调用哪一个。如果要调用Win32 API函数而不是'TControl :: GetClientRect()'方法,请指定全局名称空间,例如:':: GetClientRect(parameters here);'。 –
感谢您的澄清! –