?
Solved

want to get the bitmap behind a picture box !!!

Posted on 2003-10-29
7
Medium Priority
?
531 Views
Last Modified: 2012-08-13
Hello,
I want to retrieve the bitmap behind a picture box, i mean there is a command button and a text box for example, on a form. Now a picture box is placed just as it is in front of the command button and the text box. I have to get the bitmap of the same coordinates as of the picturebox, i.e what is the image beneath that pic. box.
I have tried different techniques but failed, one such was to make the pic. box invisible (Picture1.Visible = False) and then get the hdc of the form1 and Paint in Pic. Box using BitBlt, then True its Visible Property. and then alpha blend to make the picture1 *look* translucent!

That is good when the picturebox is static but when we want it to move, or the background picture of form1 is changed. It fails, or even if we update the code every time, that toggling of visibility causes the picture to flicker.!
Any Comments,
Thanks.
Saad.
0
Comment
Question by:SaadKhakwani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:Kokoglen
ID: 9645135
What program are you using?
0
 

Author Comment

by:SaadKhakwani
ID: 9648354
I am trying to do that in Visual Basic!
0
 
LVL 5

Accepted Solution

by:
Goofytouy earned 500 total points
ID: 9660147
I do not understand something... Reading what you are saying, are you trying to turn invisible the command button and the textbox?

what do you mean with "hdc"?

Can you explain more? Let's say... the picturebox... which is its function? cover part of the background image?
The background image... is on an MDI form? is on another picturebox?

0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

Author Comment

by:SaadKhakwani
ID: 9662466
Goofytouy:
i am saying that there is a form. I have loaded a picture into it,

Form1.Picture = LoadPicture(whatever)

Now textbox, commandbutton and picturebox all are on that form, but picturebox is on top of textbox and command button i.e

Picture1.ZOrder 0
All are contained in the form!
PictureBox doesn't contain Anything!

Here i want to add the code as, the Picture1, becomes translucent. I could see the textbox and commandbutton and whatever the image is on the form, through the Picturebox,
Retrieving the hDC of the Form1 by using GetDC(Form1.hWnd), also gives the image of the Picturebox because that is also on the Form1. turning the picturebox invisible does the trick because if picturebox is invisible, the hDC of the form thus generated wont show picturebox, but all else control do. Now BitBlt the hDC of the Form1 to fit in pictureBox, so that the part of the Form1's hDC which shows the part of other controls (which were actually beneath the PictureBox) comes in Picture1!!! AlphaBlend if required to make the image more translucent!
Then turn the picture1.Visible = True!

That algorithm is ok if things are static, but when the textbox or commandbutton moves the picture of the Picture1 is not updated! or even if we do update! The repeated toggling of picture1 from visible to invisible cause it to flicker badly!
that was one poor way of making a picturebox translucent!, but if someone knows better, please tell me!!!
0
 
LVL 5

Expert Comment

by:Goofytouy
ID: 9671278
As far as I understand (let me say is difficult because I can no imagine what would be the point), you are going to have flicker in every case. At least, you should take it to the minimum by updating picture1 only as necessary. let's say you may code a function "updatepicture1" and call it from "form_activate", "form_resize" and other "rupture points" (remember to code an UDF for checking the contents of form1.picture)

But as said before, eliminating flicker is imposible as VB redraws all in every change...
0
 
LVL 11

Expert Comment

by:turn123
ID: 10172591
SaadKhakwani,
No comment has been added lately (80 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to Goofytouy http:#9671278

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

turn123
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
I originally wrote this article to compare SARDU and YUMI, but have now added Easy2Boot, since that is the one I currently use and find the easiest to create and alter.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.

764 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