码迷,mamicode.com
首页 > 其他好文 > 详细

copy_data

时间:2016-03-22 09:00:48      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case  WM_CREATE:
            CreateWindow(L"button", L"发送",
            WS_CHILD | WS_VISIBLE, 10, 10, 100, 30, 
            hWnd, (HMENU)10001, hInst, NULL);
            break;
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // 分析菜单选择: 
        switch (wmId)
        {
        case IDM_ABOUT:
            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        case 10001://注意--------------------------------------------
        {
            //构造一个COPYDATASTRUCT的结构体,可以发送任意数据
            COPYDATASTRUCT cds = { 0x123,
                10, L"15PB" };
            //得到目标窗口的句柄
            HWND           hDesWnd = ::FindWindow(
                NULL, L"06 COPY_DATA接收端");
            //向目标窗口发送WM_COPYDATA消息
            SendMessage(hDesWnd, WM_COPYDATA,
                (WPARAM)hWnd, (LPARAM)&cds);
        }
        //注意-----------------------------------------------------------
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        // TODO:  在此添加任意绘图代码...
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

 

copy_data

标签:

原文地址:http://www.cnblogs.com/Alyoyojie/p/5304598.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!