Results 1 to 3 of 3

Thread: My code is adding pixels :(

  1. #1
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default My code is adding pixels :(

    Strange title, but it's the most accurate thing I could think of.

    I'm making a small program that can convert an image to different things. (Formats, and hex.) I've run into a problem with displaying the image, however.

    SCAR Code:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      PicH, PicW: Integer;
    begin
      OpenPictureDialog1.Execute;
      Form2.Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
      Form2.Caption := ExtractFileName(OpenPictureDialog1.FileName);
      PicH := Form2.Image1.Picture.Height;
      PicW := Form2.Image1.Picture.Width;
      Form2.Image1.Height := PicH;
      Form2.Image1.Width := PicW;
      Form2.ClientHeight := PicH;
      Form2.ClientWidth := PicW;
      Form2.HorzScrollBar.Visible := False;
      Form2.VertScrollBar.Visible := False;
      Form2.Visible := True;
    end;

    It's suppose to show another form that holds the image selected. It works with some images, but with others, it adds about fifteen pixels from the bottom of Image1 to the bottom of the form's window area. (Client area? Not sure what it's called...)

    I'm completely stumped. I've tried subtracting fifteen pixels from ClientHeight, but that doesn't work. That just adds those fifteen pixels to ClientWidth, for some reason...

    Anyways, I'm hoping you can help me. Tell me what I'm doing wrong

    -Mike

    Edit: Never mind. Fixed

  2. #2
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    make ur window's height and width unchangeable?i forgot what its called to do it(but its possible)
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  3. #3
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Why would I do that? I want it to adjust both the size of Image1 and Form2 when it loads the picture in. If I made Form2's bounds unchangeable, there's a chance it'll have to scroll.

    Edit: Nevermind, thread closed or whatever. You made me want to see what that property was called, and when I was looking, I found the boolean option "AutoSize". It fixed everything for some reason

    Edit2: Strange. I guess it didn't... Everything is fine now, but AutoSize didn't fix it. I guess I just had to adjust Image1's height a little bit on the main form. Strange...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do you code?
    By Wrycu in forum C/C++ Help and Tutorials
    Replies: 17
    Last Post: 10-27-2008, 02:10 PM
  2. Click every 10 pixels in the window
    By turner850 in forum OSR Help
    Replies: 2
    Last Post: 01-22-2008, 02:48 PM
  3. Code Box
    By Bam Bam in forum News and General
    Replies: 2
    Last Post: 08-15-2006, 10:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •