#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0

    Picture box control is hard work


    Hi,

    I am using a picture box in my application to display a bitmap. However on a radio button it should clear the contents of the bitmap.

    I have been trying for ages to find a way to clear the contents.

    However im not getting anywhere.

    My app is kinda like mouse spy so I copy the contents under the mouse to the box. So you should think there would be a command to clear the contents but I cant find any documentation for visual c++ on the stupid picture box control
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Hi,

    you need to set the picture property of picture box to nothing.
    in VB i use the following.try similar statement in VC as well.it should work.


    Set Picture1.Picture = Nothing
    SR -
    webshiju.com
    www.lizratechnologies.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0
    Yeah VB makes super light work of this,

    However can you think of the command I need to send to the control?

    There must be something.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    did you try "Picture1.Picture=null;" ? this would be the corresponding command to the vb one.

    i donīt know that much about windows/c but in delphi i use:
    Picture1.Bitmap.Free();
    Picture1.Bitmap:=new TBitmap();

    you should be able to find the corresponding commands for c.

    did this help?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0
    Well you say set picture1 = null etc but in c its does not seem anywhere near as easy :-(

    I have implemented a slight workaround which is to have 2 bitmaps one which never changes and one which shows the bitmap, I just toggle the visible state. Its not great but it works fine.


    Unless someone actually has any C code to set the picturebox control back to nothing (ie show the button face colour again).

    Thanks though
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    does my second suggestion not work? it should...
    you destroy the old bitmap (free the memory) and just create a new one. let me try to translate the lines to c:

    freemem(Picture1.Picture);
    Picture1.Picture:=new(TPicture);

    did this help? (maybe donīt destroy the picture but the bitmap inside... this got me stuck for some hrs too)
  12. #7
  13. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    The following will work for you.you just release the picture box after the use:


    Picture1->Release();
    SR -
    webshiju.com
    www.lizratechnologies.com

    "The fear of the LORD is the beginning of knowledge..."
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0
    this seems to be going on :-)

    Im using straight C so I dont actually have a ref to the control I have to send it messages.

    So im busy trying to find out what to send it to clear itself :=-)
  16. #9
  17. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4248
    Are you using the Active-X CPictureBox control or just a plain old Bitmap?
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0
    Just a plain old bitmap control in bog standard C.

    I have to send messages to controls since I dont actually have a physicall reference to them.
  20. #11
  21. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4248
    Have you tried sending a WM_HIDE message to the control?
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0
    yeah but that completely hides the control which is no good :-)

    There has to be a simple way to send a clear message to a control (picture control)

IMN logo majestic logo threadwatch logo seochat tools logo