Thread: Scrolling Image Control

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    4

    Scrolling Image Control

    Hi all,

    I am trying to display an image onto a fixed sized static control and if the image exceeds the size of the control, scrolling is enabled. However whenever I load the image onto the control by using

    Code:
    SendMessage( m_hMain, STM_SETIMAGE, ( WPARAM )IMAGE_BITMAP, ( LPARAM )m_hDisplay );
    the static control gets resized to the bitmap's size.

    Is there a way to display the image on the static control then enabling the scrollbars to work or is there another approach to this?

    I appreciate any help. Thanks

  2. #2
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    well you could resize your bitmap to fit the control. You can do that outside the program.
    However if bitmap dimensions vary, then there is a function for that...
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    If using only XP, you can use the SS_REALSIZECONTROL style on the static so the image is resized to the frame.

    Else look at ownerdraw, ScrollDC(), BitBlit() ect.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    4
    Hi thanks for the reply, however here I would like to retain the size of the original bitmap and allow scrolling when the bitmap size exceeds the control size.

    I added WS_HSCROLL and WS_VSCROLL to the static control however it seems that the scrollbars are not working even when the image is larger than the control size. Is there a way to work around this issue?

    Thanks again

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Whan I need to do this I use a back buffer and do my own drawing.

    I use CreateCompatibleDC(), CreateCompatibelBitmap(), ScrollDC(), BitBlit(), SelectObject() ect.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Loading an image to a picture control
    By hanhao in forum C++ Programming
    Replies: 0
    Last Post: 05-06-2004, 03:22 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Changing the image in a picture control
    By pinkcheese in forum Windows Programming
    Replies: 1
    Last Post: 04-15-2002, 03:14 PM