Sending info when clicking a mouse button to notepad

Discussion in 'MFC' started by Andres, Aug 26, 2008.

  1. Andres

    Andres New Member

    Joined:
    Jul 22, 2008
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Can someone please help me with this code... I am trying to send info to notepad when I click a mouse button.

    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    static HANDLE hFile = INVALID_HANDLE_VALUE;

    switch(msg)
    {
    case WM_CREATE:
    hFile = CreateFile(...);
    return 0;

    case WM_DESTROY:
    CloseHandle(hFile);
    PostQuitMessage(0);
    return 0;

    case WM_LBUTTONDOWN:
    WriteFile(...);
    return 0;

    case WM_RBUTTONDOWN:
    WriteFile(...);
    return 0;

    default:
    return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    }
     
  2. oogabooga

    oogabooga New Member

    Joined:
    Jan 9, 2008
    Messages:
    115
    Likes Received:
    11
    Trophy Points:
    0
    Are you really trying to send the data to "notepad"?
    Or are you trying to write the data to a text file that could subsequently be read in notepad?
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Moved to MFC/Win32 forum for better responses.
     
  4. Andres

    Andres New Member

    Joined:
    Jul 22, 2008
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Yes you are right, I am trying to write data to a text file that could subsequently be read in notepad.
     
  5. oogabooga

    oogabooga New Member

    Joined:
    Jan 9, 2008
    Messages:
    115
    Likes Received:
    11
    Trophy Points:
    0
    Then you need to look up those functions on MSDN.
    CreateFile
    WriteFile
    They're a little complicated, but just remember that you mostly want the defaults.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice