Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 657685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:51:04+00:00 2026-05-13T22:51:04+00:00

Friends its really giving me a great head ache about the problem I am

  • 0

Friends its really giving me a great head ache about the problem I am facing for the couple of days…Its simple…I want to communicate between two/more dialog boxes for example if there is a variable CString test..I want this test variable to be common for the dialogs/classes(considering each dialog having separate classes)…I tried lot methods, everything failed..atlast I tried this WM_COPYDATA method…even now, am not achieve what i wanted to do…

Sender Class:

#define ORGININFO 1

typedef struct ShareMessage
{
    CString mydata;
    int myValue;
}MYDATA;

void CCopyDataDlg::OnBnClickedOk()
{
    // TODO: Add your control notification handler code here
    MYDATA myData;
    COPYDATASTRUCT cData;

    myData.mydata.SetString(L"Rakesh");

    cData.dwData = ORGININFO;
    cData.cbData = sizeof(myData);
    cData.lpData = &myData;

    HWND hwnd  = (HWND)FindWindow(L"Dialog1",L"Test");



    SendMessageA(m_hWnd,WM_COPYDATA,(WPARAM)hwnd,(LPARAM)(LPVOID)&myData);


    Dialog1 dlg;
    dlg.DoModal();

}

Receiver class:

#define iMessage 1

typedef struct MyDatas
{
    CString myData;
    int myint;
}DATA;
PCOPYDATASTRUCT pData;


LRESULT Dialog1::WindowProc(UINT message,WPARAM wParam,LPARAM lparam)
{

    if(WM_COPYDATA != NULL)
        pData = (PCOPYDATASTRUCT)lparam;
        switch(pData->dwData)
        {
        case iMessage:
            MessageBoxA((HWND)AfxGetInstanceHandle(),(LPCSTR)(LPCTSTR)((DATA*)(pData->lpData))->myData,(LPCSTR)L"Test",MB_OK);

        }
    return 0;
}

in the above I dont know what is the mistake I am doing but its not receiving the data from the CCopyDialog class…Please help me with this…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:51:05+00:00Added an answer on May 13, 2026 at 10:51 pm

    I avoided to use WinProc..Instead of that I wrote a normal function(CopyData) in the class Dialog11..Created a modeless dialog in the class CCopyDialog1.. and called that function(CopyData)..It worked..Please check the below code…

    //CCopyDialog Class(sender)
    void CCopyDataDlg::OnBnClickedOk()
    {
        // TODO: Add your control notification handler code here
        Dialog1* dialog1 = new Dialog1();
        dialog1->Create(IDD_DIALOG1,0);
        dialog1->ShowWindow(SW_SHOW);
        ZeroMemory(&myData,sizeof(myData));
        wcscpy(myData.mydata,(L"Rakesh"));
    
        cData.dwData = ORGININFO;
        cData.cbData = sizeof(myData);
        cData.lpData = &myData;
    
           HWND rs = ::FindWindow(NULL,L"Rakesh");
    
        dialog1->CopyData(WM_COPYDATA,(WPARAM)rs,(LPARAM)&cData);
    
    
    }
    
    
    Dialog1 class(receiver)
    LRESULT Dialog1::CopyData(UINT message,WPARAM wParam,LPARAM lparam)
    {
        if(message == WM_COPYDATA)
        {
            pData = (PCOPYDATASTRUCT)lparam;
            wchar_t tes[50];
            memcpy(tes,((DATA*)(pData->lpData))->myData,sizeof(DATA));
    
        }
        else
        {
            return FALSE;
        }
    
        return 0;
    }
    

    Basically when compared to my previous code(code in my question)…theres lot of difference/mistakes..

    1.In the sendmessage i passed the structure instead of COPYDATASTRUCT..
    2.Called FindWindow before calling the Dialog1 window..
    3.Used the function WinProc function to receive the message..which was very hard to make it work..then avoided that and used a normal function
    4.Didnt pass a proper window handle…
    the above all are corrected by Bob Moore…credit goes to him….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello friends i designed a floating div and its working perfectly but due to
hey. friends i dont know this question is really asked before or not ?
I'm really struggling to get a query time down, its currently having to query
Some friends of mine and I were talking recently about version control, and how
I want a type A that will yield its hidden datum to an object
I've been having a play around with Mootools 1.3 server-side today. Its really nice
I'm sorry I'm really new to Java, I'm working on friends project. I seem
I've built a simple Friend model, which allows Users to have multiple friends. Here's
It's now possible to tag friends and location in feed post https://developers.facebook.com/blog/post/2012/03/07/building-better-stories-with-location-and-friends/ according to
The C++ friend keyword allows a class A to designate class B as its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.