Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2003-10-29
7
Medium Priority
?
532 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Curious about the latest ransomware attack? Check out our timeline of events surrounding the spread of this new virus along with tips on how to mitigate the damage.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

609 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