Microsoft Tech・Ed Japan 2010よりWindows Phone 7ニュース 
8月25日より3日間パシフィコ横浜にて開催された、
今回のメインテーマは
私もこのような連載をさせて頂いており、
Visual Studio 2010 Express for Windows Phoneを使って、
テクニカルセッションでは、
また、
WEC7の特徴としては、
次回のTech・
はじめに
さて、
以前、
そこでMSDNオンラインライブラリで公開されている
- サンプルソースコード:GradientionSample.
zip (24. 9KB)  
WndProcHookerクラスを利用する
WndProcHookerクラスは、
「方法 : WndProcHooker クラスを使用する」
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace GradientionSample
{
    public class WndProcHooker
    {
      // WndProcHookerの実装
    }
}
上記のような形になっていれば問題ありません。次は、
  public sealed class Win32
  {
      // for WndProc.
      public delegate int WndProc(IntPtr hwnd, uint msg, uint wParam, int lParam);
      
      [DllImport("coredll.dll")]
      public extern static IntPtr SetWindowLong(
          IntPtr hwnd, int nIndex, IntPtr dwNewLong);
      public const int GWL_WNDPROC = -4;
      
      [DllImport("coredll.dll")]
      public extern static int CallWindowProc(
          IntPtr lpPrevWndFunc, IntPtr hwnd, uint msg, uint wParam, int lParam);
      
      [DllImport("coredll.dll")]
      public extern static int DefWindowProc(
          IntPtr hwnd, uint msg, uint wParam, int lParam);
      
      // Windows メッセージ
      public const uint WM_PAINT = 0x000F;
      public const uint WM_ERASEBKGND = 0x0014;
      public const uint WM_KEYDOWN = 0x0100;
      public const uint WM_KEYUP = 0x0101;
      public const uint WM_MOUSEMOVE = 0x0200;
      public const uint WM_LBUTTONDOWN = 0x0201;
      public const uint WM_LBUTTONUP = 0x0202;
      public const uint WM_NOTIFY = 0x4E;
      
      // for WM_Paint
      [DllImport("coredll.dll")]
      public extern static IntPtr GetDC(IntPtr hwnd);
      
      [DllImport("coredll.dll")]
      public extern static bool ReleaseDC(IntPtr hwnd, IntPtr hdc);
      
      [DllImport("coredll.dll")]
      public extern static IntPtr BeginPaint(IntPtr hwnd, ref PAINTSTRUCT ps);
      
      [DllImport("coredll.dll")]
      public extern static bool EndPaint(IntPtr hwnd, ref PAINTSTRUCT ps);
      
      public struct PAINTSTRUCT
      {
          private IntPtr hdc;
          public bool fErase;
          public Rectangle rcPaint;
          public bool fRestore;
          public bool fIncUpdate;
          [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
          public byte[] rgbReserved;
      }
      
      public static Point LParamToPoint(int lParam)
      {
          uint ulParam = (uint)lParam;
          return new Point(
              (int)(ulParam & 0x0000ffff),
              (int)((ulParam & 0xffff0000) >> 16));
      }
  }
以上の定義が終われば、
WndProcHookerクラスを使ってボタンコントロールを実装する
前回まで実装していたボタンコントロールは
コンストラクタでWM_ このGradientionButton2をフォームデザイナで、 ちなみにこの対応だけですと、 Controlクラスを継承して作成したグラデーションボタン、 随分長くなってしまいましたが、 以上で今回は終わりです。ありがとうございました。  class GradientionButton2 : System.Windows.Forms.Button 
  {  
      public GradientionButton2()
      {
          // WM_
さいごに
