Home > Back-end >  Show small window with image from CLI
Show small window with image from CLI

Time:05-25

What the problem in this code i've written ?

using System;
using System.Windows.Forms;
public class stfu {
    public static void Main() 
    {
        Console.WriteLine("Hello Toxic world!");
        var f = new Form();
        f.FormBorderStyle = FormBorderStyle.None;
        f.Controls.Add(new PictureBox() { ImageLocation = @"image.png",Dock = DockStyle.Fill});
        f.Show();
        Console.ReadLine();
    }
}

form not responding. . .

CodePudding user response:

You need invoke Application.Run() method to properly process window's messages:

var f = new Form();
// init form here
Application.Run(f);
  •  Tags:  
  • c#
  • Related