Solved

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

Posted on 2003-10-29
7
485 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
Comment Utility
What program are you using?
0
 

Author Comment

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

Accepted Solution

by:
Goofytouy earned 125 total points
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:SaadKhakwani
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

762 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

6 Experts available now in Live!

Get 1:1 Help Now