Click here to Skip to main content
15,925,181 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: 16 color to black and white Pin
ThatsAlok11-Oct-07 4:10
ThatsAlok11-Oct-07 4:10 
AnswerRe: 16 color to black and white Pin
Mark Salsbery11-Oct-07 12:33
Mark Salsbery11-Oct-07 12:33 
QuestionMFC + Windows Embedded Xp [modified] Pin
bankai12311-Oct-07 3:42
bankai12311-Oct-07 3:42 
AnswerRe: MFC + Windows Embedded Xp Pin
JudyL_MD11-Oct-07 4:57
JudyL_MD11-Oct-07 4:57 
GeneralRe: MFC + Windows Embedded Xp Pin
bankai12311-Oct-07 5:00
bankai12311-Oct-07 5:00 
QuestionAny alternative for IsBadReadPtr / IsBadWritePtr Pin
sw@thi11-Oct-07 3:03
sw@thi11-Oct-07 3:03 
AnswerRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
Cedric Moonen11-Oct-07 3:25
Cedric Moonen11-Oct-07 3:25 
GeneralRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
sw@thi11-Oct-07 20:12
sw@thi11-Oct-07 20:12 
Thanks for your reply. here is why i think i need to check for bad ptr:

theres this function in a class that would return a pointer. something like this

CMyWnd *GetMyWnd(){ return m_myWnd};

now when this object is destroyed m_myWnd is delete and the pointer is set to NULL, but after the object is destroyed in someother function somewhere this function is again called then GetMyWnd retunrs a CMyWnd* with a junk value. when this pointer is set to NULL in the destructor, it should return NULL but it doesnt, it returns something like 0xcdcdcdcd in the calling function say we do something like this

GetMyWnd()->SetSomeFunc(); // the application crashes here, in VS2005 where as in 2003 it works fine.

this happens because the pointer that GetMyWnd returns is not a valid pointer and once it tries to acces any member of CMyWnd the application crashes.

i've changed the above statement to something like this:

CMyWnd *pWnd = GetMyWnd(); // i also tried CMyWnd *pWnd = NULL; pWnd = GetMyWnd();
if(pWnd)
{
pWnd->SetSomeFunc();
}

to see what GetMyWnd returns. It returns a Junk value, and the if condition is evaluated to true and it enters inside and crashes. this is the reason that i thought i should check for NULL as well as Bad Ptr.

how do i solve this?? is there anyother way??


GeneralRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
JudyL_MD12-Oct-07 3:19
JudyL_MD12-Oct-07 3:19 
AnswerRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
Matthew Faithfull11-Oct-07 3:32
Matthew Faithfull11-Oct-07 3:32 
GeneralRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
Stephen Hewitt11-Oct-07 17:58
Stephen Hewitt11-Oct-07 17:58 
GeneralRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
Matthew Faithfull11-Oct-07 23:22
Matthew Faithfull11-Oct-07 23:22 
GeneralRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
Stephen Hewitt14-Oct-07 14:55
Stephen Hewitt14-Oct-07 14:55 
GeneralRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
sw@thi11-Oct-07 20:22
sw@thi11-Oct-07 20:22 
QuestionRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
David Crow11-Oct-07 3:54
David Crow11-Oct-07 3:54 
AnswerRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
led mike11-Oct-07 4:12
led mike11-Oct-07 4:12 
QuestionRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
ThatsAlok11-Oct-07 4:08
ThatsAlok11-Oct-07 4:08 
AnswerRe: Any alternative for IsBadReadPtr / IsBadWritePtr Pin
Stephen Hewitt11-Oct-07 18:00
Stephen Hewitt11-Oct-07 18:00 
QuestionHow to access properties of ActiveX control in atl Pin
Rajesh_Yadav_8011-Oct-07 2:40
Rajesh_Yadav_8011-Oct-07 2:40 
GeneralRe: How to access properties of ActiveX control in atl Pin
Matthew Faithfull11-Oct-07 2:52
Matthew Faithfull11-Oct-07 2:52 
QuestionHow to send hex data to TCP socket using Winsock Pin
alofang11-Oct-07 2:35
alofang11-Oct-07 2:35 
AnswerRe: How to send hex data to TCP socket using Winsock Pin
ThatsAlok11-Oct-07 2:55
ThatsAlok11-Oct-07 2:55 
GeneralRe: How to send hex data to TCP socket using Winsock Pin
alofang11-Oct-07 4:13
alofang11-Oct-07 4:13 
QuestionBackground color Pin
ArielR11-Oct-07 2:33
ArielR11-Oct-07 2:33 
AnswerRe: Background color Pin
Nelek11-Oct-07 2:41
protectorNelek11-Oct-07 2:41 

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.