C++ control and toolbox bitmap problem 
Author Message
 C++ control and toolbox bitmap problem

Hi,
I have a question.
I have tried to ask it before, got some suggestions but they did not help.

Here is a question:
I am developing a custom NET control using Managed Extensions for C++.
I need to specify a toolbox bitmap for the control (NOTE: bitmap should be
embedded into the assembly not as a separate file in disk).
It is well documented and works fine for C# controls but all my attempts to
do that for C++ control failed.
------ C# control -------
[ ToolboxBitmap(typeof(Foo_CSharp)) ]
public class Foo_CSharp : Control
{

Quote:
}

------ C++ control -------
[ ToolboxBitmap(__typeof(Foo_CPlus)) ]
public __gc class Foo_CPlus : public Control
{
Quote:
};

-------------------------------------------
In this case C++ sample won't compile at all probably because the type
Foo_CPlus haven't defined yet.
I could not find any workaround for this problem.

Another question is - how to add a correspondent bitmap to the control
resources? For C# I need to add a bitmap with name of the class I'd like to
associate with, how to do that in C++?

Thanks in advance,
Andrew



Sat, 25 Sep 2004 01:20:51 GMT  
 C++ control and toolbox bitmap problem
Hello Andrew,

You can use another constructor of the ToolboxBitmap attribute:

ToolboxBitmapAttribute Constructor (Type, String)

This constructor searches for an image with a name specified by the name
parameter in the assembly where the class specified by the t parameter is
defined. Hence, you can declare your control as this:

[ ToolboxBitmap(__typeof(Someclass), "Foo_CPlus") ]
public __gc class Foo_CPlus : public Control
{

Quote:
};

Someclass is a class defined in the assembly which include the image
resource. For more information about this constructor please see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre...
frlrfsystemdrawingtoolboxbitmapattributeclassctortopic3.asp

I hope this is helpful.

Best regards,

Lion Shi, MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2001 Microsoft Corporation. All rights
reserved.
--------------------

    Subject: C++ control and toolbox bitmap problem
    Date: Mon, 8 Apr 2002 13:20:51 -0400
    Lines: 34
    X-Priority: 3
    X-MSMail-Priority: Normal
    X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

    Newsgroups: microsoft.public.dotnet.languages.vc
    NNTP-Posting-Host: 204.128.199.10
    Path: cpmsftngxa07!tkmsftngp01!tkmsftngp04
    Xref: cpmsftngxa07 microsoft.public.dotnet.languages.vc:8972
    X-Tomcat-NG: microsoft.public.dotnet.languages.vc

    Hi,
    I have a question.
    I have tried to ask it before, got some suggestions but they did not
help.

    Here is a question:
    I am developing a custom NET control using Managed Extensions for C++.
    I need to specify a toolbox bitmap for the control (NOTE: bitmap should
be
    embedded into the assembly not as a separate file in disk).
    It is well documented and works fine for C# controls but all my
attempts to
    do that for C++ control failed.
    ------ C# control -------
    [ ToolboxBitmap(typeof(Foo_CSharp)) ]
    public class Foo_CSharp : Control
    {
    }
    ------ C++ control -------
    [ ToolboxBitmap(__typeof(Foo_CPlus)) ]
    public __gc class Foo_CPlus : public Control
    {
    };
    -------------------------------------------
    In this case C++ sample won't compile at all probably because the type
    Foo_CPlus haven't defined yet.
    I could not find any workaround for this problem.

    Another question is - how to add a correspondent bitmap to the control
    resources? For C# I need to add a bitmap with name of the class I'd
like to
    associate with, how to do that in C++?

    Thanks in advance,
    Andrew



Sun, 26 Sep 2004 13:58:08 GMT  
 C++ control and toolbox bitmap problem
Hi Lion,

Thanks for the suggestion but I have read all documents and help files on
this topic before posting on this newsgroup. And of course I saw and tried
the constructor for the ToolboxBtimap attribute you mentioned.

