Thread: Problem

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    Problem

    Hi,

    I made my own Ownerdraw buttons. and there something wrong with the following code. I get GDI file read error, when I try to open the dialog which contains these buttons.

    Please help

    [tag]
    Code:
    {
    /*   DibB = new TDib("Close1.bmp");
       try
        	{
          pal = new TPalette(*DibB);
          }
       catch(...)
        	{
          pal = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       TBitbtn = new TBitmap(*DibB,pal);
       DibB2 = new TDib("Close2.bmp");
       try
        	{
          pal2 = new TPalette(*DibB2);
          }
       catch(...)
        	{
          pal2 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       TBitbtn2 = new TBitmap(*DibB2,pal2);
       DibB3 = new TDib("Close3.bmp");
       try
        	{
          pal3 = new TPalette(*DibB3);
          }
       catch(...)
        	{
          pal3 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       TBitbtn3 = new TBitmap(*DibB3,pal3);
       DibB4 = new TDib("txt1.bmp");
       try
        	{
          pal4 = new TPalette(*DibB4);
          }
       catch(...)
        	{
          pal4 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       Ttxt1 = new TBitmap(*DibB4,pal4);
       DibB5 = new TDib("txt2.bmp");
       try
        	{
          pal5 = new TPalette(*DibB5);
          }
       catch(...)
        	{
          pal5 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       Ttxt2 = new TBitmap(*DibB5,pal5);
       DibB6 = new TDib("txt3.bmp");
       try
        	{
          pal6 = new TPalette(*DibB6);
          }
       catch(...)
        	{
          pal6 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       Ttxt3 = new TBitmap(*DibB6,pal6);
       DibB7 = new TDib("html1.bmp");
       try
        	{
          pal7 = new TPalette(*DibB7);
          }
       catch(...)
        	{
          pal7 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       Thtml1 = new TBitmap(*DibB7,pal7);
       DibB8 = new TDib("html2.bmp");
       try
        	{
          pal8 = new TPalette(*DibB8);
          }
       catch(...)
        	{
          pal8 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       Thtml2 = new TBitmap(*DibB8,pal8);
       DibB9 = new TDib("html3.bmp");
       try
        	{
          pal9 = new TPalette(*DibB9);
          }
       catch(...)
        	{
          pal9 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETTE));
          }
    
       Thtml3 = new TBitmap(*DibB9,pal9);
       Close1 = new TOwnerDrawButton(this, IDOK, TBitbtn, TBitbtn2, TBitbtn3);
       Txt = new TOwnerDrawButton(this, IDTXT, Ttxt1, Ttxt2, Ttxt3);
       html = new TOwnerDrawButton(this, IDHTML, Thtml1, Thtml2, Thtml3);*/
    }
    [/tag]

    Ciao,
    Shawn

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    well, this is a windows forum question

    I imagine your filename that you are loading should probably show full path and not just the filename. try that first.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    4
    Oh did not know it was a windows forum.

    I do not have to show the full file path.

    I found the problem. the bmp's have to be in same folder, as the exe. So now it works.

    Thanks,
    Ciao,
    Shawn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM