Пример #1
0
  void click(boolean dropDown) {
    long /*int*/ hwnd = parent.handle;
    if (OS.GetKeyState(OS.VK_LBUTTON) < 0) return;
    int index = (int) /*64*/ OS.SendMessage(hwnd, OS.TB_COMMANDTOINDEX, id, 0);
    RECT rect = new RECT();
    OS.SendMessage(hwnd, OS.TB_GETITEMRECT, index, rect);
    int hotIndex = (int) /*64*/ OS.SendMessage(hwnd, OS.TB_GETHOTITEM, 0, 0);

    /*
     * In order to emulate all the processing that
     * happens when a mnemonic key is pressed, fake
     * a mouse press and release.  This will ensure
     * that radio and pull down items are handled
     * properly.
     */
    int y = rect.top + (rect.bottom - rect.top) / 2;
    long /*int*/ lParam = OS.MAKELPARAM(dropDown ? rect.right - 1 : rect.left, y);
    parent.ignoreMouse = true;
    OS.SendMessage(hwnd, OS.WM_LBUTTONDOWN, 0, lParam);
    OS.SendMessage(hwnd, OS.WM_LBUTTONUP, 0, lParam);
    parent.ignoreMouse = false;

    if (hotIndex != -1) {
      OS.SendMessage(hwnd, OS.TB_SETHOTITEM, hotIndex, 0);
    }
  }