Einzelnen Beitrag anzeigen

cRayZo

Registriert seit: 30. Jul 2007
156 Beiträge
 
Delphi 6 Personal
 
#12

Re: Entfernung zwischen zwei Pixelkoordinaten

  Alt 2. Nov 2007, 16:06
nicht viel aber ich kann sie dir ja mal vollständig mit Funktionen kopieren:

[code=delphi]function _VolumeControl(Mixer: hMixerObj;
var Control: TMixerControl): MMResult;
var
Line : TMixerLine;
Controls : TMixerLineControls;
begin
ZeroMemory(@Line, SizeOf(Line));
Line.cbStruct := SizeOf(Line);
Line.dwComponentType := MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
Result := mixerGetLineInfo(Mixer,
@Line,
MIXER_GETLINEINFOF_COMPONENTTYPE);
if Result = MMSYSERR_NOERROR then begin
ZeroMemory(@Controls, SizeOf(Controls));
Controls.cbStruct := SizeOf(Controls);
Controls.dwLineID := Line.dwLineID;
Controls.cControls := 1;
Controls.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
Controls.cbmxctrl := SizeOf(Control);
Controls.pamxctrl := @Control;
Result := mixerGetLineControls(Mixer,
@Controls,
MIXER_GETLINECONTROLSF_ONEBYTYPE);
end;
end;

procedure SetMasterVolume(Mixer: hMixerObj; Value: Word);
var
MasterVolume : TMixerControl;
Details : TMixerControlDetails;
UnsignedDetails : TMixerControlDetailsUnsigned;
Code : MMResult;
begin
Code := _VolumeControl(Mixer, MasterVolume);
if Code = MMSYSERR_NOERROR then begin
with Details do begin
cbStruct := SizeOf(Details);
dwControlID := MasterVolume.dwControlID;
cChannels := 1; // set all channels
cMultipleItems := 0;
cbDetails := SizeOf(UnsignedDetails);
paDetails := @UnsignedDetails;
end;
UnsignedDetails.dwValue := Value;
Code := mixerSetControlDetails(Mixer,
@Details,
MIXER_SETCONTROLDETAILSF_VALUE);
end;
if Code <> MMSYSERR_NOERROR then
raise Exception.CreateFmt('SetMasterVolume failure, '+
'multimedia system error #%d',
Code:
);
end;
/////////////////////////////////////////////////function end////////////////////////

procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
    Shape1.Left:= X-4 {1};
    Shape1.Top := Y-4 {2};

end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  leftx,topx:                        real;
  shape1top, shape1left,entfernung:  integer;
begin
    shape1Top:=shape1.Top;shape1left:=shape1.Left;
if Edit1.Text='' then Edit1.Text:='500';  try Timer1.Interval:=strtoint(edit1.Text) except end;

//PC001
     topx:=abs(PC001.Top-shape1Top);
     leftx:=abs(PC001.left-shape1left);
  entfernung:=trunc(250*sqrt(leftx*leftx+topx*topx));
                if entfernung>65000 
                then entfernung:=65000;
  SetMasterVolume(MasterVolumeControl,65000-entfernung);
  lbPC001.Caption:=floattostr(65000-entfernung);
vll geht die Lösung des Problems so leichter
lg cRayZo
  Mit Zitat antworten Zitat