Ejemplo n.º 1
0
	bool VListWin::Command( int id, int subId, Win* win, void* data )
	{
		if ( id == CMD_SCROLL_INFO )
		{
			switch ( subId )
			{
				case SCMD_SCROLL_LINE_UP:
					MoveFirst( first - 1 );
					break;

				case SCMD_SCROLL_LINE_DOWN:
					MoveFirst( first + 1 );
					break;

				case SCMD_SCROLL_PAGE_UP:
					MoveFirst( first - pageSize );
					break;

				case SCMD_SCROLL_PAGE_DOWN:
					MoveFirst( first + pageSize );
					break;

				case SCMD_SCROLL_LINE_LEFT:
					MoveXOffset( xOffset - 10 );
					break;

				case SCMD_SCROLL_LINE_RIGHT:
					MoveXOffset( xOffset + 10 );
					break;

				case SCMD_SCROLL_PAGE_LEFT:
					MoveXOffset( xOffset - listRect.Width() );
					break;

				case SCMD_SCROLL_PAGE_RIGHT:
					MoveXOffset( xOffset + listRect.Width() );
					break;

				case SCMD_SCROLL_TRACK:
					( win == &vScroll ) ?
					MoveFirst( ( ( int* )data )[0] ) :
					MoveXOffset( ( ( int* )data )[0] );
					break;
			}

			return true;
		}

		return Win::Command( id, subId, win, data );
	}
Ejemplo n.º 2
0
int HeapFile::Open(char* fpath){

    f.Open(1, fpath);
    MoveFirst();
    return 1;

}
Ejemplo n.º 3
0
void CBPacket::WriteRaw(void* buf, long size)
{
	Write(buf, size);
	m_size = (short) size;
	m_ptr = 0;
	MoveFirst();
}
void CLryEDBQryDoc::OnCursorMove(UINT nID)
{
	try
	{
		switch(nID)
		{
		case ID_RECORD_FIRST:		
			MoveFirst();
			break;
		case ID_RECORD_PREV:
			MovePrevious();
			break;
		case ID_RECORD_NEXT:
			MoveNext();
			break;
		case ID_RECORD_LAST:
			MoveLast();
			break;
		default: break;
		} 
	}
	catch(_com_error &e)
	{
		dump_com_error(e);
	}
	UpdateAllViews(	NULL,1);
}
Ejemplo n.º 5
0
BOOL CSourceODBC::SetPosition(long position)
{
    if ( m_lRecordCount == 0 ) return FALSE;
    if ( position == m_lCurrentRecord ) return TRUE;
    MoveFirst();
    for( long i=0; i < position; i++ )
    {
        MoveNext();
    }
    return TRUE;
}
Ejemplo n.º 6
0
void CSourceODBC::ReQuestion()
{
    Requery();
    m_database.recordcount = 0;
    if ( m_lRecordCount > 0 )
    {
        MoveFirst();
        while( !IsEOF() )
        {
            m_database.recordcount++;
            MoveNext();
        }
    }
}
Ejemplo n.º 7
0
int main ()
{
	DictHndl testHash;
	ListHndl testLookUp;

	testHash = NewDictionary (10);

	InsertKey (testHash, "cat", 123);

	InsertKey (testHash, "dog", 234);

	InsertKey (testHash, "fog", 2345);

	InsertKey (testHash, "fog", 245);

	testLookUp = LookUp (testHash, "fog");

	MoveFirst (testLookUp);
	while (!OffEnd (testLookUp))
	{
		int temp = *(int*) GetCurrent (testLookUp);
		printf ("%d ", temp);
		MoveNext (testLookUp);
	}

	printf ("\n");

	if (IsIn (testHash, "dog"))
	{
		printf ("dog is in the table\n");
	}

	DeleteKey (testHash, "cat");

	DeleteKey (testHash, "dog");

	if (IsIn (testHash, "dog"))
	{
		printf ("dog is still in the table\n");
	}

	testLookUp = LookUp (testHash, "dog");

	FreeDictionary (testHash);

	return (0);
}
Ejemplo n.º 8
0
 bool Loop()
 {
    size_t row = 0;
    if (!(IsBOF() && IsEOF())) for (MoveFirst(); !IsEOF(); MoveNext(), row++)
    {
       //TRACE(_T("row %3d\n"), row);
       NewRecord();
       for (int i = 0; i < GetFieldCount(); i++)
       {
          COleVariant var;
    	   GetFieldValue(i, var);
          SaveField(i, var);
       }
       SaveRecord();
    }
    return true;
 }
