Just to make things correctly :
1- Download controlSpy from
http://www.microsoft.com/downloads/d...displaylang=en
2- Run controlSpy6.exe . Go to the button section, Apply the BS_BITMAP
style, and then go to the Message tab and send the "SetImage" message.
3- With Spy++ get the handle of the button and convert it to integer
4- Replace the Handle value in for the Handle variable in the
Form_load of the following code
5- Run the code. (My code is .net 1.0)
<Code>
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Runtime. InteropServices ;
using System.Diagnost ics;
using System.Data;
namespace GetWin32ButtonI mage
{
public class Form1 : System.Windows. Forms.Form
{
private System.Componen tModel.Containe r components = null;
public Form1()
{
InitializeCompo nent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeCompo nent()
{
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHan dler(this.Form1 _Load);
}
#endregion
[DllImport("user 32.dll")]
public static extern IntPtr SendMessage(Int Ptr hwnd, int msg,
IntPtr
wparam, IntPtr lparam);
[STAThread]
static void Main()
{
Application.Run (new Form1());
}
private void Form1_Load(obje ct sender, System.EventArg s e)
{
IntPtr Handle=(IntPtr) 666666; //*** REPLACE THE HANDLE HERE ***//
int BM_GETIMAGE = 246;
IntPtr ImageHandle =
SendMessage(Han dle,BM_GETIMAGE ,IntPtr.Zero,In tPtr.Zero);
System.Drawing. Image MyImg=
System.Drawing. Image.FromHbitm ap(ImageHandle) ;
MessageBox.Show ("We have a valid bitmap!!! :
height="+MyImg. Height.ToString ())
}
}
}
</Code>
Now we have a full working example! ;o) You can skip the 3 first step
if you can find a button with BS_BITMAP style and with an image. (not
an icon...BS_ICON)