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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to pass data from MFC to Win 32 Console through windows messaging [modified]

How to pass data from MFC to Win 32 Console through windows messaging [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++
2 Posts 1 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.
  • D Offline
    D Offline
    Darrel Q Pham
    wrote on last edited by
    #1

    Hi everyone, I have been trying to send data through windows messaging from a dialog to a windows service, both of which I have created. I can send data from the service to the dialog fine, I just let OnCopyData handle it. My windows service, with my limited knowledge, doesn't have anything like that, I think. I created a thread in my windows service to look for messages. I know I can't cast the datastructure to a LPARAM or cast back the LPARAM to my datastructure, the code below just shows as an example what I want to do. If there is a way, please let me know. I look forward to be educated by you.

    void myMessageThread( VOID *)
    {

    MSG l\_msgMessage;	
        //Create hidden window for the dialog to capture the hwnd
    hWndMain = ::CreateWindow( \_T("STATIC"), \_T("Sample"), 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);	
    CString c\_CopyDataMessage;
    l\_msgMessage.hwnd = hWndMain;
    //Data structure I want to receive
    PCOPYDATASTRUCT l\_newdata; 
        //Loop forever
    while( GetMessage(&l\_msgMessage, hWndMain, 0, 0) !=100	){
    	if( l\_msgMessage.message == WM\_myCopyData ){
    		l\_newdata = (PCOPYDATASTRUCT)l\_msgMessage.lParam;		
    	}
    	TranslateMessage( &l\_msgMessage );
    	DispatchMessage( &l\_msgMessage );
    }
    

    }

    modified on Monday, November 17, 2008 9:30 PM

    D 1 Reply Last reply
    0
    • D Darrel Q Pham

      Hi everyone, I have been trying to send data through windows messaging from a dialog to a windows service, both of which I have created. I can send data from the service to the dialog fine, I just let OnCopyData handle it. My windows service, with my limited knowledge, doesn't have anything like that, I think. I created a thread in my windows service to look for messages. I know I can't cast the datastructure to a LPARAM or cast back the LPARAM to my datastructure, the code below just shows as an example what I want to do. If there is a way, please let me know. I look forward to be educated by you.

      void myMessageThread( VOID *)
      {

      MSG l\_msgMessage;	
          //Create hidden window for the dialog to capture the hwnd
      hWndMain = ::CreateWindow( \_T("STATIC"), \_T("Sample"), 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);	
      CString c\_CopyDataMessage;
      l\_msgMessage.hwnd = hWndMain;
      //Data structure I want to receive
      PCOPYDATASTRUCT l\_newdata; 
          //Loop forever
      while( GetMessage(&l\_msgMessage, hWndMain, 0, 0) !=100	){
      	if( l\_msgMessage.message == WM\_myCopyData ){
      		l\_newdata = (PCOPYDATASTRUCT)l\_msgMessage.lParam;		
      	}
      	TranslateMessage( &l\_msgMessage );
      	DispatchMessage( &l\_msgMessage );
      }
      

      }

      modified on Monday, November 17, 2008 9:30 PM

      D Offline
      D Offline
      Darrel Q Pham
      wrote on last edited by
      #2

      *bump* I know how to use shared memory and named pipes, but I want to know how to do it with Windows Messaging and for a Win 32 console app. Any help would be appreciated, even if its an answer telling me its impossible.

      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