Exemplo n.º 1
0
LOCAL LPLISTBOXDATA DragOK(HWND hWindow)
/***********************************************************************/
{
// get the listbox data pointer, if we don't have one, get out
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return(NULL);

if (!lpData->fEnableMove)
	return(NULL);

// the number of items in the list box
lpData->iCount = ListBox_GetCount(hWindow);         
if (lpData->iCount == 0 ) // don't do anything to and empty list box
   return(NULL);

// see if this is a multiple selection listbox
DWORD dwStyle = GetWindowLong (hWindow, GWL_STYLE);
if (dwStyle & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL))
	{
	// see how many items are selected we only work if one is selected
	int iSelCount = ListBox_GetSelCount(hWindow);
	if (iSelCount != 1)
		return(NULL);
	ListBox_GetSelItems(hWindow, 1, &lpData->iOldPos);
	}
else
	// the current item
	lpData->iOldPos = ListBox_GetCurSel(hWindow);
return(lpData);
}
Exemplo n.º 2
0
void ListBox_MoveAllStrings(HWND hwndListBox, int iAmount)
{
    int iCount = ListBox_GetSelCount(hwndListBox), i;
    LPINT lpiItems = (LPINT)Mem_Alloc(iCount * sizeof(INT));

    SetWindowRedraw(hwndListBox, FALSE);

    ListBox_GetSelItems(hwndListBox, iCount, lpiItems);

    if (iAmount < 0)
    {
        for (i = 0; i < iCount; i++)
        {
            int nIndex = ListBox_MoveString(hwndListBox, lpiItems[i], iAmount, TRUE);
            ASSERT(nIndex != LB_ERR);
        }
    }
    else
    {
        for (i = (iCount - 1); i > -1; i--)
        {
            int nIndex = ListBox_MoveString(hwndListBox, lpiItems[i], iAmount, TRUE);
            ASSERT(nIndex != LB_ERR);
        }
    }

    // Reselect all the items moved
    for (i = 0; i < iCount; i++)
        ListBox_SetSel(hwndListBox, TRUE, lpiItems[i] + iAmount);

    SetWindowRedraw(hwndListBox, TRUE);
    RedrawWindow(hwndListBox, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

    Mem_Free(lpiItems);
}
Exemplo n.º 3
0
/* This function updates the out-basket status
 */
void FASTCALL UpdateOutBasketStatus( void )
{
   if( hwndOutBasket )
      {
      BOOL fIsEditable;
      BOOL fHasItem;
      BOOL fCanDelete;
      HWND hwndList;
      int nSelCount;

      hwndList = GetDlgItem( hwndOutBasket, IDD_LIST );
      fIsEditable = FALSE;
      fHasItem = ( ListBox_GetCount( hwndList ) > 0 );
      fCanDelete = FALSE;
      if( ( nSelCount = ListBox_GetSelCount( hwndList ) ) > 0 )
         {
         OBINFO obinfo;
         LPOB lpob;
         int nSel;

         ListBox_GetSelItems( hwndList, 1, &nSel );
         lpob = (LPOB)ListBox_GetItemData( hwndList, nSel );
         Amob_GetObInfo( lpob, &obinfo );
         SetWindowText( GetDlgItem( hwndOutBasket, IDD_HOLD ), ( obinfo.obHdr.wFlags & OBF_HOLD ) ? GS(IDS_STR282) : GS(IDS_STR281) );
         SetWindowText( GetDlgItem( hwndOutBasket, IDD_KEEP ), ( obinfo.obHdr.wFlags & OBF_KEEP ) ? GS(IDS_STR318) : GS(IDS_STR319) );
         fIsEditable = !fInitiatingBlink && Amob_IsEditable( obinfo.obHdr.clsid ) && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE );
         fCanDelete = !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE );
         }
      EnableControl( hwndOutBasket, IDOK, fIsEditable );
      EnableControl( hwndOutBasket, IDD_LIST, fHasItem );
      EnableControl( hwndOutBasket, IDD_DELETE, fCanDelete );
      EnableControl( hwndOutBasket, IDD_HOLD, fHasItem && fCanDelete );
      EnableControl( hwndOutBasket, IDD_KEEP, fHasItem && fCanDelete );
      }
}
Exemplo n.º 4
0
/////////////////////////////////////////////////////////////////////////
//Function:    RemoveItem
//Description: remove a item from selected object list
/////////////////////////////////////////////////////////////////////////
void RemoveItem(HWND hDlg)
	{
	 long nObjects ;
	 long Index ;

	 EnableWindow(GetDlgItem(hDlg, removeB), FALSE) ;
	 EnableWindow(GetDlgItem(hDlg, editB), FALSE) ;
	 /*nObjects = SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETSELCOUNT, 0, 0L) ;
	 if (nObjects!=0 &&(0!=SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETCOUNT, 0, 0)))
	 {
		while(SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETSELITEMS, 1, (long) &Index) !=0)
	 	{
			SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_DELETESTRING, (WORD)Index, 0) ;
		}
		SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_SETCARETINDEX, 0, 0) ;
     }*/
	 nObjects = ListBox_GetSelCount (GetDlgItem(hDlg, IDD_FIELDSLIST)) ;
	 if(nObjects!=0&&(0!=ListBox_GetCount(GetDlgItem(hDlg, IDD_FIELDSLIST))))
		{
		while(ListBox_GetSelItems (GetDlgItem(hDlg,IDD_FIELDSLIST),1, &Index)!=0)
			{
			ListBox_DeleteString (GetDlgItem(hDlg, IDD_FIELDSLIST), Index) ;
			}
		ListBox_SetCaretIndex (GetDlgItem(hDlg, IDD_FIELDSLIST),0) ;
		}
	 SetFocus(GetDlgItem (hDlg,IDD_FIELDSLIST)) ;
	}
Exemplo n.º 5
0
/////////////////////////////////////////////////////////////////////////
//Function:    AddItem
//Description: Add a item to Selected object list
/////////////////////////////////////////////////////////////////////////
void AddItem (HWND hDlg)
	{
	 int  		  nObjects ;
	 char   *lpszString ;
	 int       *SelectedIndexes ;
	 DWORD 	  	objectIndex ;
	 OBJECTID 	theObj ;
	 int		i ;

	 //nObjects = (int) SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETSELCOUNT, 0, 0L) ;
	 nObjects = ListBox_GetSelCount (GetDlgItem(hDlg, IDD_OBJECTSLIST)) ;
	 if (nObjects == 0) return ;

	 SelectedIndexes = new int[nObjects] ;
	 //SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETSELITEMS, (WPARAM)nObjects, (long)SelectedIndexes) ;
	 ListBox_GetSelItems (GetDlgItem (hDlg, IDD_OBJECTSLIST), nObjects, SelectedIndexes) ;
	 lpszString = new char[256] ;
	 for (i = 0; i < nObjects; i++)
		{
		 //SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETTEXT, SelectedIndexes[i], (long) lpszString) ;
		 //theObj =(OBJECTID)SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETITEMDATA, SelectedIndexes[i], 0) ;
		 //objectIndex = (DWORD)SendDlgItemMessage(hDlg, IDD_FIELDSLIST, LB_INSERTSTRING, -1, (long)lpszString) ;
		 //SendDlgItemMessage(hDlg, IDD_FIELDSLIST, LB_SETITEMDATA, (WPARAM)objectIndex, (long)theObj) ;
		 ListBox_GetText (GetDlgItem (hDlg, IDD_FIELDSLIST),SelectedIndexes[i], lpszString) ;
		 theObj = (OBJECTID)ListBox_GetItemData (GetDlgItem (hDlg, IDD_FIELDSLIST),SelectedIndexes[i]) ;
		 objectIndex = ListBox_InsertString (GetDlgItem (hDlg, IDD_FIELDSLIST), -1, lpszString) ;
		 ListBox_SetItemData (GetDlgItem(hDlg, IDD_FIELDSLIST), objectIndex, theObj) ;
		}
	 delete(SelectedIndexes) ;
	 delete(lpszString) ;
	 return ;
	}
Exemplo n.º 6
0
vector<int> ListBox::GetSelectedItemsIndex()
{
    int count = ListBox_GetSelCount(ThisWindow);
    vector<int> res(count);
    if (count != 0)
        ListBox_GetSelItems(ThisWindow, count, &res[0]);
    return res;
}
Exemplo n.º 7
0
int ListBox_GetFirstSel(HWND hwndListBox)
{
    int iIndex;

    ListBox_GetSelItems(hwndListBox, 1, &iIndex);

    return (iIndex);
}
Exemplo n.º 8
0
/////////////////////////////////////////////////////////////////////////
//Function:    EditItem
//Description: Edit a item in Selected Object list
/////////////////////////////////////////////////////////////////////////
void EditItem(HWND hDlg)
	{
	 long nObjects ;
	 int  Index ;
	 OBJECTID theObject ;

	 //nObjects = SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETSELCOUNT, 0, 0L) ;
	 nObjects = ListBox_GetSelCount (GetDlgItem(hDlg, IDD_FIELDSLIST)) ;
	 if (nObjects != 1) return ;

	 //SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETSELITEMS, 1, (long)&Index) ;
	 //theObject =(OBJECTID) SendDlgItemMessage(hDlg, IDD_FIELDSLIST, LB_GETITEMDATA, Index, 0L) ;
	 ListBox_GetSelItems (GetDlgItem(hDlg, IDD_FIELDSLIST),1, &Index) ;
	 theObject = (OBJECTID) ListBox_GetItemData (GetDlgItem(hDlg, IDD_FIELDSLIST), Index) ;
	 AObjEdit(theObject) ;
	 return ;
	}
Exemplo n.º 9
0
BOOL ListBox_DeleteAllStrings(HWND hwndListBox)
{
    BOOL bSuccess = FALSE;
    int iCount = ListBox_GetSelCount(hwndListBox);
    LPINT lpiItems = (LPINT)_alloca(iCount * sizeof(INT));
    ListBox_GetSelItems(hwndListBox, iCount, lpiItems);

    SetWindowRedraw(hwndListBox, FALSE);


    for ( ; iCount > 0; iCount--)
    {
        if (ListBox_DeleteString(hwndListBox, lpiItems[iCount - 1]) != LB_ERR)
            bSuccess = TRUE;
    }

    SetWindowRedraw(hwndListBox, TRUE);

    return (bSuccess);
}
Exemplo n.º 10
0
// Return number of selections and an array of selected integers
int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
    aSelections.Empty();

    if ( HasMultipleSelection() )
    {
        int countSel = ListBox_GetSelCount(GetHwnd());
        if ( countSel == LB_ERR )
        {
            wxLogDebug(wxT("ListBox_GetSelCount failed"));
        }
        else if ( countSel != 0 )
        {
            int *selections = new int[countSel];

            if ( ListBox_GetSelItems(GetHwnd(),
                                     countSel, selections) == LB_ERR )
            {
                wxLogDebug(wxT("ListBox_GetSelItems failed"));
                countSel = -1;
            }
            else
            {
                aSelections.Alloc(countSel);
                for ( int n = 0; n < countSel; n++ )
                    aSelections.Add(selections[n]);
            }

            delete [] selections;
        }

        return countSel;
    }
    else  // single-selection listbox
    {
        if (ListBox_GetCurSel(GetHwnd()) > -1)
            aSelections.Add(ListBox_GetCurSel(GetHwnd()));

        return aSelections.Count();
    }
}
Exemplo n.º 11
0
/* This function intercepts messages for the out-basket list box window
 * so that we can handle the right mouse button.
 */
