How to pass a CString from one application to another application using WPARAM/LPARAM in sendmessage fn.

I have two different application A & B. I am trying to send a message from A to B. In application A , I get the window handle of application B and call postmessage fn to post a message to application B. While posting the message I am trying to send a
cstring in wparam parameter so that it can be accessed in the message handler.
Code in Application A:
void CTestApplnDlg::OnBnClickedOk()
 CString csProcessName = _T("FSAPP.exe");
 CFSProcess objProcess;
 HWND hFSWnd = NULL;
 if(objProcess.GetProcessHandle(csProcessName, hFSWnd))
  CString * csMessage = new CString(_T("This is message from A application."));
  ::PostMessage(hFSWnd, WM_THIRD_PARTY_NOTIFICATION, (WPARAM)csMessage
, NULL);
In the other application in the event event handler I try to do the following :
LRESULT CMainFrame::OnProcessThirdPartyNotification(WPARAM wParam, LPARAM lParam)
 CString* csMessage = (CString*)wParam;
 if(csMessage )
  AfxMessageBox(*csMessage);
 return 0L;
In the message handler fn, the variable csMessage is pointing to a address but the value is a bad ptr. On accessing the variable like *csMessage it crashes. I have created the variable in heap when the message is posted. So I hope the variable will be in memory.
Pls help.

The ultimate problem is that when you place a CString in a wparam like that you are putting an address.  That address only has meaning in the first program.  Your second program cannot access the first programs memory (this is good, otherwise misbehaving
programs could take down all applications in Windows).  But it does make transferring data between programs more complicated. 
Some messages like WM_COPYDATA will copy a data buffer from one process to another and are appropriate for what you are trying to do, but a custom message like
WM_THIRD_PARTY_NOTIFICATION is not one of them.
By the way your example has a memory leak as well since you would have no way to ever clean up the string you allocate in OnBnClickedOk

