如题

解决方案 »

  1.   

    #define ID_MYBUTTON 4000
    m_button->Create("mybutton",dwstyle,rect,this,ID_MYBUTTON);
    m_button->ShowWindow(1);
      

  2.   

    所谓ID实际上就是一个常数。
    所以你可以用alien_taiji(笑了) 的方法,只不过#define ID_MYBUTTON 4000要在资源文件中定义,你如果嫌麻烦,可以:
    m_button->Create("mybutton",dwstyle,rect,this,4000);
    你用的时候,就可以:
    GetDlgItem(4000)->
      

  3.   

    good,就是那样。还是费点事的写法好一点,以后改动方便。请问是用sdk编写的吗?如果是好像没法指定id
        hwndHou = CreateABtn(hwnd,&rcRect,"Hou");//创建一个按钮
        r.left = 100;
        r.top = 100;
        r.bottom = 150;
        r.right = 200;
        hwndStatic = CreateWindow(//创建一个static
                 "STATIC",
                 "Hello,World!",
                 WS_CHILD | WS_VISIBLE | WS_TABSTOP | TRANSPARENT,
                 r.left,
                 r.top,
                 r.right - r.left,
                 r.bottom - r.top,
                 hwnd,
                 NULL,
                 NULL,
                 NULL);
      

  4.   

    #define ID_MYBUTTON 4000
    m_button->Create("mybutton",dwstyle,rect,this,ID_MYBUTTON);
    m_button->ShowWindow(1);
      

  5.   

    难道你们没看我的题意就解答了?
    我说过了是用CreateWindow创建的button,难道真没人知道了?
      

  6.   

    你跟蹤一下就會發現,button.create 中的ID最終是這么用的 cs.hMenu = nIDorHMenu;(這個值就是你的button里的 nID)
    HWND hWnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszClass,
    cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
    cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);   如果你直接用createwindow的話,可以把hMenu設為你指定的ID.   (未經測試。想法而已) Good Luck
      

  7.   

    HWND hWnd = CreateWindow(lpszClass,
                             lpszName,
                             dwStyle,
                             x,y,cx,cy,
                             hWndParent,
                             (HMENU)ID,
                             hInstance,
                             NULL);
    本人都是这么用的:)