none
IE .net toolbar (C# Zolnikov's Toolband and .net kbbar) on IE 7: toolbar unmovable! RRS feed

Answers

  • I'm not quite sure what is giving you difficulty so forgive me if I seem verbose.

    Basically, everything in the ComInterop.cs is the same as the original except for the addition of the new flags enum and one other line.
    When complete you should have a DBIM enum, DBIMF enum and the previous code.

    Now, in public struct DESKBANDINFO the original looks like:
    [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
    public struct DESKBANDINFO
    {
    public UInt32 dwMask;
    public Point ptMinSize;
    public Point ptMaxSize;
    public Point ptIntegral;
    public Point ptActual;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst=255)]
    public String wszTitle;
    public DBIM dwModeFlags;
    public Int32 crBkgnd;
    };

    However, you will note that I stated dwMask should use the DBIM(deskband info mask) enum and dwModeFlags should use the DBIMF(deskband info mode flag) enum.
    The enums we created map to constants in the COM documentation and headers.

    The new DESKBANDINFO should look like this:
    [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
    public struct DESKBANDINFO
    {
    public DBIM dwMask;
    public Point ptMinSize;
    public Point ptMaxSize;
    public Point ptIntegral;
    public Point ptActual;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst=255)]
    public String wszTitle;
    public DBIMF dwModeFlags;
    public Int32 crBkgnd;
    };

    Notice that dwMask is now of type DBIM and DBIMF is now of type dwModeFlags. This allows us to specify a value from the enums to use in those fields. This gives us the advantage of readability and not having to memorize the various vaules of the constants. All our flags can be accessed either by DBMI. or DBMIF.

    Anywhere in which you use the dwMask field or the dwModeFlags field, you will need to specify one of the DBIM or DBIMF enumeration or you can cast an uint as one of these enums. Alternatively you can cast the enum as a uint if you need to use it in that manner for some reason.

    Since these enums are flags, we can set a number of different values using the OR(|) bitwise operator on any number of flags.
    For example, if you wanted your toolbar to be undeletable and use a chevron then you could do:
    dwModeFlags = DBIMF.UNDELETABLE | DBIMF.USECHEVRON;
    The MSDN documentation on deskbands has information on what each of these flags does.

    In essence, in order to obtain a complete ComInterop.cs file simply add the enum in my previous post and make the change to the deskband struct as described above.

    Hope this helps,
    Matthew Morrow
    Wednesday, November 8, 2006 11:42 PM

All replies

  • Hello,
    I was experiencing the same situation. Skip to the bottom if you want a straight-up answer.
    I've noticed a few problems with both of the mentioned implementations. I'll talk about the Zolnikov implementation.
    First off, I recommend adding the following enum which is specified in the MSDN library:

    In ComInterop.cs:
    [Flags]
    public enum DBIMF : uint
    {
        NORMAL = 0x0001,
        FIXED = 0x0002,
        FIXEDBMP = 0x0004,
        VARIABLEHEIGHT = 0x0008,
        UNDELETEABLE = 0x0010,
        DEBOSSED = 0x0020,
        BKCOLOR = 0x0040,
        USECHEVRON = 0x0080,
        BREAK = 0x0100,
        ADDTOFRONT = 0x0200,
        TOPALIGN = 0x0400,
        NOGRIPPER = 0x0800,
        ALWAYSGRIPPER = 0x1000,
        NOMARGINS = 0x2000
    }

    This enum is used in the DESKBANDINFO struct for the dwModeFlags.

    Next, we need to change the way GetBandInfo works.
    In GetBandInfo, the Zolnikov implementation errorfully sets the dwModeFlags to the DBIM(mask flags). This is wrong. Mask flags are used by dwMask in order for the browser to specify which values it is requesting. The implementation current does not regard this and instead sets everything.
    I found a Microsoft ATL example and here is how GetBandInfo should look:

    public virtual void GetBandInfo(
        UInt32 dwBandID,
        UInt32 dwViewMode,
        ref DESKBANDINFO dbi )
    {

        if ( ( dbi.dwMask & DBIM.MINSIZE ) != 0 )
        {
            dbi.ptMinSize.X = this.MinSize.Width;
            dbi.ptMinSize.Y = this.MinSize.Height;
        }

        if ( ( dbi.dwMask & DBIM.MAXSIZE ) != 0 )
        {
            dbi.ptMaxSize.X = this.MaxSize.Width;
            dbi.ptMaxSize.Y = this.MaxSize.Height;
        }

        if ( ( dbi.dwMask & DBIM.INTEGRAL ) != 0 )
        {
            dbi.ptIntegral.X = this.IntegralSize.Width;
            dbi.ptIntegral.Y = this.IntegralSize.Height;
        }

        if ( ( dbi.dwMask & DBIM.ACTUAL ) != 0 )
        {
            dbi.ptActual.X = this.Size.Width;
            dbi.ptActual.Y = this.Size.Height;
        }

        if ( ( dbi.dwMask & DBIM.TITLE ) != 0 )
        {
            dbi.wszTitle = this.Title;
        }

        if ( ( dbi.dwMask & DBIM.MODEFLAGS ) != 0 )
        {
            dbi.dwModeFlags = DBIMF.VARIABLEHEIGHT;
        }

        if ( ( dbi.dwMask & DBIM.BKCOLOR ) != 0 )
        {
            //Use the default background color by removing this flag.
            dbi.dwMask &= ~DBIM.BKCOLOR;
        }

        //Insert dbi.dwModeFlags code here
    }
    Note that you will need to replace the last line of the function with whatever you wish to specify the mode flag to.

    This is where your problem lies. In order to get the toolbar to be on a new line you must add the DBIMF_BREAK flag to the mode flags.
    So with in the previous code you could simply add the line dbi.dwModeFlags = DBIMF.BREAK.
    However, this is shortsighted. I recommend adding a ModeFlag property to the BandObject class and in the GetBandInfo se dbi.dwModeFlags to that property. This would allow you to set it to whatever flags you need in your derived class.
    Let me know how it works out.

    Matthew Morrow
    Monday, October 23, 2006 3:35 PM
  • I almost forgot. You must change dwModeFlags from type DBIM to DBIMF and dwMask from uint to DBIM. DBIM are mask flags and DBIMF are mode flags.

    Furthermore, your bar does not need to have BandStyle.Horizontal or BandStyle.TaskbarBand unless you intend to have your bar become a horizontal explorer bar or a taskbar toolbar.

    On other recommendation that I've came across is havng BandObject inherit from Toolbar instead of UserControl but I'm not sure of this.

    Monday, October 23, 2006 3:50 PM
  • Hi Mr. Morrow,

    Just breaking into windows forms programming from asp.net programming.

    Could you  expand on what this line means?:

    You must change dwModeFlags from type DBIM to DBIMF and dwMask from uint to DBIM. DBIM are mask flags and DBIMF are mode flags.

     

    Do you have  completed "comInterop.cs"?

    Monday, November 6, 2006 4:12 AM
  • I'm not quite sure what is giving you difficulty so forgive me if I seem verbose.

    Basically, everything in the ComInterop.cs is the same as the original except for the addition of the new flags enum and one other line.
    When complete you should have a DBIM enum, DBIMF enum and the previous code.

    Now, in public struct DESKBANDINFO the original looks like:
    [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
    public struct DESKBANDINFO
    {
    public UInt32 dwMask;
    public Point ptMinSize;
    public Point ptMaxSize;
    public Point ptIntegral;
    public Point ptActual;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst=255)]
    public String wszTitle;
    public DBIM dwModeFlags;
    public Int32 crBkgnd;
    };

    However, you will note that I stated dwMask should use the DBIM(deskband info mask) enum and dwModeFlags should use the DBIMF(deskband info mode flag) enum.
    The enums we created map to constants in the COM documentation and headers.

    The new DESKBANDINFO should look like this:
    [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
    public struct DESKBANDINFO
    {
    public DBIM dwMask;
    public Point ptMinSize;
    public Point ptMaxSize;
    public Point ptIntegral;
    public Point ptActual;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst=255)]
    public String wszTitle;
    public DBIMF dwModeFlags;
    public Int32 crBkgnd;
    };

    Notice that dwMask is now of type DBIM and DBIMF is now of type dwModeFlags. This allows us to specify a value from the enums to use in those fields. This gives us the advantage of readability and not having to memorize the various vaules of the constants. All our flags can be accessed either by DBMI. or DBMIF.

    Anywhere in which you use the dwMask field or the dwModeFlags field, you will need to specify one of the DBIM or DBIMF enumeration or you can cast an uint as one of these enums. Alternatively you can cast the enum as a uint if you need to use it in that manner for some reason.

    Since these enums are flags, we can set a number of different values using the OR(|) bitwise operator on any number of flags.
    For example, if you wanted your toolbar to be undeletable and use a chevron then you could do:
    dwModeFlags = DBIMF.UNDELETABLE | DBIMF.USECHEVRON;
    The MSDN documentation on deskbands has information on what each of these flags does.

    In essence, in order to obtain a complete ComInterop.cs file simply add the enum in my previous post and make the change to the deskband struct as described above.

    Hope this helps,
    Matthew Morrow
    Wednesday, November 8, 2006 11:42 PM
  •  

    Thanks Mr. Morrow,

    I was indeed able to get everything compiled and now my ComInterop.cs is in sync with yours.

    Not only that I understood what you were saying with your last post.  Thank you!  Means a lot to see you spell things out again.

    Note, I did not start with the base Zolnikov Toolband.

    I am using the 2.0 example that has Zolnikov Toolband as the base.  I wanted to use some of the .net 2.0 controls.

    From: http://www.codeproject.com/csharp/BandObjects20.asp?df=100&forumid=306921&fr=26

    Got some other problems now, but I see the value of you corrections to Zolnikov's Toolband.

    One pressing problem is that the band shows under view/toolbars but won't show up in either IE6 or IE7.

    I am relatively new to c# and windows form programming.  Background in Java and other languages plus asp.net.

    Mr. Morrow, can I contract you for a couple of hours of consulting time(flexible on the time)?  I really have some questions that can take me to the next level and I have searched all over trying to find the answers.

    How can we contact each other?  My contact information is on www.getvic.com (my one man shop).

    Look forward to paying you.

    :)

    Thanks,

    VicAllen

    Thursday, November 9, 2006 12:47 AM
  • Thank you very much Matthew for all this information, its works great! Just one thing: Do you know a way of having the toolbar being initially on its own line only after installation, but not at each IE launch? If after installation, the user decides to move it on a line where there's already another toolbar, I don't want my toolbar to go back to its own line every time IE is launched.
    Do you have any idea about this?

    Thanks a lot again
    Thibaud

    Wednesday, November 15, 2006 5:07 PM
  • I think I misunderstood you the first time. I thought you wanted to place it on its own line always. However, this is a simple change and it requires the same changes to the implementation as before except for one line.
    Instead of setting dwModeFlags to DBIMF.BREAK set it to DBIMF.ADDTOFRONT

    i.e. In GetBandInfo
    dbi.dwModeFlags = DBIMF.ADDTOFRONT(or where ever you used to set dwModeFlags to DBIMF.BREAK)

    This allows the bar to be moved almost anywhere. If you notice you cannot place the bar on the same line as another bar, the bar's creators probably used BREAK
    For both BREAK and ADDTOFRONT the MSDN documentation states that both are available in XP only so I'm not sure how the bar would work on an earlier OS. If that is a concern you might want to test it.

    Does your toolbar stay visible when you create a new tab? My test one doesn't. I'm kind of curious as to why not.

    EDIT:VICAllen, I sent you an email to the address on that webpage. I assume that that was correct. Forgive my late response.
    Monday, November 20, 2006 3:21 PM
  • Hi Matthew, thanks for your reply. I tried what you suggested. I uninstalled everything about the toolbar (assemby cache and registry: hkcr->clsid of the toolbar, hkcu->webbrowser\ITBar7Layout, hklr->\Internet Explorer\toolbar\mytoolbar), I modified the flag you mentionned, compiled, then re-installed the toolbar. But in IE, it appeared on the same line as the menu line :-(
    I was expecting it to be on its own line at first run, just after install! Did I do something wrong? Is DBIMF.ADDTOFRONT really designed for this purpose or did I misunderstand you? I tried to find some information about this, but unfortunately it's barely documented!

    Thanks again for your help Matthew!
    Thursday, November 23, 2006 9:40 AM
  • This doesn't make any sense but if I put the flag to anything other than Break, Normal, or AddToFront it works the way that you want it.
    So my suggestion would be to set it to TopAlign since it probably wouldn't affect any functionality, I don't think.
    This is such a hacky toolbar.
    Sunday, November 26, 2006 6:06 AM
  • ok, I'll give this a try, thanks again Matthew.
    Sorry for your previous question, I had forgotten:
     Matthew Morrow wrote:
    Does your toolbar stay visible when you create a new tab? My test one doesn't. I'm kind of curious as to why not.

    Well, I never had this problem, I'm sorry I can't help you about this!

    Thibaud
    Monday, November 27, 2006 10:39 AM
  • Does anyone know how to make the toolbar transparent?  If I set the backcolor of the toolbar to a specific color, it looks different in IE6 and IE7 because toolbars in IE7 are lighter than IE6.    I thought I would just set the backcolor to transparent, but that does not work.  I also tried the following which didn't work:

    dwViewMode = DBIF_VIEWMODE_TRANSPARENT;

    Thank you,

    Tony

    Wednesday, January 3, 2007 10:32 PM
  • Hi Tony,

    I don't know if it's the easiest way, but here's how I did: set your BandObject control's backcolor to Transparent and add this in the BandObject class:

    [DllImport("uxtheme", ExactSpelling = true)]
    public extern static Int32 DrawThemeParentBackground(IntPtr hWnd, IntPtr hdc, ref Rectangle pRect);

    protected override void OnPaintBackground(PaintEventArgs e)
    {
        if (this.BackColor == Color.Transparent)
        {
            IntPtr hdc = e.Graphics.GetHdc();
            Rectangle rec = new Rectangle(e.ClipRectangle.Left,
                e.ClipRectangle.Top, e.ClipRectangle.Width, e.ClipRectangle.Height);
            DrawThemeParentBackground(this.Handle, hdc, ref rec);
            e.Graphics.ReleaseHdc(hdc);
        }
        else
            base.OnPaintBackground(e);
    }

    Please tell me if you find a better solution

    Thibaud
    Thursday, January 4, 2007 9:52 AM
  • Thibaud,

     

    Thank you for your response.

     

    When I try to set the BandObjects backcolor to transparent, I get this error "This control does not support transparent background colors.".  Do you have this line of code:

    this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);

    If so, where did you add this code?

     

    Thank for all your help.

     

    Thursday, January 4, 2007 4:41 PM
  • OK, it does work.  Thanks for the code.

    However, when I add a button to the toolbar usercontrol, it shows up with a black background even though the backcolor is set to transparent.  I'm adding the button via drag and drop.  I'm not writing code to add the button. 

    Also, IE7 dumps every time I close IE.  Have you run into this?

     

    Thank You,

    Thursday, January 4, 2007 6:07 PM
  • I didn't do anything to be able to set the bandobject control transparent such as SetStyle(ControlStyles.SupportsTransparentBackColor,true). Be aware that if you're using a toolstrip control in the bandobject, its backcolor should be transparent too, and its border will still be painted. To avoid this, you have to use your own toolstrip renderer and make it do 'nothing', as I described it here: http://www.codeproject.com/csharp/dotnetbandobjects.asp?select=1642881&df=100&forumid=3788&noise=1&mpp=50&exp=0&tid=1472577#xx1642881xx

    About your button, I'm not sure I understood well, are you adding it with VS resource designer? If so, maybe you should put in in a toolstrip as I do, rather than directly on the bandobject control?
    Friday, January 5, 2007 8:57 AM
  • Thanks all!

    This post help me finally finish the example..

    Even added a button,,

     

    It is a pitty when the examples have errors,,  I had some issues beside what you talked about.. After I added some code with brackets,, One of my issues went away so I went back and added brackets to all the if then blocks..

    and whooo hooo... LOL I have read you can leave brackets off but it seems to be not true... I will add missing brackets from the get go from now on when I use somebody else code to play with...

     

    Now that I have a working model I can play...

     

    Thanks again...  doing the DBIM and DBIMF swapping around worked great,,,,

     

     

    Saturday, July 7, 2007 1:20 AM
  • Great post. It was a lot of help.

    Any pointers on setting up the install project for the toolbar, specifically what goes in _AfterInstall and _AfterUnInstall methods?

    Thank you
    Thursday, September 13, 2007 12:43 AM
  • sorry Traimo, I haven't been checking this thread for a while... About your multiple tab issue:
    In fact, contrary to one might think, there's a different toolbar for each tab! Each one is a totally independent control. So check out what happens during your 2nd toolbar initialization, hope you might see what goes wrong. In case you don't already know, to debug the toolbar, edit the toolbar project settings, under debug tab, and just tell Visual Studio to attach to "C:\Program Files\Internet Explorer\iexplore.exe"
    Wednesday, September 19, 2007 9:06 AM
  • About traimo black button background issue:
    I'm afraid I can't help you about this, I didn't face it. But I didn't directly put the buttons on the toolbar, but instead on a toolstrip, with its backcolor set to transparent. This might help you?
    When I first coded the toolbar, I remember IE was crashing on exit. If I remember well, this was due to the fact I was calling Application.EnableVisualStyles() in toolbar constructor, without calling Application.DoEvents() just afterwards. But I'm not really sure. Sorry if this doesn't help.
    Wednesday, September 19, 2007 9:12 AM
  • VICAllen, I sent you an email to the address on that webpage. I assume that that was correct. Forgive my late response.

    Hi, i have the same problem as
    VICAllen can you  post the  link to the possible solution? or eventualy send  me  an email...
    Wednesday, January 9, 2008 3:04 PM
  • Hi EveryOne,

     

    i have used  this toolbar and it is works fine now i need some functionality like open the window at toolbar button click that window have a swf file on shockwave flash object component .,when i run this it gives this type of error

    System.IO.FileNotFoundException: Could not load file or assembly 'AxInterop.ShockwaveFlashObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7f2b56d53762df3d' or one of its dependencies. The system cannot find the file specified.

     give the proper solution.

     

    Friday, January 18, 2008 5:33 PM
  • I implemented a toolbar based on Zolnikov's Toolbar with all the fixes mentioned here.

    I have this weird problem that I can't determine when it exactly happens.

    I am using IE7. sometimes something get messed up with the keyboard strokes , for example when I press "ENTER" a new tab is opened. also when I switch to Hebrew then I get weird characters.

    I tried to find some logic in the problem , I know that "נ" turns in to "א" and the following Hebrew letters keep the same distance (16) which lead me to assume that something happens to the 4th bit that represents character.

    but what is more weird is that the english characters remain intact so it ruined my "4th bit" theory.

     

    I am 99% sure it is something with the toolbar since more than 10 people I know reported me this phenomena since

    they installed the toolbar.

     

    another thing is that if I open a new tab , the new tab functions just fine , so it is "per" tab issue.

     

    maybe it have something to do with COM Interop issues ? maybe the BandObject is not attached correctly ?

     

    how can I debug such thing ?

     

     

     

     

     

    Thursday, April 24, 2008 1:58 PM
  • Okay
    I tried all ideas for getting the toolbar to work on IE 7 - but it still doesen't work.
    Could anyone Post a completely and working example?
    Sunday, April 27, 2008 8:25 PM
  • Hi traimo,
    Did you find out how to resolve the black background issue? I'm having the same problem after setting the background to transparent.
    Also, how did you get rid of the error that this control does not support transparent background?
    Is it just by adding
    Code Snippet

    this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);


    ?

    Thank you

    Wednesday, July 23, 2008 2:38 AM
  •  

    I need my Explorer Band to have a pop out button and allow the IE Explorer band to open in its own window.  Any guidence would be great!

     

    Thanks

    • Proposed as answer by abhinayts Wednesday, April 15, 2009 9:07 AM
    Wednesday, September 3, 2008 5:23 PM
  • What is a "pop out" button?

     

    Wednesday, September 3, 2008 5:30 PM
  •  

    My Explorer band is web enabled and I would like for the Docked IE Explorer bar to be able to pop out into its own window.  Such as the "IE Developer Toolbar" microsoft offers does.

     

    thanks

    Wednesday, September 3, 2008 5:39 PM
  • I almost forgot. You must change dwModeFlags from type DBIM to DBIMF and dwMask from uint to DBIM. DBIM are mask flags and DBIMF are mode flags.

    Furthermore, your bar does not need to have BandStyle.Horizontal or BandStyle.TaskbarBand unless you intend to have your bar become a horizontal explorer bar or a taskbar toolbar.

    On other recommendation that I've came across is havng BandObject inherit from Toolbar instead of UserControl but I'm not sure of this.


    Try it and see if it works for me, I have the similar question, Thanks!
    Sunday, September 5, 2010 11:36 PM
  • I'm not quite sure what is giving you difficulty so forgive me if I seem verbose.

    Basically, everything in the ComInterop.cs is the same as the original except for the addition of the new flags enum and one other line.
    When complete you should have a DBIM enum, DBIMF enum and the previous code.

    Now, in public struct DESKBANDINFO the original looks like:
    [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
    public struct DESKBANDINFO
    {
    public UInt32 dwMask;
    public Point ptMinSize;
    public Point ptMaxSize;
    public Point ptIntegral;
    public Point ptActual;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst=255)]
    public String wszTitle;
    public DBIM dwModeFlags;
    public Int32 crBkgnd;
    };

    However, you will note that I stated dwMask should use the DBIM(deskband info mask) enum and dwModeFlags should use the DBIMF(deskband info mode flag) enum.
    The enums we created map to constants in the COM documentation and headers.

    The new DESKBANDINFO should look like this:
    [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
    public struct DESKBANDINFO
    {
    public DBIM dwMask;
    public Point ptMinSize;
    public Point ptMaxSize;
    public Point ptIntegral;
    public Point ptActual;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst=255)]
    public String wszTitle;
    public DBIMF dwModeFlags;
    public Int32 crBkgnd;
    };

    Notice that dwMask is now of type DBIM and DBIMF is now of type dwModeFlags. This allows us to specify a value from the enums to use in those fields. This gives us the advantage of readability and not having to memorize the various vaules of the constants. All our flags can be accessed either by DBMI. or DBMIF.

    Anywhere in which you use the dwMask field or the dwModeFlags field, you will need to specify one of the DBIM or DBIMF enumeration or you can cast an uint as one of these enums. Alternatively you can cast the enum as a uint if you need to use it in that manner for some reason.

    Since these enums are flags, we can set a number of different values using the OR(|) bitwise operator on any number of flags.
    For example, if you wanted your toolbar to be undeletable and use a chevron then you could do:
    dwModeFlags = DBIMF.UNDELETABLE | DBIMF.USECHEVRON;
    The MSDN documentation on deskbands has information on what each of these flags does.

    In essence, in order to obtain a complete ComInterop.cs file simply add the enum in my previous post and make the change to the deskband struct as described above.

    Hope this helps,
    Matthew Morrow
    Saturday, October 23, 2010 9:57 AM