2010-03-11 3 views
12

작업 표시 줄에 아이콘을 표시하기 위해 NotifyIcon을 사용하고 있습니다. 이 프로그램에는 Windows Form이 없습니다. 아마 하나를 만들고 보이지 않게 만들 수는 있었지만 나는 그것을 피하기를 바랬습니다. NotifyIcon에 첨부 된 툴팁 기능은 다소 부족하며, 여기 전문가 중 한 명은 툴팁 기능을 살펴볼 것을 제안했습니다. 도구 설명을 양식에 첨부 할 수 있습니다. 그것을 NotifyIcon에 첨부 할 수 있습니까? 나는이 할 노력하고있어 :NotifyIcon 및 ToolTip을 결합하십시오.

NotifyIcon CTicon = new NotifyIcon(); 
ToolTip toolTip = new ToolTip(); 
toolTip.SetToolTip(CTicon, "Test"); 

을 그리고 난 오류 " 'System.Windows.Forms.Control'에서 'System.Windows.Forms.NotifyIcon'에서 변환 할 수 없습니다 변환하는 방법이 있나요 얻을.?

toolTip.SetToolTip(CTicon.Container, "Test"); 

하지만 컨테이너는 분명히 하나의 유효한 제어하지 나는이 나 작동하지 않을 수있는 방법의 이해 내 총 부족에 대한 사과

사전에 감사

: 나는 또한 시도했다...
+1

NotifyIcons 및 시스템 트레이는 Windows 7에서이 방법 밖으로에있을 것 같다을, 버튼과 메뉴와 도구 모음의 미리보기가 길에있다 대신에. 새로운 소프트웨어의 경우이를 고려해야 할 수도 있습니다. –

답변

1

NotifyIcon은 화면의 오른쪽 하단에 표시되는 시스템 트레이 아이콘에 사용되며 도구 설명은 텍스트 상자, 확인란 등의 컨트롤에만 사용됩니다 ... 예를 들어 TextBox 인스턴스가 있다고 가정 해 봅시다

 
toolTip1.SetToolTip(textBox1, "Hello World"); 

를 이제, 당신이 위에 마우스를 텍스트 상자, 툴팁이 표시 될 때 ...

1

을 나는 당신이 설정할 수 있습니다 확실하지 않다 : 일하는 것이이보다 양식 '을 textBox1'라는 툴팁은 알림 아이콘에 직접 표시됩니다. 알림 아이콘 자체에서 텍스트 속성을 설정하는 것과 동일한 작업입니다. 알림 아이콘 텍스트에는 몇 가지 제한 사항이 있습니다. 128 자로 제한되어 있으며 짧은 시간 동안 머무를 것입니다. 더 긴 시간 동안 더 많은 정보를 표시하려면 알림 아이콘의 풍선 텍스트 속성을 확인해야합니다. 나는 매우 유용한 MSDN 페이지를 읽는 것이 좋습니다.

http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx

+0

* 참고 : 위에 제공된 링크 아래의 텍스트 설명서에 따르면 텍스트의 한도는 63 자입니다 (예외 섹션 참조). http://msdn.microsoft.com/en-us/library/system.windows .forms.notifyicon.text.aspx –

3

트레이 아이콘 사각형 도구 설명 만 풍선을 지원하지 않습니다. 친절한 말은 아이콘이 일반적으로 매우 가깝기 때문에 풍선에 "줄기"가없는 아이콘이 무엇인지 알기가 어려울 것입니다. NotifyIcon.BalloonTipText 속성을 사용하십시오.

1

안됩니다.

NotifyIcon은 알림을 표시하는 데 사용되는 반면 툴팁은 사용자의 현재 활동에 대한 정보를 표시하는 데 사용되지만 "현재 위치에서"사용해야합니다.

확인 사용자 인터페이스 지침 :

  1. Notifications
  2. Balloons
+1

그건 이론입니다. 지난 10 년 간 또는 실제로 알림 아이콘은 알림에 전혀 사용되지 않고 로우 프로파일 UI에만 사용되었습니다. –

26

뒤늦은 대답하지만, 다른 사람을 위해 어쩌면 유용합니다.

NotifyIcon.Text = "ToolTipText"; 
1

내 컴퓨터의 모든 트레이 아이콘에는 툴팁이 있습니다. Component를 인수로 받아들이는 생성자를 사용하여 NotifyIcon을 만들어야합니다. NotifyIcon.Text 속성을 표시합니다.

내가 여기 예제 코드를 사용하여 하나 만들 수 있었다 : http://msdn.microsoft.com/en-us/library/1by05f8d.aspx

using System; 
using System.Drawing; 
using System.Windows.Forms; 

public class Form1 : System.Windows.Forms.Form 
{ 
    private System.Windows.Forms.NotifyIcon notifyIcon1; 
    private System.Windows.Forms.ContextMenu contextMenu1; 
    private System.Windows.Forms.MenuItem menuItem1; 
    private System.ComponentModel.IContainer components; 

    [STAThread] 
    static void Main() 
    { 
     Application.Run(new Form1()); 
    } 

    public Form1() 
    { 
     this.components = new System.ComponentModel.Container(); 
     this.contextMenu1 = new System.Windows.Forms.ContextMenu(); 
     this.menuItem1 = new System.Windows.Forms.MenuItem(); 

     // Initialize contextMenu1 
     this.contextMenu1.MenuItems.AddRange(
        new System.Windows.Forms.MenuItem[] {this.menuItem1}); 

     // Initialize menuItem1 
     this.menuItem1.Index = 0; 
     this.menuItem1.Text = "E&xit"; 
     this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); 

     // Set up how the form should be displayed. 
     this.ClientSize = new System.Drawing.Size(292, 266); 
     this.Text = "Notify Icon Example"; 

     // Create the NotifyIcon. 
     this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); 

     // The Icon property sets the icon that will appear 
     // in the systray for this application. 
     notifyIcon1.Icon = new Icon("appicon.ico"); 

     // The ContextMenu property sets the menu that will 
     // appear when the systray icon is right clicked. 
     notifyIcon1.ContextMenu = this.contextMenu1; 

     // The Text property sets the text that will be displayed, 
     // in a tooltip, when the mouse hovers over the systray icon. 
     notifyIcon1.Text = "Form1 (NotifyIcon example)"; 
     notifyIcon1.Visible = true; 

     // Handle the DoubleClick event to activate the form. 
     notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); 

    } 

    protected override void Dispose(bool disposing) 
    { 
     // Clean up any components being used. 
     if(disposing) 
      if (components != null) 
       components.Dispose();    

     base.Dispose(disposing); 
    } 

    private void notifyIcon1_DoubleClick(object Sender, EventArgs e) 
    { 
     // Show the form when the user double clicks on the notify icon. 

     // Set the WindowState to normal if the form is minimized. 
     if (this.WindowState == FormWindowState.Minimized) 
      this.WindowState = FormWindowState.Normal; 

     // Activate the form. 
     this.Activate(); 
    } 

    private void menuItem1_Click(object Sender, EventArgs e) { 
     // Close the form, which closes the application. 
     this.Close(); 
    } 
} 
+0

일반적으로 링크를 포함하는 대신 답변의 링크에서 관련 코드를 삽입하려고합니다. –

관련 문제