3

I'm having trouble finding a way to change the background color of the AxTOCControl. Is there an easy way to do this? I'm using ArcEngine 10 C# and VS2010. Thanks

2 Answers 2

4

Nope, we could not find a way to do it. See my thread How to set background color in TOC? on the ESRI forum.

Update: We could not find a way to change the color of the TOC. So we change the background of the swatch instead. We did that by looping through layers casting to ILagendInfo and updating the bitmap in the IPictureMarkerSymbol, converting all pixels with background color to gray making the white symbols to show up.

Might be a good Idea to vote on this ArcGIS Engine Idea

2

my guess is the first child hwnd under the main AxTocControl's hwnd is the treeview itself (you may want to try the top level one as well). You can use the following (unchecked) code to change a treeview's background color

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
static int TV_FIRST = 0x1100;
static int TVM_SETBKCOLOR = (TV_FIRST + 29);

private void ChangeBGColor(IntPtr tv_hwnd, Color color)
{
    int c = System.Drawing.ColorTranslator.ToWin32(color);
    SendMessage(tv_hwnd, TVM_SETBKCOLOR, IntPtr.Zero, new IntPtr(c));
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.