Thema: Dimmed Sample

Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#31

AW: Dimmed Sample

  Alt 31. Mär 2012, 12:13
Managed Wrapper_DLL Dimmed_API Class für Dimmed C#
Code:
namespace Dimmed_Api
{
    using System;
    using System.Runtime.InteropServices;
    using System.Security;


    [SuppressUnmanagedCodeSecurity]
    public sealed class Fade
    {

        [DllImport("user32.dll", SetLastError = false)]
        public static extern IntPtr GetDesktopWindow();

        //Dimmed_GetVersion
        public static string Dimmed_GetVersion()
        {
            IntPtr ptr = Dimmed_GetVersionPtr();
            if (ptr != IntPtr.Zero)
            {
                return Marshal.PtrToStringAnsi(ptr);
            }
            return null;
        }       
        [DllImport("dimmed.dll", EntryPoint = "Dimmed_GetVersion", CharSet = CharSet.Auto)]
        private static extern IntPtr Dimmed_GetVersionPtr();      

        //FadeDestroy
        [DllImport("dimmed.dll", EntryPoint = "FadeDestroy", CharSet = CharSet.Auto)]
        public static extern void FadeDestroy();


        //FadeCreate
        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport("dimmed.dll", EntryPoint = "FadeCreate", CharSet = CharSet.Auto)]
        public static extern bool FadeCreate(IntPtr handle, int FadeTime, int clLight, int clDark);

    }
}
Dimmed Sample VB_NET
Code:
Option Explicit On

Imports Dimmed_Api

Public Class Form1

    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

        Fade.FadeDestroy()
    End Sub

    Private Sub cmdDimmMe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDimmMe.Click

        Fade.FadeCreate(Me.Handle, 3500, RGB(255, 255, 255), RGB(0, 0, 0))
    End Sub

    Private Sub cmdDimmDesktop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDimmDesktop.Click

        Fade.FadeCreate(Fade.GetDesktopWindow, 3500, RGB(255, 255, 255), RGB(0, 0, 0))
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.Text = "Dimmed Sample " & "DLLVers. " & Fade.Dimmed_GetVersion
    End Sub

End Class
Dimmed Sample C#
Code:
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;
using Dimmed_Api;

namespace WindowsFormsApplication1
{

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

        private void cmdDimmMe_Click(object sender, EventArgs e)
        {
            Fade.FadeCreate(Handle, 3500, ColorTranslator.ToWin32(Color.FromArgb(255, 255, 255)),
                ColorTranslator.ToWin32(Color.FromArgb(0, 0, 0)));
        }

        private void cmdDimmDesktop_Click(object sender, EventArgs e)
        {
            Fade.FadeCreate(Fade.GetDesktopWindow(), 1500, ColorTranslator.ToWin32(Color.FromArgb(255, 255, 255)),
                ColorTranslator.ToWin32(Color.FromArgb(0, 0, 0)));
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            Fade.FadeDestroy();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Text = "Dimmed Sample " + "DLLVers. " + Fade.Dimmed_GetVersion();
        }
    }
}

gruss

Geändert von EWeiss ( 4. Apr 2012 um 14:47 Uhr)
  Mit Zitat antworten Zitat