Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Richard MacCutchan8-Aug-11 21:18
mveRichard MacCutchan8-Aug-11 21:18 
QuestionRe: Still trying to hunt down a runtime error in VS 2010, need suggestions [modified] Pin
AndrewG12319-Aug-11 7:10
AndrewG12319-Aug-11 7:10 
AnswerRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Richard MacCutchan9-Aug-11 8:52
mveRichard MacCutchan9-Aug-11 8:52 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
AndrewG12319-Aug-11 9:58
AndrewG12319-Aug-11 9:58 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Charles Oppermann9-Aug-11 10:37
Charles Oppermann9-Aug-11 10:37 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
AndrewG12319-Aug-11 14:04
AndrewG12319-Aug-11 14:04 
SuggestionRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Charles Oppermann10-Aug-11 2:45
Charles Oppermann10-Aug-11 2:45 
QuestionRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
AndrewG123110-Aug-11 9:49
AndrewG123110-Aug-11 9:49 
It is a valid pointer the first time it is called, but the second time it is initializes something is going wrong (it is remaining NULL when it should contain the information for the bitmap). However, they are destroyed after processing in my code. Here is the part of the bitmap processing code with the constructor/destructor through the "render" member where the flag of (m_Bitmap==NULL) becomes true and I get the message "Bitmap not init" (note, the 'a' in the code is my signal that this is code section telling me something is going wrong). Still, it works when the bitmap is first opened by the program, but not when I try to manipulate the image that results in the document being copied to a new window(CopyDoc is called).
C#
CWinSTMBmp::CWinSTMBmp(void)
{
    ZeroMemory(&m_HistogramData,sizeof(int)*256);
    m_ImageMode     = IMAGE_MODE_HORIZONTAL;
    m_Inversion     = false;
    m_Derivative    = false;
    m_LineDC        = false;
    m_Render        = false;
    m_Bitmap        = NULL;
    m_BmpBits       = NULL;
    m_SizeX         = 0;
    m_SizeY         = 0;

}

CWinSTMBmp::~CWinSTMBmp(void)
{
    if(m_Bitmap != NULL)
        DeleteObject(m_Bitmap);
}

bool CWinSTMBmp::Init(int sizex, int sizey, RGBQUAD* Pal)
{
    // if bmp already exists, delete it and start over

    if (m_Bitmap != NULL)
    {
        DeleteObject(m_Bitmap);
        m_Bitmap=NULL;
    }
    // create Bitmap in memory
    if (m_Bitmap == NULL)
    {
        ZeroMemory ( &m_ImageInfo, sizeof (BITMAPINFO) );
        m_ImageInfo.bmiHeader.biSize        = sizeof (BITMAPINFOHEADER);
        m_ImageInfo.bmiHeader.biWidth       = sizex;
        m_ImageInfo.bmiHeader.biHeight      = -sizey;
        m_ImageInfo.bmiHeader.biPlanes      = 1;
        m_ImageInfo.bmiHeader.biBitCount    = 32;
        m_ImageInfo.bmiHeader.biCompression = BI_RGB;
        m_ImageInfo.bmiHeader.biSizeImage   = 0;

        m_Bitmap=CreateDIBSection ( NULL, &m_ImageInfo, DIB_RGB_COLORS, (void **)&m_BmpBits, NULL, NULL );
    }

    // copy pallet
    memcpy(m_RGB,Pal,sizeof(RGBQUAD)*256);

    m_SizeX = sizex;
    m_SizeY = sizey;

    return true;
}

HBITMAP CWinSTMBmp::GetHBitmap(void)
{
    return HBITMAP(m_Bitmap);
}

BITMAPINFO* CWinSTMBmp::GetBmpInfo(void)
{
    return &m_ImageInfo;
}

bool CWinSTMBmp::Render(int* Data,int Min, int Max)
{


    if(Data == NULL)
    {
        AfxMessageBox("Passing in a NULL Data Ptr");
        return false;
    }

    if(m_Bitmap == NULL)
    {
        AfxMessageBox("aBitmap has not been init");
        return false;
    }

Do you happen to know what the
return HBITMAP(m_Bitmap);
is doing?
AnswerRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Charles Oppermann10-Aug-11 10:15
Charles Oppermann10-Aug-11 10:15 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
AndrewG123110-Aug-11 10:29
AndrewG123110-Aug-11 10:29 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Charles Oppermann10-Aug-11 10:42
Charles Oppermann10-Aug-11 10:42 
QuestionRe: Still trying to hunt down a runtime error in VS 2010, need suggestions [modified] Pin
AndrewG123117-Aug-11 12:36
AndrewG123117-Aug-11 12:36 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Charles Oppermann9-Aug-11 10:40
Charles Oppermann9-Aug-11 10:40 
GeneralRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Code-o-mat8-Aug-11 22:15
Code-o-mat8-Aug-11 22:15 
AnswerRe: Still trying to hunt down a runtime error in VS 2010, need suggestions Pin
Rolf Kristensen9-Aug-11 10:30
Rolf Kristensen9-Aug-11 10:30 
QuestionWhat does WS_EX_TRANSPARENT really mean ? Pin
Cold_Fearing_Bird8-Aug-11 6:21
Cold_Fearing_Bird8-Aug-11 6:21 
AnswerRe: What does WS_EX_TRANSPARENT really mean ? Pin
«_Superman_»8-Aug-11 6:35
professional«_Superman_»8-Aug-11 6:35 
QuestionIn MFC, How to avoid GUI long time waiting? Pin
yu-jian8-Aug-11 4:57
yu-jian8-Aug-11 4:57 
AnswerRe: In MFC, How to avoid GUI long time waiting? Pin
BadJerry8-Aug-11 5:12
BadJerry8-Aug-11 5:12 
GeneralRe: In MFC, How to avoid GUI long time waiting? Pin
Albert Holguin8-Aug-11 9:22
professionalAlbert Holguin8-Aug-11 9:22 
GeneralRe: In MFC, How to avoid GUI long time waiting? Pin
pix_programmer9-Aug-11 20:45
pix_programmer9-Aug-11 20:45 
QuestionMFC in Xcode Pin
BadJerry8-Aug-11 3:45
BadJerry8-Aug-11 3:45 
JokeRe: MFC in Xcode Pin
Chris Meech8-Aug-11 4:32
Chris Meech8-Aug-11 4:32 
JokeRe: MFC in Xcode Pin
BadJerry8-Aug-11 5:14
BadJerry8-Aug-11 5:14 
QuestionRe: MFC in Xcode Pin
BadJerry8-Aug-11 5:15
BadJerry8-Aug-11 5:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.