TPrintPreview: Required compiler options?

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

TPrintPreview: Required compiler options?

Postby sbussinger » August 2nd, 2004, 5:29 pm

In playing with TPrintPreview, I've gotten lots of range check exceptions while doing things like scrolling with the mouse wheel. I noticed that the code has no explicit compiler directives in it so as an experiment, I added {$Q-R-} to the top and recompiled and all of the errors I was seeing went away (since I disabled the checks) and I saw no issues caused by this.

I always have my default compiler directives set to their most rigorous settings and I'm wondering if TPrintPreview was only intended to be compiled with range and overflow checking off?

If that's the case, then perhaps you could add those directives to the source? If not, there are some problems with the mouse wheel handling that need to be addressed.

Thanks, be seeing you.
sbussinger
Active Member
Active Member
 
Posts: 10
Joined: July 2nd, 2004, 7:55 pm

Postby aspence » August 7th, 2004, 3:52 am

I encountered this as well. I made the following additions to the source code:

Code: Select all
{$IFOPT R+}{$DEFINE RCHECKSAREON}{$ENDIF}
{$R-}
procedure TPrintPreview.WMMouseWheel(var Message: TMessage);
...
end;
{$IFDEF RCHECKSAREON}{$R+}{$UNDEF RCHECKSAREON}{$ENDIF}


and

Code: Select all
{$IFOPT R+}{$DEFINE RCHECKSAREON}{$ENDIF}
{$R-}
procedure TThumbnailPreview.WMMouseWheel(var Message: TMessage);
..
end;
{$IFDEF RCHECKSAREON}{$R+}{$UNDEF RCHECKSAREON}{$ENDIF}


With these changes, you can set range checking in your compiler options and you won't get range errors from those routines. I found this method of switch setting in the newsgroups somewhere from a Borland rep. The idea is to turn off range checking for a code section and only turn it back on if it was on already. I've never been able to find clear documentation that says this is necessary but it's something I've often wondered about. In anycase, turning a switch on or off in code should only affect the unit in which it is contained (for those interested).

I also found the following code in my main form useful for using the scrolling. The preview window needs focus before it will capture wheel movements so I added these events:

Code: Select all
procedure TMyForm.PrintPreviewMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  ActiveControl := PrintPreview;
end;


This way, you don't have to click the preview window to get the scrolling to work, just move the mouse cursor over it.
- Arnold B. Spence
aspence
Active Member
Active Member
 
Posts: 13
Joined: July 11th, 2004, 8:50 am
Location: Wolfville, N.S. Canada


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 2 guests

cron