Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .NET Rebar Control Error

.NET Rebar Control Error

Scheduled Pinned Locked Moved C#
csharpcomhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David M Kean
    wrote on last edited by
    #1

    I have created my own Rebar Control and I am having issues on Windows 2000 machines. When creating the handle it throws an Win32Exception with the error "Invalid window class name". It works fine on Windows XP machines. The following is my CreateHandle method and CreateParams property. Any ideas? protected override void CreateHandle() { if (!RecreatingHandle) { // Initialize Cool Bar Common Control INITCOMMONCONTROLSEX initCommonControls = new INITCOMMONCONTROLSEX(); // I set Size field in constructor initCommonControls.Flags = InitCommonClasses.COOL_CLASSES | InitCommonClasses.BAR_CLASSES; SafeInterop.InitCommonControlsEx(initCommonControls); } base.CreateHandle(); // <-- Exception thrown here } protected override CreateParams CreateParams { [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)] get { CreateParams createParams = base.CreateParams; createParams.ClassName = Interop.REBARCLASSNAME; createParams.Style |= (int)(CommonControlStyles.NORESIZE | CommonControlStyles.NODIVIDER | CommonControlStyles.NOPARENTALIGN); if (_Borders) { createParams.Style |= (int)RebarStyles.BANDBORDERS; createParams.Style |= (int)(RebarStyles.VARHEIGHT | RebarStyles.AUTOSIZE); return createParams; } } }

    H 1 Reply Last reply
    0
    • D David M Kean

      I have created my own Rebar Control and I am having issues on Windows 2000 machines. When creating the handle it throws an Win32Exception with the error "Invalid window class name". It works fine on Windows XP machines. The following is my CreateHandle method and CreateParams property. Any ideas? protected override void CreateHandle() { if (!RecreatingHandle) { // Initialize Cool Bar Common Control INITCOMMONCONTROLSEX initCommonControls = new INITCOMMONCONTROLSEX(); // I set Size field in constructor initCommonControls.Flags = InitCommonClasses.COOL_CLASSES | InitCommonClasses.BAR_CLASSES; SafeInterop.InitCommonControlsEx(initCommonControls); } base.CreateHandle(); // <-- Exception thrown here } protected override CreateParams CreateParams { [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)] get { CreateParams createParams = base.CreateParams; createParams.ClassName = Interop.REBARCLASSNAME; createParams.Style |= (int)(CommonControlStyles.NORESIZE | CommonControlStyles.NODIVIDER | CommonControlStyles.NOPARENTALIGN); if (_Borders) { createParams.Style |= (int)RebarStyles.BANDBORDERS; createParams.Style |= (int)(RebarStyles.VARHEIGHT | RebarStyles.AUTOSIZE); return createParams; } } }

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You must make sure that your window class is registered using RegisterClass(Ex) API. InitCommonControls does this for classes defined in the common controls library, but any custom classes must be registered by you.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      D 1 Reply Last reply
      0
      • H Heath Stewart

        You must make sure that your window class is registered using RegisterClass(Ex) API. InitCommonControls does this for classes defined in the common controls library, but any custom classes must be registered by you.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        D Offline
        D Offline
        David M Kean
        wrote on last edited by
        #3

        I found out what is was. The INITCOMMONCONTROLSEX structure had the size and flags fields the wrong way, so the call to InitCommonControlsEx was failing. It's just weird that it worked fine Windows XP, sometimes is really bad for developing on, because it hides errors.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups