[fpc-pascal]More strangeness...

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri Aug 29 09:07:11 CEST 2003

On Thu, 28 Aug 2003, L D Blake wrote:

> In reply to your message of August 28, 2003
> > On Thu, 28 Aug 2003, L D Blake wrote:
> >> Why is it that if I compile an FPC program with range checking turned on,
> >> opening any HTML file in ie immediately causes "Error 201" from my FPC program?
> > Ahem.
> > A litlle bit more information may be in order here ?
> > What kind of program is this ? What units does it use ? What function
> > does it perform ? Is this a GUI program or a console app ?
> Okey dokey...  I gave quite a bit of information in my other message about
> these problems... XP1800/win2k/sp4/256mbram/tnt64 video, all stable on other
> software... so, to add the new info..
> It's a Gui app. No OOP, just plain pascal. Basically it's media player with
> some special functions, such as a text editor for transcribing lyrics. From
> FPC, it uses only mmsystem and windows, and of course it has it's own private
> units. I'm compiling with delphi and gui support enabled at the top of each
> unit and in the main program.
> To restate what's going on... If I compile without range checking it will play
> songs perfectly, and the text editor behaves normally so long as I don't open
> any other window over it or let it fall into the screen saver. If it goes into
> the background I sometimes (often, but not every time) lose the title bars
> from the windows and re-draws occur at random locations on the screen making
> the program appear to break in to pieces, this happens with any window or
> dialog the program opens, including those built into windows. If I guess where
> the buttons should be I can click them, even if I can't see them and the
> images scattered on the screen have the menu context numbers on them instead
> of the button text. Sometimes it will also grab bits of other windows and
> displace them as well. If I compile it with range checking it errors off (code
> 201 at random addresses) every time I try to open a html file in IE. The IE
> window will not open until I exit the application. It also errors off
> unexpectedly (but not very often) giving Error 201 at seemingly random
> addresses while running in background.   All though this, it will continue
> playing music very nicely...

Do you catch the 'focus lost' event ? Do you have any assembler ?
Windows expects some registers to be saved.

> Also, keep in mind that so long as it's in the foreqround, none of these errors
> occur. I've tortured it horribly and it runs error free so long as it never
> gets covered by anything else.
> I've been all over my own code with a fine tooth comb. I've tried declaring my
> variables with win-api names (eg. dword instead of longword) and I've tried
> using the native pascal type declarations and this seems to have little effect
> on it. I've tried re-doing the windows dispatcher and the 4 winproc routines
> (one for each main window) in several different ways, but this does not change
> the errors. I've also tried commenting out blocks of code to see if the error
> vanishes along with the function and, unless I render it unworkable, the
> errors persist.

Are the winproc routines declared as stdcall ?

> The FP IDE will not point me to a source code line when the errors occur
> because, weirdly enough, I don't get the errors in debug mode.
> I'm slowly becoming convinced that it's an error someplace in FP, perhaps
> in the "Windows" unit ... perhaps a type declaration that doesn't match the
> C equivalent or some other more fundimental problem. I've experimented with
> lots of differing combinations of compiler switches (in fpc.cfg) and tried
> several different compiler directives in the source code itself. All to no
> avail. Depending on the use of range checking, I either get a scrambled
> display or randomly occuring "Error 201" popups sometimes listing 20 or more
> errors.

Did you go over all the WinAPI calls that you use ?
I know this is a tedious job, but it is one which needs to be done in
such cases. We've had other cases where the declaration was wrong.

> So far, I've been resisting tampering with the FPC distribution, because
> frankly I would have no idea where to start looking for these kinds of
> problems in all that source code.

The fact that huge projects as Lazarus work fine, make me believe that
the error is win32 specific, and this points to the Windows unit or some
special routines uses in mmsystem or whatever.

> I was a professional programmer some years back, worked with TP extensively
> and liked it just fine on the DOS platform, but FP and windows has been a real
> hassle.  I've never yet had a problem I can't find and fix... until now.
> Needless to say, I'm rather frustrated and very near scrapping FP...

This is understandable. Did you try compiling using Delphi  ?
If you want, you can send me the sources in private, and I will give it
a try with Delphi.


More information about the fpc-pascal mailing list