Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Standard Toolbar Buttons

I want to include standard windows toolbar buttons in a .net winform.

I've hunted around google groups and found the following:

        [DllImport("user32.dll", CharSet=CharSet.Auto)]
        public static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, int lParam);
        public int TB_LOADIMAGES = (0x0400+50);
        public int  HINST_COMMCTRL = -1;
        public int IDB_STD_SMALL_COLOR = 0;

        public StandardButtons()


            for(int i = 0;i<255;i++)
                ToolBarButton tb = new ToolBarButton() ;
                tb.ImageIndex = i;


            SendMessage(new HandleRef(null, toolBar1.Handle), this.TB_LOADIMAGES,
                this.IDB_STD_SMALL_COLOR, this.HINST_COMMCTRL);


This code "works" but only gives me 15 different icons.

Any thoughts on how to get "all" of the icons?



Charles Reich
Wednesday, October 22, 2003

I've also found the directory:

C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Graphics

But these seem to be not entirely complete.

In particular, I am looking for the "greyed-out" versions of some of the buttons to indicate that they are not enabled at some points of the program.

Charles Reich
Wednesday, October 22, 2003

You were only getting 15 because there are only 15 'standard' buttons for IDB_STD_LARGE_COLOR and IDB_STD_SMALL_COLOR.

Either use PrintScreen to grab any other icons you need, or one of the shareware icon grabbers out there (they extract the icons from the DLL/EXE resource segments).

Duncan Smart
Thursday, October 23, 2003

Thanks for pointing me in the right direction Duncan.

Charles Reich
Thursday, October 23, 2003

*  Recent Topics

*  Fog Creek Home