Ejemplo n.º 9
0
	bool VListWin::EventMouse( cevent_mouse* pEvent )
	{
		if ( !IsEnabled() ) { return false; }

		int n = ( pEvent->Point().y - listRect.top ) / this->itemHeight + first;

		if ( pEvent->Type() == EV_MOUSE_PRESS )
		{
			if ( pEvent->Button() == MB_X1 )
			{
				int n = pageSize / 3;

				if ( n < 1 ) { n = 1; }

				MoveFirst( first - n );
				return true;
			}

			if ( pEvent->Button() == MB_X2 )
			{
				int n = pageSize / 3;

				if ( n < 1 ) { n = 1; }

				MoveFirst( first + n );
				return true;
			}
		}

		if ( pEvent->Type() == EV_MOUSE_PRESS && pEvent->Button() == MB_L && listRect.In( pEvent->Point() ) )
		{
			captureDelta = 0;
			MoveCurrent( n );
			this->SetCapture( &captureSD );
			this->SetTimer( 0, 100 );
			return true;
		}

		if ( pEvent->Type() == EV_MOUSE_DOUBLE )
		{
			MoveCurrent( n );
			Command( CMD_ITEM_CLICK, GetCurrent(), this, 0 );
			return true;
		}

		if ( pEvent->Type() == EV_MOUSE_MOVE && IsCaptured() )
		{
			if ( pEvent->Point().y >= listRect.top && pEvent->Point().y <= listRect.bottom )
			{
				MoveCurrent( n );
				captureDelta = 0;
			}
			else
			{
				captureDelta = ( pEvent->Point().y > listRect.bottom ) ? 1 : ( pEvent->Point().y < listRect.top ) ? -1 : 0;
			}

			return true;
		}

		if ( pEvent->Type() == EV_MOUSE_RELEASE && pEvent->Button() == MB_L )
		{
			this->ReleaseCapture( &captureSD );
			this->DelTimer( 0 );
			
			if ( selectType == SINGLE_SELECT )
			{
				MoveCurrent( n );
				Command( CMD_ITEM_CLICK, GetCurrent(), this, 0 );
			}

			return true;
		}

		return Win::EventMouse( pEvent );
	}
Ejemplo n.º 10
0
	void VListWin::EventSize( cevent_size* pEvent )
	{
		this->CalcScroll();
		MoveFirst( first );
	}
Ejemplo n.º 11
0
   dbf_data_type GetFieldType(int field, const CDaoFieldInfo& info, size_t* length)
   {
      dbf_data_type type;

      switch (info.m_nType)
      {
         case dbDate:
         {
            bool date = false;
            bool time = false;
            if (!(IsBOF() && IsEOF())) for (MoveFirst(); !IsEOF(); MoveNext())
            {
               COleVariant var;
      	      GetFieldValue(field, var);
               if (var.vt == VT_DATE)
               {
                  SYSTEMTIME st;
                  COleDateTime dt(var.date);
                  if (dt.GetAsSystemTime(st))
                  {
                     date = date || (st.wYear != 1899);
                     time = time || st.wHour || st.wMinute || st.wSecond;
                  }
               }
            }
            if (date && time)
            {
               type = DBF_DATA_TYPE_DATETIME;
               *length = DBF_LEN_DATETIME;
            }
            else if (time)
            {
               type = DBF_DATA_TYPE_TIME;
               *length = DBF_LEN_TIME;
            }
            else
            {
               type = DBF_DATA_TYPE_DATE;
               *length = DBF_LEN_DATE;
            }
            break;
         }
         case dbDecimal:
         case dbFloat:
         case dbSingle:
         case dbDouble:
            type = DBF_DATA_TYPE_FLOAT;
            break;
         case dbText:
         case dbMemo:
         case dbChar:
            type = DBF_DATA_TYPE_CHAR;
            if (0 == *length)
            {
               *length = 80;
            }
            break;
         case dbInteger:
         case dbLong:
         case dbByte:
         case dbNumeric:
         case dbBigInt:
            type = DBF_DATA_TYPE_INTEGER;
            // workaround: it may be a running number, check if highest one fits.
            // Increase field size if needed
            if (!(IsBOF() && IsEOF()))
            {
               MoveLast();
               COleVariant var;
      	      GetFieldValue(field, var);
               
               int n = 0;
               switch (var.vt)
               {
                  case VT_I2: 
                     n = var.iVal; break;
                  case VT_I4: 
                     n = var.lVal; break;
               }
               if (n)
               {
                  char temp[80];
                  size_t len = _snprintf(temp, _countof(temp), "%d", n);

                  if (len > *length)
                  {
                     *length = len;
                  }
               }
            }
            break;
         case dbBoolean:
            type = DBF_DATA_TYPE_BOOLEAN;
            *length = DBF_LEN_BOOLEAN;
            break;
         case dbCurrency:
         case dbBinary:
         case dbLongBinary:
         case dbGUID:
         case dbVarBinary:
         case dbTime:
         case dbTimeStamp:
         default:
            type = DBF_DATA_TYPE_UNKNOWN;
            break;
      }
      return type;
   }
	CGameTokenIterator( CGameTokenSystem *pGTS ) :m_pGTS(pGTS)
	{
		CRY_ASSERT(pGTS);
		m_nRefCount=0;
		MoveFirst();
	}
Ejemplo n.º 13
0
BOOL CGuiRecordSet::FindFirst(LPCTSTR Criteria)
{
	MoveFirst();
   	return Find(Criteria,0,adSearchForward,"");
}
Ejemplo n.º 14
0
int main ()
{
	int customers, purchases, inputTest, i, j, k, s;
	ListHndl* booksPurchased;
	char inputFileName[1024];
	FILE* dataFile;

	fprintf (stdout, "Please input the name of a properly formatted data file\n");
	fgets (inputFileName, 1024, stdin);

	for(j = 0; j < 1024; j++)
	{
		if (inputFileName[j] == '\n')
		{
			inputFileName[j] = '\0';
			break;
		}
	}

	dataFile = fopen (inputFileName, "r");

	if (dataFile == NULL)
	{
		fprintf (stdout, "Invalid filename\n");
		return 1;
	}

	inputTest = fscanf (dataFile, "%d", &customers);

	if (inputTest != 1)
	{
		fprintf (stderr, "Improperly formatted file\n");
		fclose (dataFile);
		return 1;
	}

	if (customers < 1)
	{
		fprintf (stderr, "Invalid input\n");
		fprintf (stderr, "Number of customers cannot be less than 1\n");
		fclose (dataFile);
		return 1;
	}

	booksPurchased = (ListHndl*)malloc ( (sizeof (ListHndl)) * customers );

	inputTest = fscanf (dataFile, "%d", &purchases);

	if (inputTest != 1)
	{
		fprintf (stderr, "Improperly formatted file\n");
		fclose (dataFile);
		free (booksPurchased);
		return 1;
	}

	if (purchases < 0)
	{
		fprintf (stderr, "Invalid input\n");
		fprintf (stderr, "Number of purchases cannot be negative\n");
		fclose (dataFile);
		free (booksPurchased);
		return 1;
	}

	for (i = 0; i < customers; i++)
	{
		booksPurchased[i] = NewList ();
	}

	for (k = 0; k < purchases; k++)
	{
		int customerNumber;
		long bookNumber;
		inputTest = fscanf (dataFile, "%d%ld", &customerNumber, &bookNumber);

		if (inputTest != 2)
		{
			fprintf (stderr, "Improperly formatted file\n");
			fclose (dataFile);
			for (s = 0; s < customers; s++)
			{
				FreeList (booksPurchased[s]);
				
			}
			free (booksPurchased);
			return 1;
		}

		if (customerNumber < 1 || customerNumber > customers)
		{
			fprintf (stderr, "Invalid customer number\n");
		}
		else
		{
			if (IsEmpty (booksPurchased[customerNumber - 1]))
			{
				InsertAtFront (booksPurchased[customerNumber - 1], bookNumber);
			}
			else
			{
				InsertionSort (booksPurchased[customerNumber - 1], bookNumber);
			}
		}

		
	}

	fprintf (stdout, "customer#   books purchased\n");

	for (s = 0; s < customers; s++)
	{
		fprintf (stdout, "%d  ", (s + 1));

		if(!IsEmpty (booksPurchased[s]))
		{
			MoveFirst (booksPurchased[s]);
		}

		while (!OffEnd(booksPurchased[s]))
		{
			fprintf (stdout, " ");
			PrintCurrent (stdout, booksPurchased[s]);
			MoveNext (booksPurchased[s]);
		}

		fprintf (stdout, "\n");

		FreeList (booksPurchased[s]);
	}

	fclose (dataFile);
	free (booksPurchased);
	return 0;
}