Skip to content

Commit

Permalink
Uses strings instead of PChar and replaced Integer by LPARAM in SendM…
Browse files Browse the repository at this point in the history
…essage.
  • Loading branch information
romankassebaum committed Dec 2, 2023
1 parent a4d4938 commit 7023af0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
28 changes: 14 additions & 14 deletions source/AdFView.pas
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ implementation
HasBeenCreated := True;

if csDesigning in ComponentState then
SendMessage(Handle, apw_ViewSetDesignMode, 0, Integer(StrPCopy(TempZ, Name)));
SendMessage(Handle, apw_ViewSetDesignMode, 0, LPARAM(StrPCopy(TempZ, Name)));

SendMessage(Handle, apw_ViewSetFG, 0, FGColor);
SendMessage(Handle, apw_ViewSetBG, 0, BGColor);

if not (csDesigning in ComponentState) then begin
if FScaling then begin
FillScaleSettings(Settings);
SendMessage(Handle, apw_ViewSetScale, 0, Integer(@Settings));
SendMessage(Handle, apw_ViewSetScale, 0, LPARAM(@Settings));
end;
if FWhitespaceCompression then
SendMessage(Handle, apw_ViewSetWhitespace, FWhitespaceFrom, FWhitespaceTo);
Expand All @@ -352,7 +352,7 @@ implementation
SendMessage(Handle, apw_ViewSetAutoScale, Opt, 0);

if not (csDesigning in ComponentState) then
CheckException(Self, SendMessage(Handle, apw_ViewSetFile, 0, Integer(StrPCopy(TempZ, FFileName))));
CheckException(Self, SendMessage(Handle, apw_ViewSetFile, 0, LPARAM(StrPCopy(TempZ, FFileName))));

SendMessage(Handle, apw_ViewsetLoadWholeFax, Ord(FLoadWholeFax), 0);
SendMessage(Handle, apw_ViewSetBusyCursor, Screen.Cursors[BusyCursor], 0);
Expand Down Expand Up @@ -384,7 +384,7 @@ implementation
inherited SetName(NewName);

if (csDesigning in ComponentState) and HasBeenCreated then
SendMessage(Handle, apw_ViewSetDesignMode, 0, Integer(StrPCopy(TempZ, NewName)));
SendMessage(Handle, apw_ViewSetDesignMode, 0, LPARAM(StrPCopy(TempZ, NewName)));
end;

procedure TApdCustomFaxViewer.SetBorderStyle(const NewStyle : TBorderStyle);
Expand Down Expand Up @@ -433,7 +433,7 @@ implementation
else
FillScaleSettings(Settings);

CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, Integer(@Settings)));
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LPARAM(@Settings)));
end;
end;

Expand All @@ -450,7 +450,7 @@ implementation
if FScaling then begin
FillScaleSettings(Settings);
Settings.HMult := NewHorizMult;
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, Integer(@Settings)));
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LPARAM(@Settings)));
end;
end;

Expand All @@ -467,7 +467,7 @@ implementation
if FScaling then begin
FillScaleSettings(Settings);
Settings.HDiv := NewHorizDiv;
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, Integer(@Settings)));
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LPARAM(@Settings)));
end;
end;

Expand All @@ -484,7 +484,7 @@ implementation
if FScaling then begin
FillScaleSettings(Settings);
Settings.VMult := NewVertMult;
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, Integer(@Settings)));
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LPARAM(@Settings)));
end;
end;

Expand All @@ -501,7 +501,7 @@ implementation
if FScaling then begin
FillScaleSettings(Settings);
Settings.VDiv := NewVertDiv;
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, Integer(@Settings)));
CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LPARAM(@Settings)));
end;
end;

Expand Down Expand Up @@ -593,7 +593,7 @@ implementation
FFileName := NewFileName;

if not (csDesigning in ComponentState) then begin
CheckException(Self, SendMessage(Handle, apw_ViewSetFile, 0, Integer(StrPCopy(FNameZ, FFileName))));
CheckException(Self, SendMessage(Handle, apw_ViewSetFile, 0, LPARAM(StrPCopy(FNameZ, FFileName))));

FRotation := vr0;
FHorizMult := 1;
Expand Down Expand Up @@ -640,7 +640,7 @@ implementation
if (PageNum = 0) or (PageNum > Integer(NumPages)) then
CheckException(Self, ecBadArgument);

