🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #136

Re: Strange NT problems with D1 and TImage.Canvas Methods PLEASE HELP!!

#136
From: Dmitry Streblechenko
Date: Fri, 06 Feb 1998 00:00
134 lines
5695 bytes
Rob, I had a similar problem: you cause window
updates from within your paint handler (ImageOverlay.Refresh ?)
Win95 handles such situations better than NT.

Dmitry

Rob Wilson wrote:
> 
> Hi,
> 
> Unfortunately I was not too sure which newsgroup would be best for
> this problem, so I have cross-posted to many.
> 
> I appologise if I have 'over' posted.
> 
> I have been using Delphi 1 to ensure 16 bit windows compatibility and
> have been developing in windows 95 environment with NO problems at
> all.
> 
> Today I have moved to an NT workstation and copied my project over and
> use Delphi 1 still as the target is still 16 bit.... BUT one of my
> forms contiuously updates when it is run on an NT but NOT on 3.11 (and
> not on WIN95 at home)....
> 
> I have a snippet of my code, which you can really ignore everything
> except the area shown in ******'s.
> 
> The ListBox1 is used for debugging, and on Win3.11 just displays
> 
> "Form Update Number 1" and stops, ready for user input
> 
> On the NT, this is repeated non-stop and doesn't allow the user to
> have any input.
> 
> When I remove the bit of code in the ****'s, it stops refreshing, but
> its the heart of the draw operation..... Strangely enough, the listbox
> says its been called twice..... Why?  Is this the start of my problem?
> 
> DOES ANYONE KNOW WHATS WRONG!!!???
> 
> Please help, any ideas would be appreciated.
> 
> Code follows:-
> 
> procedure TFormOverlay.FormPaint(Sender: TObject);
> var
>    colorloop : integer;
>    gap : integer;
>    x,y : integer;
>    MaxOverlayX,MaxOverlayY : integer;
>    StartX,StartY : integer;
> begin
>      inc(FormUpdateCount);
>      ListBox1.ItemIndex:=ListBox1.Items.Add('Form update number
> '+inttostr(FormUpdateCount));
>      ListBox1.Refresh;
> 
>      {Is there a better time/place for this?}
>      OverlayNumberOfColours:=NumberOfColours;
> 
>      {Do I need to copy palette from bitmap 1 ?}
>      gap:=FormOverlay.ImageColorPalette.Width div NumberOfColours;
> 
>      ImageColorPalette.Canvas.Brush.Style:=BSSolid;
>      for colorloop:=0 to NumberOfColours-1 do
>      begin
> 
> ImageColorPalette.Canvas.Pen.Color:=ColourInfo[ColorLoop].ColourRef;
> 
> ImageColorPalette.Canvas.Brush.Color:=ColourInfo[ColorLoop].ColourRef;
> 
>           {
> 
> ImageColorPalette.Canvas.FillRect(rect(colorloop*gap,0,(colorloop*gap)+gap,imagecolorpalette.height));
>           ImageOverlay.Refresh;
> 
>           {Palette information copied to overlay when drawing, to
> ensure always
>           up-to-date without calling a function}
>           OverlayPalette[colorloop]:=ColourInfo[ColorLoop].ColourRef;
>      end;
> 
>      MaxOverlayX:=ImageOverlay.Width  div (CurrentZoom.Progress*3);
>      MaxOverlayY:=ImageOverlay.Height div (CurrentZoom.Progress*3);
> 
>      startx :=OverlayScrollBarX.Position;
>      starty :=OverlayScrollBarY.Position;
> 
>      for y:=0 to MaxOverlayY do
>      begin
>           for x:=0 to MaxOverlayX do
>           begin
>                if (startx+x > formmain.image1.width) or (starty+y >
> formmain.image1.height) then
>                begin
>                     {Debug.Items.Add('Image 1
> width='+inttostr(image1.width)+height'}
>                end
>                else
>                begin
> 
> ImageOverlay.Canvas.Pen.Color:=FormMain.Image1.Canvas.Pixels[startx+x,starty+y]
> AND $00FFFFFF;
> 
> ImageOverlay.Canvas.Brush.Color:=FormMain.Image1.Canvas.Pixels[startx+x,starty+y]
> AND $00FFFFFF;
> 
>                    {****************************}
>                    {****************************}
>                    {****************************}
>                    {THIS BIT CAUSES DRAW EVENT TO HAPPEN
> AGAIN,AGAIN,AGAIN!!!
>                    BUT ONLY ON NT!!!?  NOT 3.11 DELPHI 1 ???
> HEEEEELLLLPPPP!}
> 
>                    ImageOverlay.Canvas.Rectangle
> 
> (x*(CurrentZoom.Progress*3),y*(CurrentZoom.Progress*3),
> 
> (x+1)*(CurrentZoom.Progress*3),(y+1)*(CurrentZoom.Progress*3));
> 
>                    {****************************}
>                    {****************************}
>                    {****************************}
> 
>                end;
>           end;
>           if (y mod 5 = 0) then
>           begin
>                ImageOverlay.Refresh;
>           end;
>      end;
> end;
Technical Details
Message-ID: <34DBF743.419DDC4C@asu.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34d99764.164479739@linux.compd.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb0ea,4361e6fcbfe9a987
X-Google-Attributes: gidfb0ea,public
X-Google-Thread: 10baee,4361e6fcbfe9a987
X-Google-Attributes: gid10baee,public
X-Google-Thread: fd817,4361e6fcbfe9a987
X-Google-Attributes: gidfd817,public
X-Google-Thread: 10a296,4361e6fcbfe9a987
X-Google-Attributes: gid10a296,public
X-Google-Thread: f973d,4361e6fcbfe9a987
X-Google-Attributes: gidf973d,public
X-Google-Thread: 109d99,4361e6fcbfe9a987
X-Google-Attributes: gid109d99,public
X-Google-Thread: f973b,4361e6fcbfe9a987
X-Google-Attributes: gidf973b,public
From: Dmitry Streblechenko <dmitrys@asu.edu>
Subject: Re: Strange NT problems with D1 and TImage.Canvas Methods PLEASE HELP!!
Date: 1998/02/06
Message-ID: <34DBF743.419DDC4C@asu.edu>
X-Deja-AN: 322842480
Content-Transfer-Encoding: 7bit
References: <34d99764.164479739@linux.compd.com>
To: Rob Wilson <rw@linux.compd.com>
Content-Type: text/plain; charset=us-ascii
Organization: None
Mime-Version: 1.0
Newsgroups: comp.lang.pascal.delphi.misc,comp.lang.pascal.delphi.components.usage,comp.lang.pascal.delphi.components.misc,borland.public.delphi.vcl.components.using,borland.public.delphi.graphics,alt.lang.delphi,alt.comp.lang.borland-delphi