CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++.

    Reply
     
    Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
      #1    
    Old July 19th, 2005, 09:44 AM
    spynet spynet is offline
    Member
     
    Join Date: Mar 2003
    Posts: 32
    spynet is an unknown quantity at this point (<10)
    BUILD Error 2440

    Hi,
    I have the follow error while I compile a program from visual c++(visual studio 6.0) to visual studio .net..

    This is the code where I have the error:

    In the header file:

    Code:
    afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct);

    in the .cpp file

    Code:
    ON_MESSAGE(WM_COPYDATA, OnCopyData)
    (Here this is the point of error)...


    This is the body of function:

    //-----------------------------------------------------------------------------
    BOOL CPwSafeDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
    {
    DWORD dwLen, dwPasswordLen, dwKeyFileLen;
    CString strData, strPassword, strKeyFile, strFile;

    NotifyUserActivity();

    if(pCopyDataStruct->lpData != NULL)
    {
    dwLen = (DWORD)_tcslen((LPCTSTR)pCopyDataStruct->lpData);
    if(dwLen == 0) return TRUE;

    strData = (LPCTSTR)pCopyDataStruct->lpData;
    dwPasswordLen = pCopyDataStruct->dwData >> 16;
    dwKeyFileLen = pCopyDataStruct->dwData & 0xffff;

    if((dwPasswordLen + dwKeyFileLen) >= dwLen) return TRUE;

    if(dwPasswordLen != 0) strPassword = strData.Mid(0, dwPasswordLen);
    if(dwKeyFileLen != 0) strKeyFile = strData.Mid(dwPasswordLen, dwKeyFileLen);

    if((dwPasswordLen + dwKeyFileLen) != 0)
    strFile = strData.Right(strData.GetLength() - (int)dwPasswordLen - (int)dwKeyFileLen);
    else strFile = strData;

    if(strFile.GetLength() == 0) return TRUE;

    OnFileClose();
    if(m_bFileOpen == TRUE) return TRUE;

    if((dwPasswordLen != 0) && (dwKeyFileLen != 0))
    _OpenDatabase(strFile, strPassword, strKeyFile, FALSE, NULL);
    else if(dwPasswordLen != 0)
    _OpenDatabase(strFile, strPassword, NULL, FALSE, NULL);
    else if(dwKeyFileLen != 0)
    _OpenDatabase(strFile, NULL, strKeyFile, FALSE, NULL);
    else
    _OpenDatabase(strFile, NULL, NULL, FALSE, NULL);

    if((m_bMinimized == TRUE) || (m_bShowWindow == FALSE)) OnViewHide();
    }

    return TRUE;

    }
    /----------------------------------------------




    The error message is:
    error C2440: "static_cast": impossibile convertire da "BOOL (__thiscall CPwSafeDlg::* )(CWnd *,COPYDATASTRUCT *)" a "LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)"..

    Can anyone able to help me, please?

    Thank you very much..
    __________________
    spynet
    "Software is like sex, it's better when it's free." - Linus Torvalds

    Last edited by spynet; July 19th, 2005 at 09:57 AM. Reason: Correct TITLE
    Reply With Quote
      #2    
    Old July 19th, 2005, 09:57 AM
    philkr philkr is offline
    Senior Member
     
    Join Date: Jul 2005
    Location: Germany
    Posts: 1,194
    philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)
    Re: BUILD Error 2440

    Your message handling function must have the parameter format (WPARAM, LPARAM). You can then cast the LPARAM to a COPYDATASTRUCT* in the function.
    __________________
    Please don't forget to rate users who helped you!
    Reply With Quote
      #3    
    Old July 19th, 2005, 10:01 AM
    spynet spynet is offline
    Member
     
    Join Date: Mar 2003
    Posts: 32
    spynet is an unknown quantity at this point (<10)
    Re: Build Error 2440

    Sorry,
    Can you show me an example?

    Thank you for your reply.
    __________________
    spynet
    "Software is like sex, it's better when it's free." - Linus Torvalds

    Last edited by spynet; July 20th, 2005 at 04:54 AM.
    Reply With Quote
      #4    
    Old July 19th, 2005, 10:04 AM
    philkr philkr is offline
    Senior Member
     
    Join Date: Jul 2005
    Location: Germany
    Posts: 1,194
    philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)
    Re: Buod Error 2440

    Code:
    afx_msg LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
    ON_MESSAGE(WM_COPYDATA, OnCopyData)
    
    LRESULT CPwSafeDlg::OnCopyData(WPARAM wParam, LPARAM lParam)
    {
    COPYDATASTRUCT* pCopyDataStruct = (COPYDATASTRUCT*)lParam;
    DWORD dwLen, dwPasswordLen, dwKeyFileLen;
    CString strData, strPassword, strKeyFile, strFile;
    
    NotifyUserActivity();
    
    if(pCopyDataStruct->lpData != NULL)
    {
    dwLen = (DWORD)_tcslen((LPCTSTR)pCopyDataStruct->lpData);
    if(dwLen == 0) return TRUE;
    
    strData = (LPCTSTR)pCopyDataStruct->lpData;
    dwPasswordLen = pCopyDataStruct->dwData >> 16;
    dwKeyFileLen = pCopyDataStruct->dwData & 0xffff;
    
    if((dwPasswordLen + dwKeyFileLen) >= dwLen) return TRUE;
    
    if(dwPasswordLen != 0) strPassword = strData.Mid(0, dwPasswordLen);
    if(dwKeyFileLen != 0) strKeyFile = strData.Mid(dwPasswordLen, dwKeyFileLen);
    
    if((dwPasswordLen + dwKeyFileLen) != 0)
    strFile = strData.Right(strData.GetLength() - (int)dwPasswordLen - (int)dwKeyFileLen);
    else strFile = strData;
    
    if(strFile.GetLength() == 0) return TRUE;
    
    OnFileClose();
    if(m_bFileOpen == TRUE) return TRUE;
    
    if((dwPasswordLen != 0) && (dwKeyFileLen != 0))
    _OpenDatabase(strFile, strPassword, strKeyFile, FALSE, NULL);
    else if(dwPasswordLen != 0)
    _OpenDatabase(strFile, strPassword, NULL, FALSE, NULL);
    else if(dwKeyFileLen != 0)
    _OpenDatabase(strFile, NULL, strKeyFile, FALSE, NULL);
    else
    _OpenDatabase(strFile, NULL, NULL, FALSE, NULL);
    
    if((m_bMinimized == TRUE) || (m_bShowWindow == FALSE)) OnViewHide();
    }
    
    return TRUE;
    
    }
    EDIT: I hope it's the correct function type now. I don't use MFC.
    __________________
    Please don't forget to rate users who helped you!

    Last edited by philkr; July 19th, 2005 at 11:13 AM. Reason: Correction
    Reply With Quote
      #5    
    Old July 19th, 2005, 10:10 AM
    spynet spynet is offline
    Member
     
    Join Date: Mar 2003
    Posts: 32
    spynet is an unknown quantity at this point (<10)
    Re: BUILD Error 2440

    Hi,
    now I have the follow error...

    error C2440: "static_cast": impossibile convertire da "BOOL (__thiscall CPwSafeDlg::* )(CWnd *,WPARAM,LPARAM)" a "LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)".....
    __________________
    spynet
    "Software is like sex, it's better when it's free." - Linus Torvalds
    Reply With Quote
      #6    
    Old July 19th, 2005, 10:32 AM
    NoHero's Avatar
    NoHero NoHero is offline
    Moderator
     
    Join Date: Mar 2004
    Location: (Upper-) Austria
    Posts: 2,899
    NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)
    Re: Buod Error 2440

    Code:
    ON_MESSAGE( /* ... */ )
    Always requires a member function with the following header:

    Code:
    LRESULT CMyWindow::OnMessage ( WPARAM wParam, LPARAM lParam );
    So try to use

    Code:
    ON_WM_COPYDATA( /* ... */ )
    Instead.
    __________________
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!
    Reply With Quote
      #7    
    Old July 19th, 2005, 11:04 AM
    spynet spynet is offline
    Member
     
    Join Date: Mar 2003
    Posts: 32
    spynet is an unknown quantity at this point (<10)
    Re: Build Error 2440

    Hi,
    I am confused,

    I must use ON_WM_COPYDATA( /* ... */ ) instead of ON_MESSAGE(WM_COPYDATA, OnCopyData)...

    Sorry but I not understand.....
    __________________
    spynet
    "Software is like sex, it's better when it's free." - Linus Torvalds

    Last edited by spynet; July 20th, 2005 at 04:54 AM.
    Reply With Quote
      #8    
    Old July 19th, 2005, 11:33 AM
    philkr philkr is offline
    Senior Member
     
    Join Date: Jul 2005
    Location: Germany
    Posts: 1,194
    philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)
    Re: Buod Error 2440

    Did it work with my correcte version? I'm curious.
    __________________
    Please don't forget to rate users who helped you!
    Reply With Quote
      #9    
    Old July 19th, 2005, 11:40 AM
    spynet spynet is offline
    Member
     
    Join Date: Mar 2003
    Posts: 32
    spynet is an unknown quantity at this point (<10)
    Re: Buod Error 2440

    Hi,
    you can download the source code from http://keepass.sourceforge.net/

    I use visual studio .net 7.1- framework 1.1

    I await.. your solution....
    Thanks for your patience
    __________________
    spynet
    "Software is like sex, it's better when it's free." - Linus Torvalds
    Reply With Quote
      #10    
    Old July 19th, 2005, 11:50 AM
    philkr philkr is offline
    Senior Member
     
    Join Date: Jul 2005
    Location: Germany
    Posts: 1,194
    philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)
    Re: Buod Error 2440

    I mean. Do you still have errors with the version I posted before. Because I edited it. It's different from the version you already tested and about which you said it would still have errors.
    __________________
    Please don't forget to rate users who helped you!
    Reply With Quote
      #11    
    Old July 20th, 2005, 04:49 AM
    spynet spynet is offline
    Member
     
    Join Date: Mar 2003
    Posts: 32
    spynet is an unknown quantity at this point (<10)
    Re: Build Error 2440

    Hi,
    Now it's ok. Thank you very much for your patience and for your attention. I have understand the solution and why there was the error...

    By and good holiday.

    Crismer
    __________________
    spynet
    "Software is like sex, it's better when it's free." - Linus Torvalds
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 10:30 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009