2017-11-28 7 views
0

私はより使いやすいように古いアプリケーションを再設計しています。私がしたいことの1つは、特定のボタンの上にカーソルを置くと〜(200,200)のデモ用GIFがカーソルの右下に現れることです(ツールチップの機能に似ています)。ツールヒントのテキストをGIFに置き換える

ToolTipクラスの修正が見られましたが、これは過剰と思われます。私は静的なimageBoxを2秒間ホバリングした後に表示することを検討していますが、上記は理想的です。

私は正しい方向に私を導くことができますか?

+1

可能な重複?](https://stackoverflow.com/questions/8264340/display-image-on-mouseover-in-windows-form) –

+0

隠されたImageBoxまたはPanelが最も簡単で必要最小限のコードのようです – Slai

答えて

1

この記事を見てみましょう、それはhttps://www.codeproject.com/Articles/42050/ToolTip-With-Image-C

、特にこの方法ツールチップに画像の段階を詳細:Windowsフォームでのマウスオーバーの[表示画像の

void CustomizedToolTip_Draw(object sender, DrawToolTipEventArgs e) 
{ 
     e.Graphics.CompositingQuality = CompositingQuality.HighQuality; 
     myToolTipRectangle.Size = e.Bounds.Size; 
     e.Graphics.FillRectangle(myBorderBrush, myToolTipRectangle); 
     myImageRectangle = Rectangle.Inflate(myToolTipRectangle, 
       -BORDER_THICKNESS, -BORDER_THICKNESS); 
     e.Graphics.FillRectangle(myBackColorBrush, myImageRectangle); 
     Control parent = e.AssociatedControl; 
     Image toolTipImage = parent.Tag as Image; 
     if (toolTipImage != null) 
     { 
      myImageRectangle.Width = myInternalImageWidth; 
      myTextRectangle = new Rectangle(myImageRectangle.Right, myImageRectangle.Top, 
      (myToolTipRectangle.Width - myImageRectangle.Right - BORDER_THICKNESS), 
         myImageRectangle.Height); 
      myTextRectangle.Location = 
     new Point(myImageRectangle.Right, myImageRectangle.Top); 
      e.Graphics.FillRectangle(myBackColorBrush, myTextRectangle); 
      e.Graphics.DrawImage(toolTipImage, myImageRectangle); 
      e.Graphics.DrawString(e.ToolTipText, myFont, 
      myTextBrush, myTextRectangle, myTextFormat); 
     } 
     else 
     { 
      e.Graphics.DrawString(e.ToolTipText, myFont, 
      myTextBrush, myImageRectangle, myTextFormat); 
     } 
} 
関連する問題