Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. passing 4 parameters in SendMessage()

passing 4 parameters in SendMessage()

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabase
13 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sulabh_expert rediffmail com
    wrote on last edited by
    #1

    Hi all, My problem is i want to pass 4 variables in my SendMessage function. What i am doing is pasing a single variable and the other three through structure like this :- struct pasiin_val { int index; CString url; CString task_n; }; void CMyThread::LogMessage(CString& logmsg) { if (m_pLogWnd) { pasiin_val obj_val; obj_val.index = test_int; obj_val.url = test_str; obj_val.task_n = test_task_name; m_pLogWnd->SendMessage(LOGMSG, (WPARAM)(CString*)&logmsg, obj_val); } } when i am trying to do this its giving an error:- error C2664: 'SendMessageA' : cannot convert parameter 3 from 'struct pasiin_val' to 'long' can anybody help me in this...... thanks in advance

    P T 2 Replies Last reply
    0
    • S sulabh_expert rediffmail com

      Hi all, My problem is i want to pass 4 variables in my SendMessage function. What i am doing is pasing a single variable and the other three through structure like this :- struct pasiin_val { int index; CString url; CString task_n; }; void CMyThread::LogMessage(CString& logmsg) { if (m_pLogWnd) { pasiin_val obj_val; obj_val.index = test_int; obj_val.url = test_str; obj_val.task_n = test_task_name; m_pLogWnd->SendMessage(LOGMSG, (WPARAM)(CString*)&logmsg, obj_val); } } when i am trying to do this its giving an error:- error C2664: 'SendMessageA' : cannot convert parameter 3 from 'struct pasiin_val' to 'long' can anybody help me in this...... thanks in advance

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      sulabh_expert@rediffmail.com wrote:

      m_pLogWnd->SendMessage(LOGMSG, (WPARAM)(CString*)&logmsg, obj_val);

      Modify this to,

      m_pLogWnd->SendMessage(LOGMSG, (WPARAM)(&logmsg),(LPARAM)(&obj_val));

      Prasad Notifier using ATL | Operator new[],delete[][^]

      S 1 Reply Last reply
      0
      • P prasad_som

        sulabh_expert@rediffmail.com wrote:

        m_pLogWnd->SendMessage(LOGMSG, (WPARAM)(CString*)&logmsg, obj_val);

        Modify this to,

        m_pLogWnd->SendMessage(LOGMSG, (WPARAM)(&logmsg),(LPARAM)(&obj_val));

        Prasad Notifier using ATL | Operator new[],delete[][^]

        S Offline
        S Offline
        sulabh_expert rediffmail com
        wrote on last edited by
        #3

        now there is no error But when i m accessing it my MessageMap function like this:- recv_val *obj_recv = static_cast(lparam); its giving an error:- error C2440: 'static_cast' : cannot convert from 'long' to 'struct recv_val *' recv val is also a structure in other class in which i m having my messagemap struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

        P P D 3 Replies Last reply
        0
        • S sulabh_expert rediffmail com

          now there is no error But when i m accessing it my MessageMap function like this:- recv_val *obj_recv = static_cast(lparam); its giving an error:- error C2440: 'static_cast' : cannot convert from 'long' to 'struct recv_val *' recv val is also a structure in other class in which i m having my messagemap struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          sulabh_expert@rediffmail.com wrote:

          recv_val *obj_recv = static_cast(lparam);

          See replies below. -- modified at 3:29 Tuesday 20th March, 2007

          Prasad Notifier using ATL | Operator new[],delete[][^]

          S 1 Reply Last reply
          0
          • P prasad_som

            sulabh_expert@rediffmail.com wrote:

            recv_val *obj_recv = static_cast(lparam);

            See replies below. -- modified at 3:29 Tuesday 20th March, 2007

            Prasad Notifier using ATL | Operator new[],delete[][^]

            S Offline
            S Offline
            sulabh_expert rediffmail com
            wrote on last edited by
            #5

            same error is coming..........

            P T 2 Replies Last reply
            0
            • S sulabh_expert rediffmail com

              now there is no error But when i m accessing it my MessageMap function like this:- recv_val *obj_recv = static_cast(lparam); its giving an error:- error C2440: 'static_cast' : cannot convert from 'long' to 'struct recv_val *' recv val is also a structure in other class in which i m having my messagemap struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

              P Offline
              P Offline
              Parthi_Appu
              wrote on last edited by
              #6

              sulabh_expert@rediffmail.com wrote:

              struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

              Make sure the struct is properly defined. In the sender side you defined as int, CString, CString... You can typecaste as below,

              struct recv_val* pStruct = (recv_val*)(LPVOID)lParam;


              Do your Duty and Don't expect the Result

              T S 2 Replies Last reply
              0
              • P Parthi_Appu

                sulabh_expert@rediffmail.com wrote:

                struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

                Make sure the struct is properly defined. In the sender side you defined as int, CString, CString... You can typecaste as below,

                struct recv_val* pStruct = (recv_val*)(LPVOID)lParam;


                Do your Duty and Don't expect the Result

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                using C style cast is the simplicity mistake...;P


                [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                1 Reply Last reply
                0
                • S sulabh_expert rediffmail com

                  same error is coming..........

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #8

                  Use reinterpret_cast.

                  recv_val *obj_recv = reinterpret_cast<recv_val*>(lParam);

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  1 Reply Last reply
                  0
                  • S sulabh_expert rediffmail com

                    same error is coming..........

                    T Offline
                    T Offline
                    toxcct
                    wrote on last edited by
                    #9

                    use reinterpret_cast<>() instead


                    [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                    1 Reply Last reply
                    0
                    • P Parthi_Appu

                      sulabh_expert@rediffmail.com wrote:

                      struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

                      Make sure the struct is properly defined. In the sender side you defined as int, CString, CString... You can typecaste as below,

                      struct recv_val* pStruct = (recv_val*)(LPVOID)lParam;


                      Do your Duty and Don't expect the Result

                      S Offline
                      S Offline
                      sulabh_expert rediffmail com
                      wrote on last edited by
                      #10

                      thanku all my problem got solved..................:)

                      D 1 Reply Last reply
                      0
                      • S sulabh_expert rediffmail com

                        Hi all, My problem is i want to pass 4 variables in my SendMessage function. What i am doing is pasing a single variable and the other three through structure like this :- struct pasiin_val { int index; CString url; CString task_n; }; void CMyThread::LogMessage(CString& logmsg) { if (m_pLogWnd) { pasiin_val obj_val; obj_val.index = test_int; obj_val.url = test_str; obj_val.task_n = test_task_name; m_pLogWnd->SendMessage(LOGMSG, (WPARAM)(CString*)&logmsg, obj_val); } } when i am trying to do this its giving an error:- error C2664: 'SendMessageA' : cannot convert parameter 3 from 'struct pasiin_val' to 'long' can anybody help me in this...... thanks in advance

                        T Offline
                        T Offline
                        ThatsAlok
                        wrote on last edited by
                        #11

                        sulabh_expert@rediffmail.com wrote:

                        when i am trying to do this its giving an error:- error C2664: 'SendMessageA' : cannot convert parameter 3 from 'struct pasiin_val' to 'long'

                        better try WM_COPYDATA! http://www.codersource.net/mfc_ipc_wm_copydata.aspx[^]

                        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                        cheers, Alok Gupta Global Interface Table: An Easy Way to Marshal an Interface Pointer[new] VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                        1 Reply Last reply
                        0
                        • S sulabh_expert rediffmail com

                          now there is no error But when i m accessing it my MessageMap function like this:- recv_val *obj_recv = static_cast(lparam); its giving an error:- error C2440: 'static_cast' : cannot convert from 'long' to 'struct recv_val *' recv val is also a structure in other class in which i m having my messagemap struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #12

                          sulabh_expert@rediffmail.com wrote:

                          recv val is also a structure in other class in which i m having my messagemap struct recv_val { CString Recv_URL; CString Recv_name; int Recv_index; };

                          The structures must match. :rolleyes:


                          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                          "Judge not by the eye but by the heart." - Native American Proverb

                          1 Reply Last reply
                          0
                          • S sulabh_expert rediffmail com

                            thanku all my problem got solved..................:)

                            D Offline
                            D Offline
                            Divyang Mithaiwala
                            wrote on last edited by
                            #13

                            I am facing same issue. My message received at other side but I can access/cast structure at receiving side. Can you specify which one solution works for you?


                            regards, Divyang Mithaiwala

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups