Click here to Skip to main content
15,903,540 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DirectX and Circles Pin
Waldermort24-Jan-07 6:22
Waldermort24-Jan-07 6:22 
QuestionTrouble with Vista, MAPI, and Outlook 2000 Pin
gageller24-Jan-07 4:01
gageller24-Jan-07 4:01 
QuestionProblem in Creating Activex in AtlComponent Pin
narayanagvs24-Jan-07 3:13
narayanagvs24-Jan-07 3:13 
QuestionDetect ethernet interface STATUS?! Pin
djmarki24-Jan-07 2:57
djmarki24-Jan-07 2:57 
QuestionRe: Detect ethernet interface STATUS?! Pin
David Crow24-Jan-07 5:01
David Crow24-Jan-07 5:01 
QuestionGDI Text Input Control Required Urgently.. Pin
zeemalik24-Jan-07 2:50
zeemalik24-Jan-07 2:50 
AnswerRe: GDI Text Input Control Required Urgently.. Pin
Mark Salsbery24-Jan-07 5:39
Mark Salsbery24-Jan-07 5:39 
Questionbased pointer crashed my app Pin
Alex Cutovoi24-Jan-07 2:09
Alex Cutovoi24-Jan-07 2:09 
Hi for all

I'm trying to pass some data between 2 windows. This is the class that I pass between my 2 windows. It's just a single class with a based pointer:
<br />
<br />
#ifndef TESTE_H<br />
#define TESTE_H <br />
#include <windows.h> <br />
void * vValue; <br />
class Teste <br />
{ <br />
    public: <br />
       Teste(); <br />
       ~Teste(); <br />
       void SetMsg(char * cMsg);<br />
       void ExibeMsg(); <br />
       Teste __based(vValue) * Single;<br />
    private: <br />
       char * m_cMsg;<br />
       char * m_cClassName;<br />
}; <br />
Teste::Teste()<br />
{<br />
    if(m_cClassName == 0)m_cClassName = "Classe Teste";<br />
}<br />
Teste::~Teste(){}<br />
void Teste::SetMsg(char * cMsg)<br />
{<br />
    m_cMsg = cMsg;<br />
}<br />
void Teste::ExibeMsg()<br />
{<br />
    if(m_cMsg != NULL)MessageBox(NULL, m_cMsg, "msg", MB_OK);}<br />
#endif TESTE_H<br />



This is the code that sends the data and handles the data:
<br />
<br />
case WM_COPYDATA:<br />
{<br />
    COPYDATASTRUCT * dataReceived = (COPYDATASTRUCT*)lParam; <br />
    Teste * tempTeste = (Teste*)dataReceived->lpData; <br />
    Teste * ttt = tempTeste->Single; <br />
    char cResult[256] = {0}; <br />
    int nCount = 0; <br />
    if(ttt != NULL)<br />
    {<br />
       MessageBox(NULL, "exibindo msg janela 1", "", MB_OK); <br />
       ttt->ExibeMsg();<br />
    }<br />
    break;<br />
}<br />
<br />
case WM_COMMAND:<br />
{ <br />
    switch(LOWORD(wParam))<br />
    {<br />
       case IDC_BUTTON1:<br />
       {<br />
          char cLength[20], cSize[5]; <br />
          if(HIWORD(wParam) == BN_CLICKED)<br />
          {<br />
             if(GetDlgItemText(hwnd, IDC_EDIT1, cLength, 20) != 0)<br />
             {<br />
                Teste teste1; <br />
                teste1.SetMsg("aaa");<br />
                vValue = (void*)&teste1;<br />
                COPYDATASTRUCT dataToSend;<br />
                dataToSend.cbData= sizeof(void*);<br />
                dataToSend.lpData = vValue;<br />
                dataToSend.dwData = 0;<br />
                HWND tempHwnd = FindWindow(NULL, "Janela 2");<br />
                if(tempHwnd != NULL)<br />
                {<br />
                   SendMessage(tempHwnd, WM_COPYDATA, wParam, (LPARAM)&dataToSend);<br />
                }<br />
             }<br />
             else<br />
             {<br />
                MessageBox(NULL, "EditBox with no text", "info", MB_OK);<br />
             }<br />
          }<br />
          break;<br />
       }<br />
    }<br />
    break;<br />
}<br />



The problem is, when I call the ExibeMsg() func with my object in the WM_COPYDATA message, the application crashes. What I'm doing wrong? Anyone can suggest me a solution?


Thanks for help
AnswerRe: based pointer crashed my app Pin
KarstenK24-Jan-07 2:27
mveKarstenK24-Jan-07 2:27 
GeneralRe: based pointer crashed my app Pin
toxcct24-Jan-07 2:30
toxcct24-Jan-07 2:30 
GeneralRe: based pointer crashed my app Pin
KarstenK24-Jan-07 4:35
mveKarstenK24-Jan-07 4:35 
GeneralRe: based pointer crashed my app Pin
toxcct24-Jan-07 4:39
toxcct24-Jan-07 4:39 
GeneralRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 2:38
Alex Cutovoi24-Jan-07 2:38 
GeneralRe: based pointer crashed my app Pin
KarstenK24-Jan-07 4:37
mveKarstenK24-Jan-07 4:37 
GeneralRe: based pointer crashed my app Pin
Mark Salsbery24-Jan-07 5:54
Mark Salsbery24-Jan-07 5:54 
QuestionRe: based pointer crashed my app Pin
David Crow24-Jan-07 4:17
David Crow24-Jan-07 4:17 
AnswerRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 6:00
Alex Cutovoi24-Jan-07 6:00 
QuestionRe: based pointer crashed my app Pin
David Crow24-Jan-07 7:01
David Crow24-Jan-07 7:01 
AnswerRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 8:10
Alex Cutovoi24-Jan-07 8:10 
GeneralRe: based pointer crashed my app Pin
David Crow24-Jan-07 8:37
David Crow24-Jan-07 8:37 
AnswerRe: based pointer crashed my app Pin
Michael Dunn24-Jan-07 9:34
sitebuilderMichael Dunn24-Jan-07 9:34 
GeneralRe: based pointer crashed my app Pin
Alex Cutovoi24-Jan-07 11:40
Alex Cutovoi24-Jan-07 11:40 
GeneralRe: based pointer crashed my app Pin
Michael Dunn24-Jan-07 12:37
sitebuilderMichael Dunn24-Jan-07 12:37 
GeneralRe: based pointer crashed my app Pin
Alex Cutovoi25-Jan-07 16:34
Alex Cutovoi25-Jan-07 16:34 
QuestionComputing hashes and comparing hashes for C++ Pin
vgandhi24-Jan-07 2:05
vgandhi24-Jan-07 2:05 

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.