I'm using Borland Builder C++ 6 (my tutors force me to) and I want to make a TImage full screen. I don't think there's any specific function for this, the only way I can see doing it is possibly manipulating the Height and Width properties, but then again I can't see it working unless I change the properties of form, panels etc.

Can someone please try and help me out?!

There's nothing wrong with BC++Builder...

What do you mean "make a TImage full screen"? Do you have an image you want to resize to your desktop? Or do you mean that you have a form and you want the image area to grow with the form when you maximize (like MSPaint's image area does)? Does the image have an actual picture in it that must be preserved?

I'm making a program that loads a picture from a file into the TImage and reads all the other pictures in the directory of the file chosen into a TStringList then when a button is pressed it begins a slideshow, displaying the pictures from the directory in the TImage property at a user selected speed (using a timer). All this works fine, but now I need to implement a button that makes the picture loaded (and hence the slideshow) appear full screen. i.e. the whole of the monitors resolution is taken up by the TImage property. The slideshow need also to work when in 'full screen mode', and I'll probably want to use a keyHit to escape the full screen mode (most likely using a virtual key press).

Hope this is more understandable. And with regards to Borland...well I'm used to using Visual Studio and I find it a lot more user friendly!

Thanks

To make a form fullscreen and restore it you will have to manipulate your form using a couple of Win32 API functions. #include <windows.h> First, you'll need some class variables to preserve your form's normal attributes when it is fullscreen. LONG f_form_style; WINDOWPLACEMENT f_form_placement; You'll also want to remember whether or not you are actually fullscreen. bool f_is_fullscreen = false; The following code snippit makes the window fullscreen. The variable handle is your form's hWnd.

WINDOWPLACEMENT wp;

  if (f_is_fullscreen) return;

  f_form_style = SetWindowLong( handle, GWL_STYLE, 0 );
  f_form_placement.length = sizeof( WINDOWPLACEMENT );
  GetWindowPlacement( handle, &f_form_placement );

  wp = f_form_placement;
  wp.showCmd = SW_SHOWMAXIMIZED;

  SetWindowPlacement( handle, &wp );

To restore the window:

SetWindowPlacement( handle, &f_form_placement );
  SetWindowLong( handle, GWL_STYLE, f_form_style );

As to the image, with Borland's TImage component, all you need to do is make sure that the AutoSize property is False and set the Stretch property to True. This will cause the image to stretch to fit the control's dimensions. That may distort it, so you will have to adjust the size of the control each time you assign a new bitmap to its Bitmap property to keep the aspect ratio correct.

So, if you have a form with a black or other neutral background with just a TImage on it, you can set the form to fullscreen. Then, to animate, just set a TTimer to assign the next image's bitmap to the form's TImage.picture.bitmap property, adjust the size so that at least two edges touch the form's edges, and you are all set.

Hope this helps.

I forgot to set the value of f_is_fullscreen in the code snippits. Don't forget to do that...:)

Thanks dude you are awesome. Now there's actually a little bit of info on how to do something with a TImage on the net!

Im actually a bit confused as to what to do with the handle variable, could you explain it a bit more? Do I need to get a value for the forms hWnd and then copy it to the handle variable?

Im actually a bit confused as to what to do with the handle variable, could you explain it a bit more? Do I need to get a value for the forms hWnd and then copy it to the handle variable?

Actually mate I've just sorted it, cheers anyway!

This article has been dead for over six months. Start a new discussion instead.