How to set a background for my form in c++builder6?











up vote
0
down vote

favorite












I am new to C++Builder 6, but I have used C++. My question is, how do I set a background for my form? When I open the application I want the background to have a specific image. I tried with Graphics::TBitmap but it says that the image is not valid even if it is bmp.



Graphics::TBitmap *BmpTabla = new Graphics::TBitmap;

try {
BmpTabla->LoadFromFile("board.bmp");

}
__finally
{
delete BmpTabla;
}


Edit: I just changed the picture and worked fine.










share|improve this question









New contributor




Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    0
    down vote

    favorite












    I am new to C++Builder 6, but I have used C++. My question is, how do I set a background for my form? When I open the application I want the background to have a specific image. I tried with Graphics::TBitmap but it says that the image is not valid even if it is bmp.



    Graphics::TBitmap *BmpTabla = new Graphics::TBitmap;

    try {
    BmpTabla->LoadFromFile("board.bmp");

    }
    __finally
    {
    delete BmpTabla;
    }


    Edit: I just changed the picture and worked fine.










    share|improve this question









    New contributor




    Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am new to C++Builder 6, but I have used C++. My question is, how do I set a background for my form? When I open the application I want the background to have a specific image. I tried with Graphics::TBitmap but it says that the image is not valid even if it is bmp.



      Graphics::TBitmap *BmpTabla = new Graphics::TBitmap;

      try {
      BmpTabla->LoadFromFile("board.bmp");

      }
      __finally
      {
      delete BmpTabla;
      }


      Edit: I just changed the picture and worked fine.










      share|improve this question









      New contributor




      Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I am new to C++Builder 6, but I have used C++. My question is, how do I set a background for my form? When I open the application I want the background to have a specific image. I tried with Graphics::TBitmap but it says that the image is not valid even if it is bmp.



      Graphics::TBitmap *BmpTabla = new Graphics::TBitmap;

      try {
      BmpTabla->LoadFromFile("board.bmp");

      }
      __finally
      {
      delete BmpTabla;
      }


      Edit: I just changed the picture and worked fine.







      c++ background c++builder






      share|improve this question









      New contributor




      Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday





















      New contributor




      Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      Gabi5537

      33




      33




      New contributor




      Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Gabi5537 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Drop TImage component to the form, send it to back of the all controls, set the Align property to alClient.
          In runtime



          Image1->Picture->LoadFromFile("board.bmp");





          share|improve this answer





















          • It worked, but now it says that "Bitmap image is not valid", there are certain standars for images?
            – Gabi5537
            2 days ago






          • 1




            Picture object load the file according to its type (file extension). If .bmp file has other format regardless the type, an exception will be thrown. Try to test some trusted bitmap file i.e. included in C++Builder distribution package. Also try to open .bmp in some graphic editor (GIMP, XnView...) and re-save it.
            – serge
            2 days ago


















          up vote
          0
          down vote













          The easiest way to have a custom background is to use a client-aligned TImage, like @serge suggested.



          Another way is to load the BMP image into a Graphics::TBitmap object (like you are already attempting to do) and then use the Form's OnPaint event to draw the TBitmap onto the Form's Canvas.



          The "image is not valid" error means you are trying to load a .bmp file that is not a valid BMP image. Double check the contents of the file.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Gabi5537 is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186876%2fhow-to-set-a-background-for-my-form-in-cbuilder6%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            Drop TImage component to the form, send it to back of the all controls, set the Align property to alClient.
            In runtime



            Image1->Picture->LoadFromFile("board.bmp");





            share|improve this answer





















            • It worked, but now it says that "Bitmap image is not valid", there are certain standars for images?
              – Gabi5537
              2 days ago






            • 1




              Picture object load the file according to its type (file extension). If .bmp file has other format regardless the type, an exception will be thrown. Try to test some trusted bitmap file i.e. included in C++Builder distribution package. Also try to open .bmp in some graphic editor (GIMP, XnView...) and re-save it.
              – serge
              2 days ago















            up vote
            0
            down vote



            accepted










            Drop TImage component to the form, send it to back of the all controls, set the Align property to alClient.
            In runtime



            Image1->Picture->LoadFromFile("board.bmp");





            share|improve this answer





















            • It worked, but now it says that "Bitmap image is not valid", there are certain standars for images?
              – Gabi5537
              2 days ago






            • 1




              Picture object load the file according to its type (file extension). If .bmp file has other format regardless the type, an exception will be thrown. Try to test some trusted bitmap file i.e. included in C++Builder distribution package. Also try to open .bmp in some graphic editor (GIMP, XnView...) and re-save it.
              – serge
              2 days ago













            up vote
            0
            down vote



            accepted







            up vote
            0
            down vote



            accepted






            Drop TImage component to the form, send it to back of the all controls, set the Align property to alClient.
            In runtime



            Image1->Picture->LoadFromFile("board.bmp");





            share|improve this answer












            Drop TImage component to the form, send it to back of the all controls, set the Align property to alClient.
            In runtime



            Image1->Picture->LoadFromFile("board.bmp");






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 2 days ago









            serge

            1877




            1877












            • It worked, but now it says that "Bitmap image is not valid", there are certain standars for images?
              – Gabi5537
              2 days ago






            • 1




              Picture object load the file according to its type (file extension). If .bmp file has other format regardless the type, an exception will be thrown. Try to test some trusted bitmap file i.e. included in C++Builder distribution package. Also try to open .bmp in some graphic editor (GIMP, XnView...) and re-save it.
              – serge
              2 days ago


















            • It worked, but now it says that "Bitmap image is not valid", there are certain standars for images?
              – Gabi5537
              2 days ago






            • 1




              Picture object load the file according to its type (file extension). If .bmp file has other format regardless the type, an exception will be thrown. Try to test some trusted bitmap file i.e. included in C++Builder distribution package. Also try to open .bmp in some graphic editor (GIMP, XnView...) and re-save it.
              – serge
              2 days ago
















            It worked, but now it says that "Bitmap image is not valid", there are certain standars for images?
            – Gabi5537
            2 days ago




            It worked, but now it says that "Bitmap image is not valid", there are certain standars for images?
            – Gabi5537
            2 days ago




            1




            1




            Picture object load the file according to its type (file extension). If .bmp file has other format regardless the type, an exception will be thrown. Try to test some trusted bitmap file i.e. included in C++Builder distribution package. Also try to open .bmp in some graphic editor (GIMP, XnView...) and re-save it.
            – serge
            2 days ago




            Picture object load the file according to its type (file extension). If .bmp file has other format regardless the type, an exception will be thrown. Try to test some trusted bitmap file i.e. included in C++Builder distribution package. Also try to open .bmp in some graphic editor (GIMP, XnView...) and re-save it.
            – serge
            2 days ago












            up vote
            0
            down vote













            The easiest way to have a custom background is to use a client-aligned TImage, like @serge suggested.



            Another way is to load the BMP image into a Graphics::TBitmap object (like you are already attempting to do) and then use the Form's OnPaint event to draw the TBitmap onto the Form's Canvas.



            The "image is not valid" error means you are trying to load a .bmp file that is not a valid BMP image. Double check the contents of the file.






            share|improve this answer

























              up vote
              0
              down vote













              The easiest way to have a custom background is to use a client-aligned TImage, like @serge suggested.



              Another way is to load the BMP image into a Graphics::TBitmap object (like you are already attempting to do) and then use the Form's OnPaint event to draw the TBitmap onto the Form's Canvas.



              The "image is not valid" error means you are trying to load a .bmp file that is not a valid BMP image. Double check the contents of the file.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                The easiest way to have a custom background is to use a client-aligned TImage, like @serge suggested.



                Another way is to load the BMP image into a Graphics::TBitmap object (like you are already attempting to do) and then use the Form's OnPaint event to draw the TBitmap onto the Form's Canvas.



                The "image is not valid" error means you are trying to load a .bmp file that is not a valid BMP image. Double check the contents of the file.






                share|improve this answer












                The easiest way to have a custom background is to use a client-aligned TImage, like @serge suggested.



                Another way is to load the BMP image into a Graphics::TBitmap object (like you are already attempting to do) and then use the Form's OnPaint event to draw the TBitmap onto the Form's Canvas.



                The "image is not valid" error means you are trying to load a .bmp file that is not a valid BMP image. Double check the contents of the file.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                Remy Lebeau

                325k18243429




                325k18243429






















                    Gabi5537 is a new contributor. Be nice, and check out our Code of Conduct.










                     

                    draft saved


                    draft discarded


















                    Gabi5537 is a new contributor. Be nice, and check out our Code of Conduct.













                    Gabi5537 is a new contributor. Be nice, and check out our Code of Conduct.












                    Gabi5537 is a new contributor. Be nice, and check out our Code of Conduct.















                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186876%2fhow-to-set-a-background-for-my-form-in-cbuilder6%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    Guess what letter conforming each word

                    Port of Spain

                    Run scheduled task as local user group (not BUILTIN)