473,785 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to paint 1px by 1px clear image on windows form

I'm painting images onto a windows form using this method:

e.Graphics.Draw ImageUnscaled(m _ItemImage, x, y)

every time I select a product. However, some products don't have an image
so when a user selects a different product from a list and that product
doesn't have an image, I need to clear the image from the previous product
that was painted onto the form.

I was thinking of creating a clear image and using the DrawImageUnscal ed
method, but if anyone has a better idea, I'm all ears.

Can anyone make some good recommendations .

Thanks.

--
mo*******@nospa m.com
Nov 20 '05 #1
7 2055
"moondaddy" <mo*******@nosp am.com> wrote in message
news:Ou******** ******@tk2msftn gp13.phx.gbl...
I'm painting images onto a windows form using this method:

e.Graphics.Draw ImageUnscaled(m _ItemImage, x, y)

every time I select a product. However, some products don't have an image
so when a user selects a different product from a list and that product
doesn't have an image, I need to clear the image from the previous product
that was painted onto the form.

I was thinking of creating a clear image and using the DrawImageUnscal ed
method, but if anyone has a better idea, I'm all ears.

Can anyone make some good recommendations .

Thanks.


Personally, I would use a PictureBox and change Visible to False when it is
not needed, i.e. there is no image to show. But you could always use
e.Graphics.Draw Rectangle and erase it, if you continue down the path you are
on.

Best Regards,

Andy

".NET or .DIE"
Nov 20 '05 #2
Hi,

It seems that you are painted the picture in the OnPaint event.
If so I think we can just do not call the
e.Graphics.Draw ImageUnscaled(m _ItemImage, x, y) method, so that there will
be no picture drawn on the form. If you want to display any thing to to
indicate that the product is of no pciture, we can just paint it on the
form, e.g. a predefined picture or some text.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3
OK I'll look into it.

--
mo*******@nospa m.com
""Peter Huang"" <v-******@online.m icrosoft.com> wrote in message
news:aE******** ******@cpmsftng xa10.phx.gbl...
Hi,

It seems that you are painted the picture in the OnPaint event.
If so I think we can just do not call the
e.Graphics.Draw ImageUnscaled(m _ItemImage, x, y) method, so that there will
be no picture drawn on the form. If you want to display any thing to to
indicate that the product is of no pciture, we can just paint it on the
form, e.g. a predefined picture or some text.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
Thanks Andy, The reason I need to draw the image on the form and not a
picturebox is because the images vary in size and dimension and the
picturebox resized the image into the size of the picturebox which deforms
the image.

--
mo*******@nospa m.com
"Andy Becker" <x@x.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
"moondaddy" <mo*******@nosp am.com> wrote in message
news:Ou******** ******@tk2msftn gp13.phx.gbl...
I'm painting images onto a windows form using this method:

e.Graphics.Draw ImageUnscaled(m _ItemImage, x, y)

every time I select a product. However, some products don't have an image so when a user selects a different product from a list and that product
doesn't have an image, I need to clear the image from the previous product that was painted onto the form.

I was thinking of creating a clear image and using the DrawImageUnscal ed
method, but if anyone has a better idea, I'm all ears.

Can anyone make some good recommendations .

Thanks.
Personally, I would use a PictureBox and change Visible to False when it

is not needed, i.e. there is no image to show. But you could always use
e.Graphics.Draw Rectangle and erase it, if you continue down the path you are on.

Best Regards,

Andy

".NET or .DIE"

Nov 20 '05 #5
Hi

I look forward to your reply. If you have any concern on this issue,please
feel free to post here and I will work on it with you.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #6
Thanks Peter, That worked for me.

Now I'm changing the form around a bit and most of the form is covered by a
tab control. So now I need to paint the image on the tab control. How
would I do that?

--
mo*******@nospa m.com
""Peter Huang"" <v-******@online.m icrosoft.com> wrote in message
news:aE******** ******@cpmsftng xa10.phx.gbl...
Hi,

