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 WindowsApplication11111111111
{
    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(IntPtr hwnd, int nIndex);        #endregion        public Form1()
        {
            InitializeComponent();
            SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW); //API函数加载,实现窗体边框阴影效果
        }
    }
}以上代码用于实现 对窗体产生阴影效果...在网上找的..使用C#可以运行 .但我需要在VC.NET上面使用.麻烦高手帮我改一下.谢谢..C#我不怎么看得懂....谢谢了

解决方案 »

  1.   

    另外我需要将阴影效果再加强一些...应该在什么地方改呢??分不够我再加....在VC.NET2005环境运行通过后马上给分..在线等 
      

  2.   

    C++/CLI的
    #pragma once
    #include<windows.h>
    #pragma comment(lib,"User32.lib")
    namespace test { using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing; /// <summary>
    /// Form1 摘要
    ///
    /// 警告: 如果更改此类的名称,则需要更改
    ///          与此类所依赖的所有 .resx 文件关联的托管资源编译器工具的
    ///          “资源文件名”属性。否则,
    ///          设计器将不能与此窗体的关联
    ///          本地化资源正确交互。
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    Form1(void)
    {
    InitializeComponent();
    //
    //TODO: 在此处添加构造函数代码
    //
    SetClassLong( (HWND)this->Handle.ToInt32() , GCL_STYLE , GetClassLong((HWND)this->Handle.ToInt32(), GCL_STYLE) |0x20000 );
    } protected:
    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    ~Form1()
    {
    if (components)
    {
    delete components;
    }
    } private:
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    System::ComponentModel::Container ^components;#pragma region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    void InitializeComponent(void)
    {
    this->components = gcnew System::ComponentModel::Container();
    this->Size = System::Drawing::Size(300,300);
    this->Text = L"Form1";
    this->Padding = System::Windows::Forms::Padding(0);
    this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    }
    #pragma endregion
    };
    }
      

  3.   


    using System; 
    using System.Collections.Generic; 
    using System.Text; 
    using System.Runtime.InteropServices; 
      
    namespace ServiceMaster 

        class WinAPI 
        { 
            [DllImport("user32.dll")] 
            public extern static IntPtr GetWindow(); 
      
            [DllImport("user32.dll")] 
            public extern static bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags); 
            public static uint LWA_COLORKEY = 0x00000001; 
            public static uint LWA_ALPHA = 0x00000002; 
      
            #region 阴影效果变量 
            //声明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(IntPtr hwnd, int nIndex); 
            [DllImport("user32.dll")] 
            public extern static uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong); 
            [DllImport("user32.dll")] 
            public extern static uint GetWindowLong(IntPtr hwnd, int nIndex); 
            #endregion 
      
            public enum WindowStyle : int 
            { 
                GWL_EXSTYLE = -20 
            } 
      
            public enum ExWindowStyle : uint 
            { 
                WS_EX_LAYERED = 0x00080000 
            } 
      
        } 
    }
    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Text; 
    using System.Windows.Forms; 
    using System.ServiceProcess; 
    using System.IO; 
    namespace ServiceMaster 

        public partial class MainFrom : Form 
        { 
            public MainFrom() 
            { 
                InitializeComponent();            
                const int CS_DropSHADOW = 0x20000; 
                const int GCL_STYLE = (-26);   
                WinAPI.SetClassLong(this.Handle, GCL_STYLE, WinAPI.GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW); 
            } 
            protected override CreateParams CreateParams 
            { 
                get 
                { 
                    CreateParams cp = base.CreateParams; 
      
                    cp.Parent = WinAPI.GetWindow(); 
                    return cp; 
                } 
            } 
      
            private void SetWindowShadow(byte bAlpha) 
            { 
                WinAPI.SetWindowLong(this.Handle, (int)WinAPI.WindowStyle.GWL_EXSTYLE, 
                WinAPI.GetWindowLong(this.Handle, (int)WinAPI.WindowStyle.GWL_EXSTYLE) | (uint)WinAPI.ExWindowStyle.WS_EX_LAYERED); 
      
                WinAPI.SetLayeredWindowAttributes(this.Handle, 0, bAlpha, WinAPI.LWA_COLORKEY | WinAPI.LWA_ALPHA); 
            } 
    }