私は独自のカスタムコントロールを作成しましたが、ここではこのカスタムコントロールを他のコントロールのツールヒントに設定します。だから私は追加したコードは、以下のコードを通じてのsendMessageて失敗SendMessageはツールヒントウィンドウを設定できません
public class MyControl : Control
{
Dictionary<IntPtr, Component> m_tools;
TOOLINFO m_toolInfo;
public MyControl()
{
m_tools = new Dictionary<IntPtr, Component>();
m_toolInfo = new TOOLINFO();
}
string myTipText;
public string MyTipText
{
get
{
return myTipText;
}
set
{
myTipText = value;
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
SolidBrush brush = new SolidBrush(Color.Blue);
e.Graphics.DrawString(this.MyTipText, this.Font, brush, e.ClipRectangle.Location);
}
internal void AddControl(Component component)
{
if (component != null)
{
if (component is Control)
{
Control control = component as Control;
control.HandleCreated += control_HandleCreated;
if (control.IsHandleCreated)
{
control_HandleCreated(control, EventArgs.Empty);
}
}
}
}
void control_HandleCreated(object sender, EventArgs e)
{
Control control = sender as Control;
if(control!=null)
{
m_tools[control.Handle] = control;
m_toolInfo.hwnd = this.Handle;
m_toolInfo.uId = control.Handle;
**int result = WindowsAPI.SendMessage(this.Handle, (int)TTM.TTM_ADDTOOLW, 0, ref m_toolInfo);**
}
}
}
しかしのSendMessage結果をツールチップとしてカスタムコントロールを設定します。私は知っている、なぜカスタムコントロールがコントロールのツールチップとして設定されていない。ここで
は、私は失敗の理由を見つけることができなかったのSendMessage、
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError=true)]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref TOOLINFO lParam);
です。誰か助けてください。
よろしく、 アマルラジU.