国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#窗體邊框陰影效果的實現方法

2023-05-18 12:33:13
字體:
來源:轉載
供稿:網友

如果給C#編寫的窗口邊框加上陰影,將使窗體變得非???,但這需要借助windows的動態鏈接庫(win32 API)來實現,下面就給出了一個小實例來演示一下。

//首先引入相關的命名空間,除最下面的那個之外其余都由程序自動添加

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

namespace winForm //程序的命名空間
{
   public partial class Form1 : Form
  {
      #region 窗體邊框陰影效果變量申明
     const int CS_DropSHADOW = 0x20000;
     const int GCL_STYLE = (-26);

        //聲明Win32 API
   [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int SetClassLong(IntPtr hwnd, int nIndex, int dwNewLong);
   [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int GetClassLong_r(IntPtr hwnd, int nIndex);

     #endregion
    public Form1()
   {
         InitializeComponent();
       SetClassLong(this.Handle, GCL_STYLE, GetClassLong_r(this.Handle, GCL_STYLE) | CS_DropSHADOW); //API函數加載,實現窗體邊框陰影效果
    }
 }
}

通過這個例子你應該熟悉DLL函數的引入方法,當然這些函數你可以查一下相關手冊,看看如何使用。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙川县| 西乌| 元谋县| 申扎县| 永兴县| 眉山市| 洛隆县| 庆元县| 福清市| 家居| 达州市| 江北区| 古交市| 夹江县| 庆安县| 松潘县| 平定县| 长岭县| 荥阳市| 横山县| 贵德县| 大兴区| 天柱县| 临泉县| 乐亭县| 抚宁县| 英吉沙县| 新郑市| 建阳市| 大城县| 西乡县| 融水| 鹰潭市| 本溪市| 遂平县| 乌审旗| 阿城市| 根河市| 凤凰县| 舒城县| 无极县|