Click here to Skip to main content
15,868,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Finding and comparing an image! Pin
Abdellatif_El_Khlifi13-Aug-07 15:59
Abdellatif_El_Khlifi13-Aug-07 15:59 
QuestionDisable and grey out menu item Pin
Johpoke30-Jul-07 11:28
Johpoke30-Jul-07 11:28 
AnswerRe: Disable and grey out menu item Pin
Michael Dunn30-Jul-07 12:10
sitebuilderMichael Dunn30-Jul-07 12:10 
AnswerRe: Disable and grey out menu item Pin
led mike30-Jul-07 12:42
led mike30-Jul-07 12:42 
AnswerRe: Disable and grey out menu item Pin
Mark Salsbery30-Jul-07 13:58
Mark Salsbery30-Jul-07 13:58 
QuestionRe: Disable and grey out menu item Pin
Johpoke30-Jul-07 21:54
Johpoke30-Jul-07 21:54 
Questionunexistent MailSlots doesn't return error. Pin
r3dqu33n30-Jul-07 10:13
r3dqu33n30-Jul-07 10:13 
QuestionMemory read error on Win2K, but not on XP Pin
Joe Smith IX30-Jul-07 7:15
Joe Smith IX30-Jul-07 7:15 
Hi,

I use a CButton-derived ThemeButton (http://www.codeproject.com/buttonctrl/WowButtons.asp[^]) in my project. It works on XP, but crashes on Windows 2000 with the following error:
"The instruction at '0x00000000' referenced memory at '0x00000000'. The memory could not be 'read'."

I traced it and it happened in the following function:

void ThemeButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
  HDC     hDC    = lpDrawItemStruct->hDC;
  CDC*    pDC    = CDC::FromHandle(hDC);
  CRect   rc     = lpDrawItemStruct->rcItem;
  CString sText    (_T(""));
 
  ::CopyRect(&m_pGDSData->rcClip,rc);
  ::CopyRect(&m_pGDSData->rcDest,rc);
  m_pGDSData->hDC = hDC;
 
   if( !(lpDrawItemStruct->itemState & (ODS_DISABLED|ODS_SELECTED)) )
  {
    if( !m_tracking )
    {
      if( lpDrawItemStruct->itemState & ODS_FOCUS )
      ::CopyRect(&m_pGDSData->rcSrc,m_rcDefault);
      else
      ::CopyRect(&m_pGDSData->rcSrc,m_rcNormal);
    }
    else
      ::CopyRect(&m_pGDSData->rcSrc,m_rcHot);
  }
  else
  {
    if( lpDrawItemStruct->itemState & ODS_SELECTED )
      ::CopyRect(&m_pGDSData->rcSrc,m_rcPressed);
    if( lpDrawItemStruct->itemState & ODS_DISABLED )
      ::CopyRect(&m_pGDSData->rcSrc,m_rcDissabled);
  }
 
  <big>(*GdiDrawStreamFunc)(hDC,sizeof(GdiDrawStreamStruct),m_pGDSData); // THIS CRASHES ON WIN2K</big>
 
  ...
}
 
 

BOOL ThemeButton::InitControl(...)
{
...
  m_pGDSData = new GdiDrawStreamStruct;
  ZeroMemory(m_pGDSData,sizeof(GdiDrawStreamStruct));
 
  m_pGDSData->...      = ...;
  m_pGDSData->...       = ...;
...
}	


in the .h file:
PGdiDrawStreamStruct m_pGDSData;
 
 
typedef struct GdiDrawStreamStruct_tag
{
  DWORD   signature;     // = 0x44727753;//"Swrd"
  DWORD   reserved;      // Zero value.
  HDC     hDC;           // handle to the device object of windiw to draw.
  RECT    rcDest;        // desination rect of window to draw.
  DWORD   unknown1;      // must be 1.
  HBITMAP hImage;        // handle to the specia bitmap image.
  DWORD   unknown2;      // must be 9.
  RECT    rcClip;        // desination rect of window to draw.
  RECT    rcSrc;         // source rect of bitmap to draw.
  DWORD   drawOption;    // option flag for drawing image.
  DWORD   leftArcValue;  // arc value of left side.
  DWORD   rightArcValue; // arc value of right side.
  DWORD   topArcValue;   // arc value of top side.
  DWORD   bottomArcValue;// arc value of bottom side.
  DWORD   crTransparent; // transparent color.

} GdiDrawStreamStruct, *PGdiDrawStreamStruct;


Can anyone help me see how it could behave differently in XP and 2K?
Thanks.
AnswerRe: Memory read error on Win2K, but not on XP Pin
Mark Salsbery30-Jul-07 8:00
Mark Salsbery30-Jul-07 8:00 
GeneralRe: Memory read error on Win2K, but not on XP Pin
Joe Smith IX30-Jul-07 8:38
Joe Smith IX30-Jul-07 8:38 
GeneralRe: Memory read error on Win2K, but not on XP Pin
Mark Salsbery30-Jul-07 8:46
Mark Salsbery30-Jul-07 8:46 
GeneralRe: Memory read error on Win2K, but not on XP Pin
Joe Smith IX30-Jul-07 9:08
Joe Smith IX30-Jul-07 9:08 
GeneralRe: Memory read error on Win2K, but not on XP Pin
Mark Salsbery30-Jul-07 9:58
Mark Salsbery30-Jul-07 9:58 
GeneralRe: Memory read error on Win2K, but not on XP Pin
led mike30-Jul-07 11:31
led mike30-Jul-07 11:31 
GeneralRe: Memory read error on Win2K, but not on XP Pin
Mark Salsbery30-Jul-07 14:45
Mark Salsbery30-Jul-07 14:45 
GeneralRe: Memory read error on Win2K, but not on XP [modified] Pin
Joe Smith IX30-Jul-07 16:55
Joe Smith IX30-Jul-07 16:55 
GeneralRe: Memory read error on Win2K, but not on XP Pin
Rick York30-Jul-07 9:52
mveRick York30-Jul-07 9:52 
GeneralRe: Memory read error on Win2K, but not on XP Pin
Joe Smith IX30-Jul-07 17:22
Joe Smith IX30-Jul-07 17:22 
QuestionParsing C files? Pin
julvr230-Jul-07 5:06
julvr230-Jul-07 5:06 
AnswerRe: Parsing C files? Pin
David Crow30-Jul-07 5:21
David Crow30-Jul-07 5:21 
AnswerRe: Parsing C files? Pin
Iain Clarke, Warrior Programmer30-Jul-07 5:38
Iain Clarke, Warrior Programmer30-Jul-07 5:38 
GeneralRe: Parsing C files? Pin
julvr230-Jul-07 6:00
julvr230-Jul-07 6:00 
GeneralRe: Parsing C files? Pin
Robert Surtees31-Jul-07 6:35
Robert Surtees31-Jul-07 6:35 
Questionneed help with thread functions Pin
alberthyc30-Jul-07 4:17
alberthyc30-Jul-07 4:17 
AnswerRe: need help with thread functions Pin
CPallini30-Jul-07 4:33
mveCPallini30-Jul-07 4:33 

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.