I can assure you that I have spent significant amount of time trying to make
it working. Poor results.
1) using - ToolboxBitmapAttribute Constructor (Type*) - if you are using as
a parameter a type of the class the this bitmap should be associated with -
it does not compile using C++ though works fine with C# controls
2) using - ToolboxBitmapAttribute Constructor (Type*, String* ) same story
as with using first constructor but if you are trying to use some other
class as a parameter just ignore it but no compiling problem I can admit.
3) The only constructor that works is: ToolboxBitmapAttribute Constructor
(String* strName) where strName is a name of the bitmap file on the
harddrive next to the control's DLL.

Could you give me or point to any sample that would show me how to use this
attribute for the controls built with C++ Managed Extensions.
Please do not give me any C# samples - I saw, tried them and they work fine.

BTW there is another problem with attributes for managed classes and ME C++.
If I try to apply ToolboxItemAttribute(false) I got a compiler error but
ToolboxItemAttribute(true) works fine.
And again note that the same code doe not produce any errors with C#.

I more and more getting convinced that ME C++ is a second class language for
developing controls under .NET though it was for years the number ONE for
VBXs and OCXs. :(

Thanks again,
Andrew


Quote:
> Hello Andrew,

> You can use another constructor of the ToolboxBitmap attribute:

> ToolboxBitmapAttribute Constructor (Type, String)

> This constructor searches for an image with a name specified by the name
> parameter in the assembly where the class specified by the t parameter is
> defined. Hence, you can declare your control as this:

> [ ToolboxBitmap(__typeof(Someclass), "Foo_CPlus") ]
> public __gc class Foo_CPlus : public Control
> {
> };

> Someclass is a class defined in the assembly which include the image
> resource. For more information about this constructor please see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre...

- Show quoted text -

Quote:
> frlrfsystemdrawingtoolboxbitmapattributeclassctortopic3.asp

> I hope this is helpful.

> Best regards,

> Lion Shi, MCSE, MCSD
> Microsoft Support Engineer

> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use.  2001 Microsoft Corporation. All rights
> reserved.
> --------------------

>     Subject: C++ control and toolbox bitmap problem
>     Date: Mon, 8 Apr 2002 13:20:51 -0400
>     Lines: 34
>     X-Priority: 3
>     X-MSMail-Priority: Normal
>     X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>     X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

>     Newsgroups: microsoft.public.dotnet.languages.vc
>     NNTP-Posting-Host: 204.128.199.10
>     Path: cpmsftngxa07!tkmsftngp01!tkmsftngp04
>     Xref: cpmsftngxa07 microsoft.public.dotnet.languages.vc:8972
>     X-Tomcat-NG: microsoft.public.dotnet.languages.vc

>     Hi,
>     I have a question.
>     I have tried to ask it before, got some suggestions but they did not
> help.

>     Here is a question:
>     I am developing a custom NET control using Managed Extensions for C++.
>     I need to specify a toolbox bitmap for the control (NOTE: bitmap
should
> be
>     embedded into the assembly not as a separate file in disk).
>     It is well documented and works fine for C# controls but all my
> attempts to
>     do that for C++ control failed.
>     ------ C# control -------
>     [ ToolboxBitmap(typeof(Foo_CSharp)) ]
>     public class Foo_CSharp : Control
>     {
>     }
>     ------ C++ control -------
>     [ ToolboxBitmap(__typeof(Foo_CPlus)) ]
>     public __gc class Foo_CPlus : public Control
>     {
>     };
>     -------------------------------------------
>     In this case C++ sample won't compile at all probably because the type
>     Foo_CPlus haven't defined yet.
>     I could not find any workaround for this problem.

>     Another question is - how to add a correspondent bitmap to the control
>     resources? For C# I need to add a bitmap with name of the class I'd
> like to
>     associate with, how to do that in C++?

>     Thanks in advance,
>     Andrew



Sun, 26 Sep 2004 23:43:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Changing the toolbox bitmap of a control

2. Toolbox Bitmap (Again)

3. Visual C++ audio toolbox

4. .NET Custom control toolbox icon

5. User controls disappear from toolbox!

6. IDE Toolbox support for custom wrapped ActiveX controls

7. HELP! Project Controls in Toolbox

8. Cant get my Custom Web Control onto toolbox!!!

9. How to get back Control Toolbox

10. Can't restore the controls toolbox...

11. Adding Custom Controls To Dialog Editor Toolbox

12. How to get back Control Toolbox

 

 
Powered by phpBB® Forum Software