LRESULT EXPORT FAR PASCAL OutBaskListProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
   switch( msg )
      {
      case WM_ERASEBKGND: {
         RECT rc;

         GetClientRect( hwnd, &rc );
         FillRect( (HDC)wParam, &rc, hbrOutBaskWnd );
         return( TRUE );
         }

      case WM_CONTEXTMENU: /*!!SM!!*/
      case WM_RBUTTONDOWN:
         {
         POINT pt;
         LPOB lpob;
         HWND hwndOpen;
         HMENU hPopupMenu;
         int index;
         AEPOPUP aep;

         /* Make sure this window is active and select the item
          * at the cursor.
          */
         if( hwndActive != GetParent( hwnd ) )
            SendMessage( hwndMDIClient, WM_MDIACTIVATE, (WPARAM)hwndOutBasket, 0L );

         /* Select the item under the cursor only if nothing is
          * currently selected.
          */
         index = ItemFromPoint( hwnd, (short)LOWORD(lParam), (short)HIWORD(lParam) );
         if( ListBox_GetSel( hwnd, index ) == 0 )
            {
            CallWindowProc( lpProcListCtl, hwnd, WM_LBUTTONDOWN, wParam, lParam );
            CallWindowProc( lpProcListCtl, hwnd, WM_LBUTTONUP, wParam, lParam );
            }

         /* Get the out-basket menu.
          */
         hPopupMenu = GetSubMenu( hPopupMenus, IPOP_OBASKWINDOW );
         hwndOpen = GetDlgItem( GetParent( hwnd ), IDOK );
         MenuEnable( hPopupMenu, IDOK, IsWindowEnabled( hwndOpen ) );

         /* If we have any selected items, use the attributes
          * of the first item to determine the menu items.
          */
         if( ListBox_GetSelCount( hwnd ) > 0 )
            {
            OBINFO obinfo;

            ListBox_GetSelItems( hwnd, 1, &index );
            lpob = (LPOB)ListBox_GetItemData( hwnd, index );
            Amob_GetObInfo( lpob, &obinfo );
            if( TestF(obinfo.obHdr.wFlags, OBF_HOLD) )
               MenuString( hPopupMenu, IDD_HOLD, GS(IDS_STR275) );
            else
               MenuString( hPopupMenu, IDD_HOLD, GS(IDS_STR277) );
            if( TestF(obinfo.obHdr.wFlags, OBF_KEEP) )
               MenuString( hPopupMenu, IDD_KEEP, GS(IDS_STR440) );
            else
               MenuString( hPopupMenu, IDD_KEEP, GS(IDS_STR439) );
            MenuEnable( hPopupMenu, IDOK, !fInitiatingBlink && Amob_IsEditable( obinfo.obHdr.clsid ) && !TestF(obinfo.obHdr.wFlags, OBF_PENDING) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            MenuEnable( hPopupMenu, IDD_DELETE, !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            MenuEnable( hPopupMenu, IDD_KEEP, !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            MenuEnable( hPopupMenu, IDD_HOLD, !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            }
         else
            {
            MenuEnable( hPopupMenu, IDOK, FALSE );
            MenuEnable( hPopupMenu, IDD_KEEP, FALSE );
            MenuEnable( hPopupMenu, IDD_HOLD, FALSE );
            MenuEnable( hPopupMenu, IDD_DELETE, FALSE );
            }
            /* Call the AE_POPUP event.
             */
         aep.wType = WIN_OUTBASK;
         aep.pFolder = NULL;
         aep.pSelectedText = NULL;
         aep.cchSelectedText = 0;
         aep.hMenu = hPopupMenu;
         aep.nInsertPos = 2;
         Amuser_CallRegistered( AE_POPUP, (LPARAM)(LPSTR)&aep, 0L );

         GetCursorPos( &pt );
         TrackPopupMenu( hPopupMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndFrame, NULL );
         return( 0 );
         }

      case WM_KEYDOWN:
         /* Trap the Delete and Shift+Delete key in the outbasket
          * list box to handle the Delete command.
          */
         if( wParam == VK_DELETE ) 
            {
            PostDlgCommand( GetParent( hwnd ), IDD_DELETE, 0 );
            return( 0 );
            }

         /* Trap the Pause and Shift+Pause key in the outbasket
          * list box to handle the Hold command.
          */
         if( wParam == VK_PAUSE )
            {
            PostDlgCommand( GetParent( hwnd ), IDD_HOLD, 1 );
            return( 0 );
            }
         break;
      }
   return( CallWindowProc( lpProcListCtl, hwnd, msg, wParam, lParam ) );
}