Similar Messages

  • How do I transfer files from one computer to another without using cables??

    How do I transfer files from one computer to another without using cables?

    Wifi network
    Email
    Thumb Drive
    Online storage such as, iCloud Google Docs, SkyDrive, etc.

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • How to pass a variable from one scene to another

    I'm making a call from one scene to another via a button, but I have two buttons calling the same scene, each for a different purpose, and I need to pass certain variables tied to each button to that called scene. How can I do this?

    import flash.events.MouseEvent;
    stop();
    var nam:String="test";
    testscene2.addEventListener(MouseEvent.CLICK,fn);
    function fn(e:MouseEvent){
        nam="Raja";
        gotoAndStop(1,"Scene 3");
    testscene1.addEventListener(MouseEvent.CLICK,fn1);
    function fn1(e:MouseEvent){
        nam="Emily";
        gotoAndStop(1,"Scene 2");

  • How to change  XML  Structure from one form to another form using OO ABAP.

    Hi Experts,
    In my Scenario, i need to do ABAP Mapping in order to change Incoming structure from one form to another.
    My Input to ABAP Mapping (OO ABAP Program)would be :
         <A>..........</A>
         <B>..........</B>
         <C> .........</C>
         <D>..........</D>
         <E>..........</E>
         <F>..........</F>
    OO ABAP Program need to read this input and change the XML Structure into below form:
         <A>..........</A>
         <B>..........</B>
         <C> .........</C>
          <X>
                <D>..........</D>
                <E>..........</E>
          <F>...............<F>
    Please provide inputs (sample Code) to solve this issue.
    Thanks,
    Kish.
    Edited by: Kishore Reddy Thamma on Jan 22, 2008 2:51 PM
    Edited by: Kishore Reddy Thamma on Jan 22, 2008 2:52 PM

    Hi,
    Please provide sample code or Material for converting XML Structure from one form to another using OO ABAP and
    Steps for ABAP MAPPING.
    Thanks,
    Kish.

  • ADF : How to pass a variable from one frame to another frame ?

    Hi,
    I have an html page divided into 3 frames, all inside a frameset. Each frame are linked to a specific .jsf page (src attribute). When I list a list thanks to a ADF datatable in ONE frame, each row has a "show more" button. When I click this button I succeeded to print row detail inside the same frame thanks to the processScope ADF's native variable. The problem is that I want to display the row detail in another frame, clicking from this current frame. So for this I need to reload the other frame which display the content of the processScope variable.
    For this I use the javascript code :
    => parent.frames['bottomRight'].location.reload()
    Just before refreshing, I put the variable in the processScope of course like it appears in the backing bean :
    FacesContext context = FacesContext.getCurrentInstance();
              CLPRMBuilding building = (CLPRMBuilding)
         context.getApplication().getVariableResolver().resolveVariable(context, "building");
         if (building == null)
         return "error";
         AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
         afContext.getProcessScope().put("buildingDetail", building);
    Next, when the user click on the button "show more" a binding CoreCommandButton component is done. And the accessor's code is executed :
    public void setShowMoreCommandButton(CoreCommandButton showMoreCommandButton) {
              this.showMoreCommandButton = showMoreCommandButton;
              showMoreCommandButton.setOnclick("parent.frames['bottomRight'].location.reload()");
    And so the other frame is reloaded ! But the "buildingDetail" variable seems not to be present in the processScope because in the jsf page displayed by the other frame no content is printed, like if the variable were not initialized. How to do then ? How to pass the buildingDetail variable to the other frame which I need to reload to refresh it's content ?

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • How to pass the values from one screen to another

    HI,
    consider me21n,
    po is created with the item category L,so components tab is enabled.that u all know.
    i have added the custom tab in the item details with netwt,gross wt,no of pieces and one more field.
    those fields are also in component structure of material data.
    i need to pass the matnr,maktx,quantity,ntwt,grosswt from the component to be displayed in  the subscreen.
    i used import mdpm to xmdpm from memory id 'subcon',  where it is exported from the function module 'me_components-maintain'.
    how to pass  all the values from component of structure MDPM to the subscreen of custom tab in the item details.
    help me pls........................'

    hi everyone,
    MODULE status_0111 OUTPUT.
    data : fill type i.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.,
      DESCRIBE TABLE lt_zzmm_po_comp LINES fill.
      ctrl_0111-lines = fill.
    ENDMODULE.                 " STATUS_0111  OUTPUT
    MODULE fetch_data OUTPUT.
      ctrl_0111-lines = 2.
    import xmdpm to lt_xmdpm from memory id 'SUBCON'.
    IF not sy-subrc eq 0.
        CLEAR lt_zzmm_po_comp[].
        LOOP AT lt_xmdpm.
          MOVE-CORRESPONDING lt_xmdpm TO lt_zzmm_po_comp.
          APPEND lt_zzmm_po_comp.
        ENDLOOP.
    MOVE-CORRESPONDING lt_zzmm_po_comp TO ctrl_0111.
      read table ctrl_0111-cols into col where index = 3.
      ENDIF.
    ENDMODULE.                 " FETCH_DATA  OUTPUT
    MODULE pass_line OUTPUT.
      READ TABLE lt_zzmm_po_comp INDEX ctrl_0111-current_line.
      MOVE-CORRESPONDING lt_zzmm_po_comp TO ctrl_0111.
    ENDMODULE.                 " PASS_LINE  OUTPUT
    flow logic
    PROCESS BEFORE OUTPUT.
    MODULE status_0111.
    MODULE FETCH_DATA.
    loop at lt_zzmm_po_comp WITH CONTROL ctrl_0111 cursor
    ctrl_0111-current_line.
       module pass_line.
    endloop.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0111.
    loop.
    *module read_data.
    endloop.
    but i cant see my fields in the table control .....i dont know y it is  not coming?can anyone help me with code...

  • How to transfer app data from one mac to another without using syncing of the iphone?

    Right, recently I have tried to change which computer my Iphone syncs with so that my older mac can be sold or disposed of in some profitable form. I have successfully synced all of my music off of one mac onto another via home sharing at which point I connected my phone to my new computer which suggested that the phone needed a software update. Immediately after doing this I realised that my updated Iphone 3GS would no longer sync to my old computer and attempted to sync it just to confirm this- it failed and stated that the iphone could only sync with itunes 10.1 which is a higher spec than that mac can hold. I then feeling doubtful that things would work out tried to carry on as if this problem were absent but I later discovered that I could only transfer the apps that I had synced to my phone to my new mac and all unsynced apps appeared lost because as I stated previously I could not sync with my older mac which contains all of their data. I have consulted the online apple manual for the phone and all it states is the method of transferring purchases in itunes which I tried and is what lead to the copying of my synced apps on to my new mac. What I am asking is is their anyway that I can 'cheat' so to speak at app transfers. I know that somewhere on my old mac the files are stored with the information of the lost apps but I cannot locate them and would not know how to merge them into my newer itunes if I were to copy and paste them to a memory stick (assuming that this is the right method) Other than this is their any other way of downgrading the upgrades of an iphone or somehow tricking itunes into running a higher update than the computer spec? I've tried all I can and this is really annoying- please help!!!!!!

    I'm not entirely sure what you're asking... I'll have to look on my Mac at home to see exactly where they are, but you should just be able to copy all the apps from your old machine to thumb drive or over the network and put them in iTunes on the new one, then sync. Right click on one of the apps in your iTunes library and choose Show in Finder. That will point you to where they are.
    If you're asking how you can do this and maintain data contained 'within' the apps themselves (high scores, game progress, etc), I don't think there's any way you can do that.

  • How to pass the value from one page to another page

    Dear Gaurav
    I have three pages
    1-creation page
    2-search page
    3-creation page
    in first creation page I have column name user write a% and submit to that search for that name.
    it is going to second page (search page)name a% is passed and search that corresponding value,the corresponding values are not there user will call third creation page and enter the details and save and click back to first page the value is not calling passing from third page to first page I submit the button in 3rd page the error is coming like this.
    The requested page contains stale data. This error could have been caused through the use of the browser's navigation buttons (the browser Back button, for example). If the browser's navigation buttons were not used, this error could have been caused by coding mistakes in application code. Please check Supporting the Browser Back Button developer guide - View Object Primary Key Comparison section to review the primary causes of this error and correct the coding mistakes.
    Cause:
    The view object xxcrmleadmgmtAM.xxcrmleadmgmtVO contained no record. The displayed records may have been deleted, or the current record for the view object may not have been properly initialized.
    in first page column name I removed view instance and view attribute the value is passing from third page to first page
    my requirement is the value call from 3 to 1 and user will enter remaining fields in 1st page and save the records.
    Regards
    Mahesh

    Hi Mahesh,
    Use
    OA.jsp?page=/oracle/apps/................&retainAM=Y).
    Thanks
    Jegan

  • How to pass the value from one level to another level

    Example :
    we have secnario for leave process
    initiall the user enters the name in first action the personal number should pick from first action to background RFC CO to pick the Payroll admin from R/3
    i designed the first data input form.... i want to pick the personal number and pass that one to next action in background mode.
    thanks in advance
    sukumar

    Hi,
    If you want to execute the step in background then you can use the callable object of type "Background Execution" or if you want to do any user interaction on that step then you can go for web dynpro callable object. Here is the link for Background Execution callable object.
    http://help.sap.com/saphelp_nw70/helpdata/en/9a/e8934258a5ca6ae10000000a155106/frameset.htm
    Here is also link for Web Dynpro Callable Object
    http://help.sap.com/saphelp_nw70/helpdata/en/de/8976417f2d5558e10000000a1550b0/frameset.htm
    If you have any conficution please let me know.
    Thanks
    Chandan

  • How to pass a variable from one form to another in Form 6i

    I have a user-password screen in one form. And every module has separate form. I need to pass user-name and user-level to all the form.
    I am using Form 6i and Oracle 8.
    Thanx in advance
    Vikas

    DECLARE
         PL_ID PARAMLIST;
    BEGIN
         pl_id := GET_PARAMETER_LIST(:your parameter name);
         IF ID_NULL(PL_ID) THEN
         PL_ID := CREATE_PARAMETER_LIST(:your parameter name);
         ELSE
         DESTROY_PARAMETER_LIST(PL_ID);
         PL_ID := CREATE_PARAMETER_LIST(:your parameter name);
         END IF;
         ADD_PARAMETER(PL_ID,your variable,TEXT_PARAMETER,:PARAMETER.your parameter name);
         call_form ('Your Fmx Here',HIDE,NO_REPLACE,NO_QUERY_ONLY,PL_ID);
    END;
    hope this will help...
    regrds
    Kris

  • How to pass selected records from one table to another ?

    Hi,
    In my view i have designed a table with certain records.  I need to pass only specific records of this table to another table which been designed in another view. Can anybody please give sum idea for this.
    Rgds
    Sudhanshu

    hi,
    Refer the below  code:
    1. I have selected some data from the table.
    2. The selected data is moved to some other internal table.
    3. Internal table is further binded to the node in which data is to be shown.
    data : lo_nd type ref to if_wd_context_node,
      lo_nd1 type ref to if_wd_context_node,
      lt_temp type wdr_context_element_set,
      wa_temp type ref to if_wd_context_element,
      ls_node1 type sflight,
      lt_node1 type STANDARD TABLE OF sflight.
    lo_nd = wd_context->get_child_node('CN_MAIN').  <CN_MAIN is my node>
      CALL METHOD lo_nd->get_selected_elements  <here selected data is moved to lt_temp>
       RECEIVING
           set = lt_temp.
      loop at lt_temp INTO wa_temp.
          CALL METHOD wa_temp->get_static_attributes
          IMPORTING
            static_attributes = ls_node1.       <Selected data in work area.>
        APPEND ls_node1 TO lt_node1.  < Data moved to internal Table>
        CLEAR ls_node1.
      ENDLOOP.
    Finally Internal table is binded to the node required.
      lo_nd1 = wd_context->get_child_node('CN_MAIN2').
      lo_nd1->bind_table( lt_node1 ).
    In your case , map this CN_MAIN2 with the Component Controller and from component controller you can access data in your second view also.
    I hope it helps.
    Thanx.
    Saurav.

  • How to pass a value from one component to another component in webdynpro

    I have created component which consists of alv display and in the alv table  I have created pernr has link and when I click that pernr the second webdypro component opens which I have created . now in the second component I want that pernr value. based on that I want to fetch some data.

    See i have this code for example which calls the browser with concatenated URL:
    CONSTANTS: l_c_url_part1 TYPE string VALUE '?sap-system-login-basic_auth=X&sap-client=',
                         l_c_url_part2 TYPE string VALUE '&sap-language=EN',
                         l_c_url_part3 TYPE string VALUE '&PARAMETER1=',
                         l_c_url_part4 TYPE string VALUE '&PARAMETER2='.
    CALL METHOD cl_wd_utilities=>construct_wd_url
                   EXPORTING
                     application_name = 'ZTEST'
                   IMPORTING
                     out_absolute_url = l_v_url.
                 CONCATENATE l_v_url  l_c_url_part1
                             sy-mandt l_c_url_part2 l_c_url_part3 'VALUE1' l_c_url_part4 'VALUE2' INTO l_v_url.
                 CALL FUNCTION 'CALL_BROWSER'
                     EXPORTING
                       url                           = l_v_url1
                       new_window             = 'X'
                     EXCEPTIONS
                       frontend_not_supported = 1
                       frontend_error         = 2
                       prog_not_found         = 3
                       no_batch               = 4
                       unspecified_error      = 5
                       OTHERS                 = 6.
                   IF sy-subrc <> 0.
                     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
                   ENDIF.

  • How do I transfer bookmarks from one computer to another without using the sync feature?

    I have used the Belkin transfer cable which did not transfer the bookmarks. I can't find them on my C Drive. I'd like to transfer them manually using a thumb drive but can't without locating the file with the bookmarks.
    Firefox and its bookmarks are on the original computer. At this time I can't use the synch function, but must manually transfer the bookmarks. How do I recognize in the files and copy on an external device and then transfer

    Ctrl+Shift+B will open the show all bookmarks window
    and on the top of that it has an import/export menu using this you can export all your bookmarks into a file either as html or as a json
    you can then do the reverse on another PC
    does that help?

  • How do I sync apps from one iPhone to another iPhone using my Macbook Pro

    I am a new Mac user....love the product but having a hard time adapting from Windows   but not giving up
    I'm trying to transfer or sync my apps and music from my iPhone 4 to my iPhone 5 using iTunes.  Is this possible?  I've been trying, but having trouble.

    I would think icloud would be the easiest way to do that.
    Barry

Maybe you are looking for

  • G4 open and save dialogs are totally buggy

    Hey folks -- so, this is a new one to me, on a g4 pinstripe (antique) machine at work: it's across many apps (Illustrator, Photoshop, TextWrangler), but not Apple ones. What happens is this: When accessing a save or open dialog, double-clicking a fol

  • Audio and video not in synch after upgrade

    I have 12.1.1.4. I'm using this new version for the first time tonight, to watch some Walking Dead episodes, and the audio and video drift out of synch. I can bring them back into synch by pausing then replaying, but it doesn't last. I watched some o

  • When I try to save a document in Pages 9.5, a popup states "unable to open (file name)" How can this be fixed?

    This is a very spiratic problem but it seems to occur when I am trying to save something very important. When I type the document, go to file, and click save, a popup comes up. I select the folder and name the file. That popup then disappears. Anothe

  • BPM 10GR3 Workspace exception

    Hi all, When I login to with my userid and password to the BPM workspace and click on Show Filters and then select Processes to the right hand side and then check on Aborted ,Completed and In Process Status boxes and hit Apply filter , I get the foll

  • UP DATE ASKING REMOVE OLD PACKAGE INTELL PROSET WIRELESS WIFI WINDOW 7 .

    .Can not uninstall intell proset wireless give code ERROR 1721BTHEREIS A PROBLEM WITH THIS WINDOWS INSTALLER PACKAGE . A PROGRAM REQUIRED FOR THIS INSTALL TO COMPLETE COULD NOT BE RUN. CONTACT YOUR SUPPORT PESONNEL OR PACKAGE VENDOR. ACTION: UNINSTAL