int
TListViewCtrl::GetSelStrings(tchar** strs, int maxCount, int maxChars, int subitemIndex) const
{
  // This function is for multiselect list views only.
  //
  if (GetStyle() & LVS_SINGLESEL)
    return -1;

  // Get the index of the first selected item.
  //
  int index = static_cast<int>(
    SendMessage(LVM_GETNEXTITEM, TParam1(-1), MkParam2(LVNI_ALL|LVNI_SELECTED, 0)));

  // Loop through selected items.
  //
  int count = 0;
  while (index != -1) {
    GetItemText(index, subitemIndex,
      strs[count], maxChars);
    count++;
    if (count > maxCount)
      break;

    // Get the next selected item.
    //
    index = static_cast<int>(
      SendMessage(LVM_GETNEXTITEM, TParam1(index), MkParam2(LVNI_ALL|LVNI_SELECTED, 0)));
  }
  return count;
}
int
TListViewCtrl::GetSelIndexes(int* indexes, int maxCount) const
{
  if (GetStyle() & LVS_SINGLESEL)
    return -1;

  // Get the index of the first selected item.
  //
  int index = static_cast<int>(
    SendMessage(LVM_GETNEXTITEM, TParam1(-1), MkParam2(LVNI_ALL|LVNI_SELECTED, 0)));

  // Loop while index indicates a selected item.
  //
  int count = 0; // number of selected items found
  while (index != -1 && count < maxCount) 
  {
    indexes[count] = index;
    count++;

    // Get the next selected item.
    //
    index = static_cast<int>(
      SendMessage(LVM_GETNEXTITEM, TParam1(index), MkParam2(LVNI_ALL|LVNI_SELECTED, 0)));
  }
  return count;
}
int
TListViewCtrl::GetSelIndex() const
{
  return (GetStyle() & LVS_SINGLESEL) ?
    static_cast<int>(SendMessage(LVM_GETNEXTITEM, static_cast<TParam1>(-1), MkParam2(LVNI_ALL | LVNI_SELECTED, 0))) :
    -1;
}
bool 
TListViewCtrl::SetItemPosition(int index, const TPoint& pt) 
{
  PRECONDITION(GetHandle());
  if (!IsRepresentable<uint16>(pt.x) || !IsRepresentable<uint16>(pt.y))
    throw TXOwl(_T("TListViewCtrl:SetItemPosition: Argument is outside valid range"));
  return ToBool(SendMessage(LVM_SETITEMPOSITION, TParam1(index), MkParam2(pt.x, pt.y)));
}
TSize
TListViewCtrl::GetApproxRect(int x, int y, int count) const
{
  PRECONDITION(GetHandle());
  if (x != -1 && !IsRepresentable<uint16>(x) || y != -1 && !IsRepresentable<uint16>(y))
    throw TXOwl(_T("TListViewCtrl:GetApproxRect: Argument is outside valid range"));
  TResult r = SendMessage(LVM_APPROXIMATEVIEWRECT, TParam1(count), MkParam2(x, y));
  return TPoint(static_cast<DWORD>(r));
}
//
/// Toggle the "checked" state when the mouse is clicked in the checkbox.
//
void
TCheckList::EvLButtonDown(uint modKeys, const TPoint& point)
{
  TListBox::EvLButtonDown(modKeys, point);
  TCheckListItem* item = GetItem(GetCaretIndex());
  if(item && item->IsEnabled() && point.x < CheckList_BoxWidth){
    item->Toggle();
    Update();
    // Inform parent of change with BN_CLICKED message 
    if(GetParentO())
      GetParentO()->HandleMessage(WM_COMMAND, 
                                  MkParam2(Attr.Id, BN_CLICKED), 
                                  TParam2(GetHandle())); 
  }
}
bool
TListViewCtrl::SetColumnWidth(int index, int width)
{
  PRECONDITION(GetHandle());
  return ToBool(SendMessage(LVM_SETCOLUMNWIDTH, TParam1(index), MkParam2(width, 0)));
}
bool
TListViewCtrl::Scroll(int dx, int dy)
{
  PRECONDITION(GetHandle());
  return ToBool(SendMessage(LVM_SCROLL, 0, MkParam2(dx, dy)));
}
int
TListViewCtrl::GetNextItem(int index, TNextItemCode code) const
{
  PRECONDITION(GetHandle());
  return static_cast<int>(SendMessage(LVM_GETNEXTITEM, TParam1(index), MkParam2(code, 0)));
}
Beispiel #10
0
//
/// If the caption bar is not enabled, returns esPartial. Otherwise, determines if
/// the user released the button outside or inside a menu, and returns esComplete.
//
TEventStatus
TTinyCaption::DoNCLButtonDown(uint hitTest, const TPoint& screenPt)
{
    if (!TCEnabled)
        return esPartial;

    TWindowDC wdc(*this);
    switch (hitTest) {
    case HTSYSMENU:
        DownHit = HTSYSMENU;
        if (CloseBox) {
            IsPressed = true;
            SetCapture();
            TRect rect(GetSysBoxRect());
            PaintCloseBox(wdc, rect, IsPressed);
        }
        else {
            TRect sysBoxRect = GetSysBoxRect().InflatedBy(-1,-1);
            sysBoxRect.right += 1;

            wdc.PatBlt(sysBoxRect, PATINVERT);

            // Display sys menu on button down
            // Need to lock sys menu until user clicks outside

            // Set flag to indicate we're expecting a sys command, & then send
            // message to popup sys menu
            //
            WaitingForSysCmd = true;
            SendMessage(WM_SYSCOMMAND, SC_MOUSEMENU|HTSYSMENU,
                        MkParam2(screenPt.x,screenPt.y));

            // If we didn't execute a command, user released btn outside of menu
            // If it was released in sys menu box, then redisplay menu as if it
            // were brought up with a keystroke
            //
            if (WaitingForSysCmd) {
                uint hitTest;
                TPoint pt;
                GetCursorPos(pt);
                DoNCHitTest(pt, hitTest);
                if (hitTest == HTSYSMENU)
                    SendMessage(WM_SYSCOMMAND, SC_KEYMENU|HTSYSMENU);
            }
            if (GetHandle())
                wdc.PatBlt(sysBoxRect, PATINVERT);
        }
        return esComplete;

    case HTMINBUTTON: {
        DownHit = HTMINBUTTON;
        IsPressed = true;
        SetCapture();
        TRect rect(GetMinBoxRect());
        PaintMinBox(wdc, rect, IsPressed);
        return esComplete;
    }

    case HTMAXBUTTON: {
        DownHit = HTMAXBUTTON;
        IsPressed = true;
        SetCapture();
        TRect rect(GetMaxBoxRect());
        PaintMaxBox(wdc, rect, IsPressed);
        return esComplete;
    }
    }
    DownHit = HTNOWHERE;
    return esPartial;
}
Beispiel #11
0
//
// Sets the amount of space around each tab's icon and label in a tab 
// control. 
//
void
TTabControl::SetPadding(const TSize& size)
{
    SendMessage(TCM_SETPADDING, 0, MkParam2(size.cx, size.cy));
}
Beispiel #12
0
//
// Sets the size (width/height) of tabs in a fixed-width or owner-draw
// tab control. Returns a TSize object containing the old width and height.
//
TSize
TTabControl::SetItemSize(const TSize& size)
{
    return TSize(SendMessage(TCM_SETITEMSIZE, 0, MkParam2(size.cx, size.cy)));
}