okienko w prawym dolny rogu ekranu

0

Jak zrobić aby moje okienko z cała zawartością programu wyświetlało się przy windowsowym zegarze. Program jest w C# (Windows Form Application).

0

Pobierasz rozdziałkę podstawowego monitora:

int deskHeight = Screen.PrimaryScreen.Bounds.Height;
int deskWidth = Screen.PrimaryScreen.Bounds.Width;

Potem dla swojej formy ustawiasz:

twojaForma.Left =  deskWidth  - twojaForma.Width - 5;
twojaForma.Left =  deskHeight  - twojaForma.Height - 5;

Pamiętaj jednak, że pasek startu nie musi znajdować się na dole ekranu - może być na górze lub na którymś z boków ekranu.

0

Druga linijka zamiast:

twojaForma.Left =  deskHeight  - twojaForma.Height - 5; 

powinno być:

 twojaForma.Top=  deskHeight  - twojaForma.Height - 5;
0

Podkreślił mi na niebiesko:

        [Form1.Left] = deskWidth - [Form1.Width] - 5;
        [Form1.Top] = deskHeight - [Form1.Height] - 5;

To w nawiasach co mi podkreślił.

kod programu:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int deskHeight = Screen.PrimaryScreen.Bounds.Height;
        int deskWidth = Screen.PrimaryScreen.Bounds.Width;

        private void Form1_Load(object sender, EventArgs e)
        {

            Form1.Left = deskWidth - Form1.Width - 5;
            Form1.Top = deskHeight - Form1.Height - 5;
            
            label1.Text += DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;
        }
    }
}
0
private void Form1_Load(object sender, EventArgs e)
        {
            Left = deskWidth - Width - 5;
            Top = deskHeight - Height - 5;
            DateTime teraz = DateTime.Now;
            label1.Text += teraz.Year + "-" + teraz.Month + "-" + teraz.Day;
        }
0

dzięki, działa

0

Mam jeszcze teraz problem z fokusem okna tego. Jak to przerobić, żeby okno miało zawsze fokusa przy debugowaniu.

1 użytkowników online, w tym zalogowanych: 0, gości: 1