NotifyIcon wird nicht angezeigt und Computer schlafen legen

  • C#

    NotifyIcon wird nicht angezeigt und Computer schlafen legen

    Hallo,
    ich habe zwei kleine Probleme:

    1. Ich habe in meinem Programm ein NotifyIcon welches ich auch komplett initialisiere. Allerdings wird es nur angezeigt wenn die Form angezeigt wird. Sobald ein anderes Fenster über der Form liegt wird es nicht mehr angezeigt. Aufgerufen wird es über das KeyDown()-Event was global funktioniert.

    C#-Quellcode

    1. // Designer Quellcode:
    2. // notify
    3. //
    4. this.notify.BalloonTipText = "Test Text";
    5. this.notify.BalloonTipTitle = "Test Titel";
    6. this.notify.Icon = ((System.Drawing.Icon)(resources.GetObject("notify.Icon")));
    7. this.notify.Text = "Test";
    8. this.notify.Visible = true;
    9. this.notify.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notify_MouseClick);
    10. //...
    11. // Anzeigen lassen:
    12. notify.ShowBalloonTip(5000);


    2. Ich nutze die SetThreadExecutionState() Methode um mein Computer daran zu hindern in den Energiesparmodus zu fahren. Das Problem ist, das ich ihn aber gar nicht mehr in den Energiesparmodus bekomme. Application.SetSuspendState() funktioniert nicht mehr.

    C#-Quellcode

    1. // Form1_Load:
    2. SetThreadExecutionState(EXECUTION_STATE.ES_AWAYMODE_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
    3. //...
    4. // Wenn die Sleep-Taste gedrückt wird:
    5. SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED);
    6. //...
    7. // Computer in den Energiesparmodus schalten (funktioniert nicht):
    8. Application.SetSuspendState(PowerState.Suspend, true, true);


    Würde mich über jede Hilfe freuen.
    LG