 |
MESSAGE BOARD
|
| View previous topic :: View next topic |
| Author |
Message |
sbussinger Member
Joined: 02 Jul 2004 Posts: 8
|
Posted: 02/08/04 17:29 Post subject: TPrintPreview: Required compiler options? |
|
|
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. |
|
| Back to top |
|
 |
aspence Member
Joined: 11 Jul 2004 Posts: 13 Location: Wolfville, N.S. Canada
|
Posted: 07/08/04 03:52 Post subject: |
|
|
I encountered this as well. I made the following additions to the source code:
| Code: |
{$IFOPT R+}{$DEFINE RCHECKSAREON}{$ENDIF}
{$R-}
procedure TPrintPreview.WMMouseWheel(var Message: TMessage);
...
end;
{$IFDEF RCHECKSAREON}{$R+}{$UNDEF RCHECKSAREON}{$ENDIF}
|
and
| Code: |
{$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: |
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 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group
|