CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: CBitmap problem

  1. #1
    Join Date
    May 1999
    Posts
    13

    CBitmap problem

    Tried to bisplay a Bitmap in an app. Inserted a .bmp file to a resource.
    Included the same...

    #include "Script2.rc"

    tried to load it in to a CBitmap object...

    if(bmp->LoadBitmap(IDB_BITMAP1)==0)

    Got the following error....

    c:\program\microsoft visual studio\vc98\code\bitmap\script2.rc(20) : error C2143: syntax error : missing ';' before 'constant'
    c:\program\microsoft visual studio\vc98\code\bitmap\script2.rc(20) : error C2501: 'LANGUAGE' : missing storage-class or type specifiers
    c:\program\microsoft visual studio\vc98\code\bitmap\script2.rc(20) : fatal error C1004: unexpected end of file found

    WHY ???? PLEASE HELP !!!!


  2. #2
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: CBitmap problem

    Typically, one does not include .rc files in C++ source files.
    It would seem that the compiler is not liking the syntax of the .rc file.
    The .rc file should be included in the app's resource file or
    declare an instance of the resource in the app's resource file.



  3. #3
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: CBitmap problem

    If you have questions, post them to the board, not to me.

    > How do i include the resource files in my app?

    Add the resource script file to your project. This can be done by right-clicking
    on one of the groups in your project (the one you want it to be in, usually source or
    resource files) and select Add Files to Project and then select your resource script.

    > Do i create an CBitmap objetc and then load the resource as follows ?
    > CBitmap bmp;
    > bmp.LoadBitmap(IDB_BITMAP);

    Yes, this is how you do it.
    Make sure the CBitmap object will last as long as you need it.
    The one you illustrated will be created on the stack and survive only the current
    execution scope. It will be destroyed when the current function returns.
    You might want it to be a member variable of your dialog or view or whatever.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured