Solved

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

Posted on 2003-10-29
7
498 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
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 125 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CD into MP3 19 96
Which free XML software can I use for opening and editing an XML file? 15 105
Any free software for printscreens 7 83
Chrome: How to show the Bookmarks bar? 4 19
If your app took Google’s lash recently, here are the 5 most likely reasons.
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…
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

862 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

Need Help in Real-Time?

Connect with top rated Experts

30 Experts available now in Live!

Get 1:1 Help Now