Solved

Canvas resize problem

Posted on 2007-03-30
6
276 Views
Last Modified: 2010-04-05
Dear Experts,

I still have a resize problem with my telnet-example, its making me grazy.
I have put 2 pictures on my site to demonstrate what happens when I resize
my form. In de first picture you see the rows and colums when I select the text
with the mouse. And when I resize the form smaller you see the rows and columns
dissapear (picture2). It has to be like picture 2 no mather how i resize the form you
may never see the rows and columns.

Who can help me?

This is the address of my site:  http://members.home.nl/peterkiers/
Underneath the Under Construction bar you see a floppy disk
click on it to download my example, and under the floppy disk
you see 2 pictures.

Greetings,

Peter  
0
Comment
Question by:peterkiers
  • 3
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
TName earned 250 total points
ID: 18826107
Hi, Peter, the raster-like design of the project doesn't really allow for smooth resizing (especially of a selection).
Anyway, here is a little workaround, try this (and TEST IT!):

Replace your DispCell procedure with this one:



procedure TMainForm.DispCell(x, y: integer; PaintBlanks: boolean);
var
  xpos, ypos: integer;
  r:TRect;                         //Added
begin
  xpos := (x * FontWidthPix) - FontWidthPix;
  ypos := (y * FontHeightPix) - FontHeightPix;
  with Canvas do
  begin
    Brush.Style := bsSolid;
    Brush.Color := ColorBlack;
    if (ScrBuf[y, x].data = Char(cdDefault)) or
      (ScrBuf[y, x].data = Char(cdFieldAttr)) then
    begin
      if PaintBlanks then
      begin
        Font.Style := [];
        TextOut(xpos, ypos, ' ');
      end;
    end
    else
    begin
      if (Byte(ScrBuf[y, x].attrib) and caNonDisp) <> caNonDisp then
      begin
        Pen.Mode := pmCopy;
        Font.Color := ColorMapI2W(ScrBuf[y, x].color);
        if ScrBuf[y, x].hilite = Char(chDefault) then
          Font.Style := []
        else if ScrBuf[y, x].hilite = Char(chReverse) then
        begin
          Font.Style := [];
          Pen.Mode := pmXor;
          Brush.Color := ColorMapI2W(ScrBuf[y, x].color);
          Font.Color := ColorBlack;
        end
        else if ScrBuf[y, x].hilite = Char(chUnderLine) then
          Font.Style := [fsUnderline]
        else if ScrBuf[y, x].hilite = Char(chBlink) then
          Font.Style := [fsStrikeout]
        else
          Font.Style := [];
        if (Byte(ScrBuf[y, x].attrib) and caIntens) = caIntens then
          Font.Style := Font.Style + [fsBold];

         r := Rect(xpos,ypos,xpos+(FontWidthPix ),ypos+(FontHeightPix ));     //Added
         canvas.FillRect(r);                                                                         //Added

         TextOut(xpos, ypos, ScrBuf[y, x].data);
      end
      else
        TextOut(xpos, ypos, ' ');
    end;
  end;
end;
(*--------------------------------------*)

0
 
LVL 1

Author Comment

by:peterkiers
ID: 18828045
Hi TName,

I have tested your example and it works fine, only another
fault appears. The CURSOR is vanished. When i choose menu-
item Fill buffer to fill the canvas with characters and numbers
and then when I click on a certain cell the cursor will not be dis-
played. And it's their but not showing. Because when I choose
the cursor to blink, by choosing menu-item Timer on/off, the cur-
sor appears again. But the cursor has to be always on the canvas
blinking or not blinking.

But the resizing works great.

Peter
0
 
LVL 28

Expert Comment

by:TName
ID: 18828108
Glad you've tested it ;o)
I'll have a look at it this evening, if no one else does it.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Assisted Solution

by:dinilud
dinilud earned 250 total points
ID: 18828407
procedure TMainForm.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Bounding then
  begin
    Bounding := False;
    CurX := X;
    CurY := Y;
  end;
  DrawCursor(CsrCol, CsrRow)
end;
0
 
LVL 28

Expert Comment

by:TName
ID: 18828663
That should indeed work. Then you can delete
DrawCursor(CsrCol, CsrRow);
from the FormMouseDown() procedure...

0
 
LVL 1

Author Comment

by:peterkiers
ID: 18828946
Hi, I have tested it and it works great.

Thank to you all.

Point will be devided.

greetings,

Peter Kiers
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question