H := SendMessage(Handle, apw_ViewGetBitmap, PageNum, Integer(@P));
H := SendMessage(Handle, apw_ViewGetBitmap, PageNum, LPARAM(@P));
if (H = 0) then
Result := nil
else begin
Expand All @@ -664,7 +664,7 @@ implementation
R : TRect;

begin
SendMessage(Handle, apw_ViewGetPageDim, 0, Integer(@R));
SendMessage(Handle, apw_ViewGetPageDim, 0, LPARAM(@R));
Result := Succ(R.Right);
end;

Expand All @@ -673,7 +673,7 @@ implementation
R : TRect;

begin
SendMessage(Handle, apw_ViewGetPageDim, 0, Integer(@R));
SendMessage(Handle, apw_ViewGetPageDim, 0, LPARAM(@R));
Result := Succ(R.Bottom);
end;

Expand Down Expand Up @@ -805,7 +805,7 @@ implementation
procedure TApdCustomFaxViewer.SelectRegion(const R : TRect);
{-Select the image bounded by R}
begin
SendMessage(Handle, apw_ViewSelect, 0, Integer(@R));
SendMessage(Handle, apw_ViewSelect, 0, LPARAM(@R));
end;

procedure TApdCustomFaxViewer.SelectImage;
Expand Down
24 changes: 9 additions & 15 deletions source/AdFaxCvt.pas
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ procedure TApdCustomFaxConverter.ChangeDefPrinter(UseFax: Boolean);
const
DefPrn : string = '';
var
Device, Name, Port : array[0..255] of char;
Device, Name, Port : string;
DevMode : THandle;
N, Last : integer;
begin
Expand All @@ -981,15 +981,12 @@ procedure TApdCustomFaxConverter.ChangeDefPrinter(UseFax: Boolean);
{ get the required info }
Printer.GetPrinter(Device, Name, Port, DevMode);
{ concatenate the strings }
StrCat(Device, ',');
StrCat(Device, Name);
StrCat(Device, ',');
StrCat(Device, Port);
Device := Device + ';' + Name + ',' + Port;
{ write the string to the ini/registry }
WriteProfileString( 'Windows', 'Device', Device );
StrCopy(Device, 'Windows' );
WriteProfileString('Windows', 'Device', PChar(Device));
Device := 'Windows';
{ tell everyone that we've changed the default }
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, Integer(@Device));
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, LPARAM(@Device));
{ make the TPrinter use the device capabilities of the new default}
SetPrinter(Device, Name, Port, 0);
end;
Expand All @@ -1000,15 +997,12 @@ procedure TApdCustomFaxConverter.ChangeDefPrinter(UseFax: Boolean);
Printer.PrinterIndex := N;
Printer.GetPrinter(Device, Name, Port, DevMode);
{ concatenate the strings }
StrCat(Device, ',');
StrCat(Device, Name);
StrCat(Device, ',');
StrCat(Device, Port);
Device := Device + ','+ Name + ',' + Port;
{ write the string to the ini/registry }
WriteProfileString( 'Windows', 'Device', Device );
StrCopy(Device, 'Windows' );
WriteProfileString('Windows', 'Device', PChar(Device));
Device := 'Windows';
{ tell everyone that we've changed the default }
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, Integer(@Device));
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, LPARAM(@Device));
end;
end;
end;
Expand Down
2 changes: 1 addition & 1 deletion source/AwFaxCvt.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ function acConvertStatus(Cvt: PAbsFaxCvt; StatFlags: Word): Integer;

with Cvt^ do begin
if (StatusWnd <> 0) then begin
if (SendMessage(StatusWnd, apw_FaxCvtStatus, StatFlags, Integer(Cvt)) <> 0) then
if (SendMessage(StatusWnd, apw_FaxCvtStatus, StatFlags, LPARAM(Cvt)) <> 0) then
acConvertStatus:= ecConvertAbort;
end else if (@StatusFunc <> nil) then
if StatusFunc(Cvt, StatFlags, BytesRead, BytesToRead) then acConvertStatus:= ecConvertAbort;
Expand Down

0 comments on commit 7023af0

Please sign in to comment.