Thread: Problem need help

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

    Problem need help

    Hi,

    I'm using Borland 5.02

    I made my own buttons, and I guess has something to with my error I get. In the compiler when open this dialog box, which contains the ownerdraw buttons. it works fine, but after opening, and closing it, 12 times, the program crashes.

    I then tried the .exe, and I get GDI read file error.

    here is the code for the dialog.

    /* Project F12003
    Shawn Purdy Software
    Copyright © 2002. All Rights Reserved.

    SUBSYSTEM: F12003.exe Application
    FILE: SPoints.cpp
    AUTHOR: Shawn Purdy


    OVERVIEW
    ========
    Source file for implementation of SPointsDialog (TDialog).
    */

    #include <owl\owlpch.h>
    #pragma hdrstop

    #include "stdhdr.h"
    #include "SPoints.h"
    TColor red(0xe0, 0x0, 0x0);
    TColor ltred(0xff, 0x90, 0x90);
    TColor dkred(0x80, 0x0, 0x0);

    char WNCaptionString[80] = {"Points Standings"};
    DEFINE_RESPONSE_TABLE1(SPointsDialog, TDialog)
    EV_COMMAND(IDOK, CmCloseB),
    EV_WM_CTLCOLOR,
    END_RESPONSE_TABLE;



    SPointsDialog::SPointsDialog (TWindow* parent,
    TResId resId, TModule* module):
    TDialog(parent, resId, module)
    {
    // Change the window's background color
    TColor red(0xe0, 0x0, 0x0);
    SetBkgndColor(red);
    DibB = new TDib("Close1.bmp");
    try
    {
    pal = new TPalette(*DibB);
    }
    catch(...)
    {
    pal = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    TBitbtn = new TBitmap(*DibB,pal);
    DibB2 = new TDib("Close2.bmp");
    try
    {
    pal2 = new TPalette(*DibB2);
    }
    catch(...)
    {
    pal2 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    TBitbtn2 = new TBitmap(*DibB2,pal2);
    DibB3 = new TDib("Close3.bmp");
    try
    {
    pal3 = new TPalette(*DibB3);
    }
    catch(...)
    {
    pal3 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    TBitbtn3 = new TBitmap(*DibB3,pal3);
    DibB4 = new TDib("txt1.bmp");
    try
    {
    pal4 = new TPalette(*DibB4);
    }
    catch(...)
    {
    pal4 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    Ttxt1 = new TBitmap(*DibB4,pal4);
    DibB5 = new TDib("txt2.bmp");
    try
    {
    pal5 = new TPalette(*DibB5);
    }
    catch(...)
    {
    pal5 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    Ttxt2 = new TBitmap(*DibB5,pal5);
    DibB6 = new TDib("txt3.bmp");
    try
    {
    pal6 = new TPalette(*DibB6);
    }
    catch(...)
    {
    pal6 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    Ttxt3 = new TBitmap(*DibB6,pal6);
    DibB7 = new TDib("html1.bmp");
    try
    {
    pal7 = new TPalette(*DibB7);
    }
    catch(...)
    {
    pal7 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    Thtml1 = new TBitmap(*DibB7,pal7);
    DibB8 = new TDib("html2.bmp");
    try
    {
    pal8 = new TPalette(*DibB8);
    }
    catch(...)
    {
    pal8 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    Thtml2 = new TBitmap(*DibB8,pal8);
    DibB9 = new TDib("html3.bmp");
    try
    {
    pal9 = new TPalette(*DibB9);
    }
    catch(...)
    {
    pal9 = new TPalette((HPALETTE)::GetStockObject(DEFAULT_PALETT E));
    }

    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);
    }


    SPointsDialog::~SPointsDialog ()
    {
    delete Close1;
    delete Txt;
    delete html;
    delete DibB;
    delete pal;
    delete TBitbtn;
    delete DibB2;
    delete pal2;
    delete TBitbtn2;
    delete DibB3;
    delete pal3;
    delete TBitbtn3;
    delete DibB4;
    delete pal4;
    delete Ttxt1;
    delete DibB5;
    delete pal5;
    delete Ttxt2;
    delete DibB6;
    delete pal6;
    delete Ttxt3;
    delete DibB7;
    delete pal7;
    delete Thtml1;
    delete DibB8;
    delete pal8;
    delete Thtml2;
    delete DibB9;
    delete pal9;
    delete Thtml3;

    Destroy();

    }

    void
    SPointsDialog::SetupWindow()
    {

    TDialog::SetupWindow();
    CentreWindow();
    //Close1->DrawNewBitmap(TBitbtn);

    SetCaption(WNCaptionString);
    }


    void
    SPointsDialog::CmOk()
    {
    TDialog::CmOk();
    }

    void SPointsDialog::CmCloseB()
    {
    CmOk();
    }

    HBRUSH
    SPointsDialog::EvCtlColor(HDC hDC, HWND hWndChild, UINT ctlType)
    {
    switch (ctlType)
    {
    case CTLCOLOR_BTN:
    SetTextColor(hDC, ltred);
    SetBkMode(hDC, TRANSPARENT);
    SetBkColor(hDC, red);
    return (HBRUSH)TBrush(red);

    case CTLCOLOR_STATIC:
    SetTextColor(hDC, TColor::Black);
    SetBkMode(hDC, TRANSPARENT);
    SetBkColor(hDC, red);
    return (HBRUSH)TBrush(red);

    case CTLCOLOR_DLG:
    SetTextColor(hDC, TColor::Black);
    SetBkMode(hDC, TRANSPARENT);
    SetBkColor(hDC, ltred);
    return (HBRUSH)TBrush(ltred);

    case CTLCOLOR_EDIT:
    SetTextColor(hDC, dkred);
    SetBkMode(hDC, TRANSPARENT);
    SetBkColor(hDC, ltred);
    return (HBRUSH)TBrush(ltred);

    default:
    return TDialog::EvCtlColor(hDC, hWndChild, ctlType);
    }
    }

    void SPointsDialog::CentreWindow()
    {
    TRect rect;

    rect = GetWindowRect();
    int winwidth = rect.right - rect.left + 1;
    int winheight = rect.bottom - rect.top + 1;
    int width = TScreenDC().GetDeviceCaps(HORZRES);
    int height = TScreenDC().GetDeviceCaps(VERTRES);
    MoveWindow((width - winwidth) / 2, (height - winheight) / 2, winwidth, winheight, true);
    }


    THIS IS THE SPOINTS.H FILE[/SIZE]

    #if !defined(__spoints_h) // Sentry, use file only if it's not already included.
    #define __spoints_h

    /* Project F12003
    Shawn Purdy Software
    Copyright © 2002. All Rights Reserved.

    SUBSYSTEM: F12003.exe Application
    FILE: SPoints.h
    AUTHOR: Shawn Purdy


    OVERVIEW
    ========
    Class definition for SetDriversDialog (TDialog).
    */

    #include <owl\owlpch.h>
    #pragma hdrstop
    #if !defined(OWL_DEFS_H)
    # include <owl/defs.h>
    #endif
    # include <owl/edit.h>
    # include <owl/combobox.h>
    #include <owl/radiobut.h>

    #include <owl\dialog.h>
    #include "F12003app.rh"
    #include "ownerd.h"
    // Definition of all resources.

    #define MAX_PORTS 4
    #define MAX_BAUD 6
    #define MAX_PARITY 1
    #define MAX_DATABITS 1
    #define MAX_STOPBITS 1


    //extern struct SetDriversDialogTB tb;
    extern char WNCaptionString[80];

    //{{TDialog = SetDriversDialog}}

    class SPointsDialog : public TDialog {
    public:
    SPointsDialog (TWindow* parent,
    TResId resId = IDD_SPOINTS, TModule* module = 0);
    virtual ~SPointsDialog ();
    void SetupWindow();
    void CentreWindow();
    void CmCloseB();
    bool Inhibit;
    TOwnerDrawButton *Close1;
    TOwnerDrawButton *Txt;
    TOwnerDrawButton *html;
    // TButton *Close;
    TDib *DibB;
    TPalette *pal;
    TBitmap *TBitbtn;
    TDib *DibB2;
    TPalette *pal2;
    TBitmap *TBitbtn2;
    TDib *DibB3;
    TPalette *pal3;
    TBitmap *TBitbtn3;
    TDib *DibB4;
    TPalette *pal4;
    TBitmap *Ttxt1;
    TDib *DibB5;
    TPalette *pal5;
    TBitmap *Ttxt2;
    TDib *DibB6;
    TPalette *pal6;
    TBitmap *Ttxt3;
    TDib *DibB7;
    TPalette *pal7;
    TBitmap *Thtml1;
    TDib *DibB8;
    TPalette *pal8;
    TBitmap *Thtml2;
    TDib *DibB9;
    TPalette *pal9;
    TBitmap *Thtml3;
    int ModeIndex;

    protected:
    void CmOk();
    HBRUSH EvCtlColor(HDC hDC, HWND hWndChild, UINT ctlType);
    DECLARE_RESPONSE_TABLE(SPointsDialog);
    }; //{{WhatsNewDialog}}


    #endif // __setdates_h sentry.[SIZE=3]


    Thanks, for any help, anybody can provide.

    Ciao,
    Shawn

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    4
    So, is their anybody, that can help, or what!!!!!!!!.

    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