zoukankan      html  css  js  c++  java
  • 圣诞树小程序的制作

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace WindowsFormsApp2
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    string pyth = System.IO.Directory.GetCurrentDirectory();
    pictureBox1.Image = Image.FromFile(pyth + "\img.gif");
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    this.TransparencyKey = this.BackColor;
    }
    [DllImport("user32.dll")]//拖动无窗体的控件
    public static extern bool ReleaseCapture();
    [DllImport("user32.dll")]
    public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
    public const int WM_SYSCOMMAND = 0x0112;
    public const int SC_MOVE = 0xF010;
    public const int HTCAPTION = 0x0002;
    private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
    {
    ReleaseCapture();
    SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
    }
    private void 结束ToolStripMenuItem_Click(object sender, EventArgs e)
    {
    this.Close();
    }

    private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
    {
    if (e.Button == MouseButtons.Right)
    {
    contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
    }
    }
    }
    }

    最主要的是这行代码:this.TransparencyKey = this.BackColor;消除了窗口自带的底色。

  • 相关阅读:
    关于C#调用VC SDK小结
    失业日志:2009年10月15日 猫 老鼠 人(一)
    闲聊日志 一:
    按编号分类的树
    不知不觉又用到了VC6
    这个问题很郁闷.net mvc,也可能我不知道
    失业日志:2008年10月13日
    失业日志:2009年10月16日 能回忆多少就写多少
    失业日志:2009年10月12日星期一
    失业日志 200910月22日
  • 原文地址:https://www.cnblogs.com/WordHorizon/p/12121018.html
Copyright © 2011-2022 走看看