It seems that you are painted the picture in the OnPaint event.
If so I think we can just do not call the
e.Graphics.Draw ImageUnscaled(m _ItemImage, x, y) method, so that there will
be no picture drawn on the form. If you want to display any thing to to
indicate that the product is of no pciture, we can just paint it on the
form, e.g. a predefined picture or some text.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #7
Hi,

Do you mean the tabcontrol or the tabpage control?
For the tabcontrol we can create a graphics based on the hwnd of the
tabcontrol, but the tabpage is on the tabcontrol, the picture will be
coverred by the tabpage.
Dim hwnd As New IntPtr
hwnd = Me.TabControl1. Handle
' Create new graphics object using handle to window.
Dim newGraphics As Graphics = Graphics.FromHw nd(hwnd)
newGraphics.Dra wImage(New
System.Drawing. Bitmap("c:\test \TestPIC\a.bmp" ), 0, 0)

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1887
by: DraguVaso | last post by:
Hi, I 'wrote' my own DataGrid, using the normal DataGrid, and overriding some of the DataGridTextBoxColumn-methods (mostly the Paint-method). I based most of my changes on the Windows Form FAQ: - http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q745q - http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q758q - http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q837q Basicly it works like this: Every time a cell has...
2
2463
by: DraguVaso | last post by:
Hi, In the override of the Paint-method of a DataGridTextBoxColumn I want to show an image with BitBlt, to see what I can gain there on performance. The problem is: It doesn't show me the image in the DataGrid-Cell's, but a black background... Does anybody has any idea what I am doing wrong? Thanks a lot in advance,
0
1907
by: Duncan Mole | last post by:
Hi, I have created a control which draws a title bar and provides a drop down menu for a Smart Device Application. It seemed to work fine until I came to add an event handler to act on Paint messages in the form which has drawn the control. Evidently, the control is consuming all of these messages. How can I pass them back/on? I have a reference to the owner form but calling Refresh() via this reference isn't helping. Help! Do I need to...
2
4914
by: Serge Klokov | last post by:
Hi! 1. Please, help with example "paint on form by mouse" 2. Below is my example, but it clear the line after each Refresh()... how to fix? 3. How to draw the line in Mouse_Move event? private Boolean isCanPaint = false; private MouseEventArgs MouseEvent1;
5
1401
by: Peter Oliphant | last post by:
I'm drawing graphics using the Graphics object one can grab in a Form's Paint event. But I'm getting a weird thing happening... These graphic shapes flicker (even if unchanged). UNLESS- I created a timer and had the timer update a Label on the form with timer interval set to 10. Now all the shapes I draw in the Paint event of the form draw WITHOUT flicker!!! What is updating a Label doing that is preventing flicker? Is it somehow...
21
5226
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each table and 11 sub items with data about each column. When a Row in ListView1 is selected the Data in ListVies2 is loaded to show the correct data. Initially the first row in ListView1 is selected in FormX load
1
2589
by: André Nogueira | last post by:
Hi there. I'd like to allow the user to create some free-form drawing in my application, in the style of Microsoft Paint (the Brush tool) or Paint.Net. I've looked through Paint.Net's source code, but could not quite understand it... :$ So.. what should I do? are there any tutorials? I've got some code working, but this codes creates a non continuous line and is kind of slow.. My code is
7
1830
by: hamil | last post by:
The following code will display a tif file on a form. When another form is moved over the tif image, the tif image is erased where the form was moved. A paint event occurs when this happens. My question is..how would I save the tif images as soon as it is initially painted, and then restore the image in a paint event. It seems to me that there should be some sort of a SaveImage method and a RestoreImage method that would be fast. Note:...
2
3349
by: anthony | last post by:
I'm embarrassed to ask this. I have a form with a bound object frame which displays an embedded bitmap stored in the table that the form is based on. How do I, by single or double click, get the image to open in Paint (the current Windows file association). I'm reduced to using SendKeys and I'm sure there are more elegant ways Anthony
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.