Winform Theme for TabControl et MsgBox

Posted by: fsegui on 24 April 2020, 10:47 am EST

    • Post Options:
    • Link

    Posted 24 April 2020, 10:47 am EST

    Hello,

    I’m trying the ComponentOne components and especially the themecontroller.

    Works well with majority of Winform native components but not with TabControl (and TabPages) and MsgBox

    Is it possible to define theme for these two?

  • Posted 27 April 2020, 5:38 am EST

    Hi,

    C1Themes can only theme those parts of a control which are exposed through public properties. This is not the case with MessageBox and parts of TabControl.

    However, you might want to take a look at the following blog post which shows how you can get a themed MessageBox:

    https://www.grapecity.com/blogs/c1themes-and-message-boxes

    For TabControl, you can use C1DockingTab which is fully supported by C1Themes.

    Regards,

    Jitender

  • Posted 13 May 2020, 6:08 am EST

    Hello,

    Sorry for my late reply. Thanks for your feedback, I’ll take a look at the blog for MessageBox.

    DockingTab should be ok as a replacement for TabControl.

    Is it possible to customize the title bar of a form?

  • Posted 14 May 2020, 5:16 am EST - Updated 3 October 2022, 11:37 pm EST

    Hi,

    The built-in themes already customize the Form Title. You can see the ThemeDesigner application (located at “C:\Program Files (x86)\ComponentOne\Apps\v4.x”).

    As shown in the screenshot below, you can create a new theme to customize the Form title:

    Regards,

    Jitender

  • Posted 14 May 2020, 5:33 am EST

    So it means I have to add a C1Ribbon on all my forms?

    Or is there a possibility of heriting?

  • Posted 14 May 2020, 5:37 am EST

    You can inherit from C1RibbonForm class:

    public partial class MainForm : C1RibbonForm
    {
    
    }
    
  • Posted 14 September 2020, 10:48 am EST

    Hello,

    I’ve tried to follow the blog regarding MessageBox. But I encounter an issue regarding the assembly bindings. The blog was posted a long ago when the assembly name was C1.Win.C1Ribbon.4. Now we are using C1.Win.C1Ribbon.4.5.2 name.

    Is it possible to change the assembly name in the assembly redirect?

    NB: here is what I have in my app.config

     <assemblyIdentity name="C1.Win.C1Ribbon.4" culture="neutral" publicKeyToken="79882d576c6336da" />
            <bindingRedirect oldVersion="4.0.20141.570" newVersion="4.5.20202.438" />
    

    Thanks.

  • Posted 15 September 2020, 8:39 am EST

    Hi,

    You should not add a redirect for the new assemblies since the new assemblies (C1.Win.C1Ribbon.4.5.2) have a different name from the previous ones (C1.Win.C1Ribbon.4). Redirecting assembly version is only applicable if they have the same name.

    You can just remove this entry, and add a reference to the new assembly.

    Regards,

    Jitender

  • Posted 15 September 2020, 8:50 am EST

    Hi,

    Thanks for your feedback. Even if I remove this entry in the app.config (I already have the C1.Win.C1Ribbon4.5.2 referenced in my project), the VtlMessageBox is still searching for the older version. How can I force to use the newer one?

  • Posted 15 September 2020, 9:22 am EST

    Do you still have a reference to older assembly?

    Also, can you show the exact error message you are getting?

  • Posted 15 September 2020, 9:35 am EST

    no reference to the old version (I never had it anyway since we purchase C1 this year).

    I just get an IO.FileNotFoundException (C1.Win.C1Ribbon.4, Version=4.0.20141.570, Culture=neutral, PublicKeyToken=79882d576c6336da)

  • Posted 18 September 2020, 2:44 am EST

    Hi,

    Ok, I got it now. The VtlMessageBox library was built with v4 assemblies and the only way to use it with v4.5.2 assemblies is to re-compile it with the new assemblies. This library was written by one of our customers and, unfortunately, the source code of this library is not available.

    However, the general idea shown in the blog still applies. You can use a RibbonForm in place of the default MessageBox, which would be themeable using C1Themes.

    Regards,

    Jitender

  • Posted 21 September 2020, 3:46 am EST

    Hi,

    you could try two things:

    a) using “dnSpy” (https://github.com/0xd4d/dnSpy) to decompile the assembly, then create a new VB.NET project and add all source files to it. This might cause trouble because the original DLL contains some image resources.

    OR

    b) disassemble the dll, modify the reference versions in the IL code and recompile it: https://stackoverflow.com/a/34045871/8225290

    Step 1: excute this in Visual Studio Developer Command Prompt:

    ildasm ViewToLearn.Vtlmb.dll /output:my.il /metadata
    

    Step 2: Open “my.il” and change the versions:

    
    // 	Name: C1.Win.C1Themes.4.5.2
    // 	Version: 4.5.20202.438
    // 	Major Version: 0x00000004
    // 	Minor Version: 0x00000005
    // 	Build Number: 0x00004eea
    // 	Revision Number: 0x000001Be
    
    

    I don’t know whether the public key token (line above snippet) needs to be changed either.

    Step 3: rebuild dll:

    ilasm my.il /res:my.res /output=ViewToLearn.Vtlmb2.dll /dll
    

    I did not test whether the resulting dll will actually work.

    Hope this works

    Wolfgang

  • Posted 23 September 2020, 3:56 am EST

    Hello,

    I’ve tried the second method without success. It seems that the new dll cannot find a method.

    System.MissingMethodException : 'Méthode introuvable : 'Void C1.Win.C1Themes.C1ThemeController.ApplyThemeToControlTree(System.Windows.Forms.Control, C1.Win.C1Themes.C1Theme, System.Predicate`1<System.Windows.Forms.Control>)'.'
    
    

    I think that the new assemblies are not correctly referenced…

    I’ll try the first method as well.

  • Posted 30 September 2020, 5:30 am EST

    Hello,

    I’ve decompile the assembly and found out why it wasn’t working.

    The assembly was targeting 4.0 .NET framework whereas C1 new assemblies target 4.5.2 .NET framework.

    I’ve recompiled with new assemblies and now it’s working. I’ve even made some adjustements (possibility to set the button captions as by default they’re all in English).

  • Posted 30 September 2020, 5:37 am EST

    Good to hear you have resolved it.

    Unfortunately, all other users who want to use the “VtlMessageBox” library will have to do the same steps themself as it is closed source and your “fixed” version cannot be published anywhere :-(.

    Best regards

    Wolfgang

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels