Ver Mensaje Individual
  #4  
Antiguo 24-01-2007
Roberto Angulo Roberto Angulo is offline
Registrado
 
Registrado: ago 2005
Posts: 6
Reputación: 0
Roberto Angulo Va por buen camino
DepjiTwain: Accediendo a sus propiedades

Esta funcion es parte de DelphiTwain

Código Delphi [-]
 
{Sets an one value capability}
function TTwainSource.SetOneValue(Capability: TW_UINT16;
  ItemType: TW_UINT16; Value: Pointer): TCapabilityRet;
var
  Data: HGLOBAL;
  OneV: pTW_ONEVALUE;
  ItemSize,ItemSize2: Integer;
begin
  {Allocate enough memory for the TW_ONEVALUE and obtain pointer}
  ItemSize := TWTypeSize(ItemType);
  //npeter: TW_ONEVALUE minimal size !!!
  //I think to meet the specifications the
  //Item's size must be at least sizeof(TW_UINT32)!
  //when I did it, some mistic errors on some drivers went gone
  if ItemSizethen ItemSize2:=TWTypeSize(TWTY_UINT32) else ItemSize2:=ItemSize;
  Data := GlobalAlloc(GHND, sizeof(OneV^.ItemType) + ItemSize2);
  OneV := GlobalLock(Data);
  {Fill value}
  OneV^.ItemType := ItemType;
  CopyMemory(@OneV^.Item, Value, ItemSize);
  GlobalUnlock(Data);
  {Call method to set}
  Result := SetCapabilityRec(Capability, TWON_ONEVALUE, Data);
  {Unload memory}
  GlobalFree(Data);
end;
Responder Con Cita