How to display a bitmap in VB.NET for pocket_PC

J

JamesL

OK,



I am trying to create a form in VB.NET program for the pocket PC. I want to
display my logo on the form. I put a picture box on the form. I get the
application path. I attach the filename to the path. But, the visualstudio
help tells me to use the command:

picturebox.image = image.fromfile(filename)

However, fromfile is not an option for the pocket_pc, only desktop VB.NET.

Below is the code I have:



Imports System.IO

Imports System.Reflection



Private Sub frmLogo_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' This is the full directory and exe name

Dim fullAppName As String =
[Assembly].GetCallingAssembly().GetName().CodeBase

' This strips off the exe name

Dim fullAppPath As String = Path.GetDirectoryName(fullAppName)

' This adds a file name to the path

Dim fullFileName As String = Path.Combine(fullAppPath, "Logo.bmp")



Now how do I put the Logo.bmp on the image of the picturebox?



Or is there a better way to get my image to appear on the form, maybe as a
background image on the form itself?



James





End Sub
 
S

Serg Kuryata [MS]

To load a bitmap from a file into a picturebox, you can something like the
following:

bitmap = new Bitmap(fileName);
pictureBox.Image = bitmap;

Hope this helps.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Reply-To: "JamesL" <[email protected]>
| From: "JamesL" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: How to display a bitmap in VB.NET for pocket_PC
| Lines: 59
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <[email protected]>
| Date: Fri, 22 Apr 2005 17:11:08 GMT
| NNTP-Posting-Host: 24.148.247.15
| X-Complaints-To: (e-mail address removed)
| X-Trace: newsread1.news.pas.earthlink.net 1114189868 24.148.247.15 (Fri,
22 Apr 2005 10:11:08 PDT)
| NNTP-Posting-Date: Fri, 22 Apr 2005 10:11:08 PDT
| Organization: EarthLink Inc. -- http://www.EarthLink.net
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.
earthlink.net!newsread1.news.pas.earthlink.net.POSTED!40a70a7c!not-for-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.compactframework:27611
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| OK,
|
|
|
| I am trying to create a form in VB.NET program for the pocket PC. I want
to
| display my logo on the form. I put a picture box on the form. I get the
| application path. I attach the filename to the path. But, the
visualstudio
| help tells me to use the command:
|
| picturebox.image = image.fromfile(filename)
|
| However, fromfile is not an option for the pocket_pc, only desktop VB.NET.
|
| Below is the code I have:
|
|
|
| Imports System.IO
|
| Imports System.Reflection
|
|
|
| Private Sub frmLogo_Load(ByVal sender As System.Object, ByVal e As
| System.EventArgs) Handles MyBase.Load
|
| ' This is the full directory and exe name
|
| Dim fullAppName As String =
| [Assembly].GetCallingAssembly().GetName().CodeBase
|
| ' This strips off the exe name
|
| Dim fullAppPath As String = Path.GetDirectoryName(fullAppName)
|
| ' This adds a file name to the path
|
| Dim fullFileName As String = Path.Combine(fullAppPath, "Logo.bmp")
|
|
|
| Now how do I put the Logo.bmp on the image of the picturebox?
|
|
|
| Or is there a better way to get my image to appear on the form, maybe as
a
| background image on the form itself?
|
|
|
| James
|
|
|
|
|
| End Sub
|
|
|
 
C

Chris Tacke, eMVP

Load the image as a Bitmap (there's a ctor that takes a Path to a file),
thin override the Form's OnPaint and draw it right to the Form.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
J

JamesL

When you say "override" the forms OnPaint do you mean put the necessary
coding in the form_pain subroutine?

James

Chris Tacke said:
Load the image as a Bitmap (there's a ctor that takes a Path to a file),
thin override the Form's OnPaint and draw it right to the Form.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


JamesL said:
OK,



I am trying to create a form in VB.NET program for the pocket PC. I want
to display my logo on the form. I put a picture box on the form. I get
the application path. I attach the filename to the path. But, the
visualstudio help tells me to use the command:

picturebox.image = image.fromfile(filename)

However, fromfile is not an option for the pocket_pc, only desktop
VB.NET.

Below is the code I have:



Imports System.IO

Imports System.Reflection



Private Sub frmLogo_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' This is the full directory and exe name

Dim fullAppName As String =
[Assembly].GetCallingAssembly().GetName().CodeBase

' This strips off the exe name

Dim fullAppPath As String = Path.GetDirectoryName(fullAppName)

' This adds a file name to the path

Dim fullFileName As String = Path.Combine(fullAppPath, "Logo.bmp")



Now how do I put the Logo.bmp on the image of the picturebox?



Or is there a better way to get my image to appear on the form, maybe as
a background image on the form itself?



James





End Sub
 
J

JamesL

AHHH! Excellent!

I combined your answer, with Chris Tacke's answer and with information form
the discussion thread by Giussepe about embedded bitmaps and have got
something even better than I started with! I embedded the bitmap and now I
don't need to concern myself with the application path.

Very Nice!

Thank you all!

I am starting to like some of the added power I get in VB.NET even if I am
slow on the uptake with it!

James
Serg Kuryata said:
To load a bitmap from a file into a picturebox, you can something like the
following:

bitmap = new Bitmap(fileName);
pictureBox.Image = bitmap;

Hope this helps.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
| Reply-To: "JamesL" <[email protected]>
| From: "JamesL" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: How to display a bitmap in VB.NET for pocket_PC
| Lines: 59
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <[email protected]>
| Date: Fri, 22 Apr 2005 17:11:08 GMT
| NNTP-Posting-Host: 24.148.247.15
| X-Complaints-To: (e-mail address removed)
| X-Trace: newsread1.news.pas.earthlink.net 1114189868 24.148.247.15 (Fri,
22 Apr 2005 10:11:08 PDT)
| NNTP-Posting-Date: Fri, 22 Apr 2005 10:11:08 PDT
| Organization: EarthLink Inc. -- http://www.EarthLink.net
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.
earthlink.net!newsread1.news.pas.earthlink.net.POSTED!40a70a7c!not-for-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.compactframework:27611
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| OK,
|
|
|
| I am trying to create a form in VB.NET program for the pocket PC. I want
to
| display my logo on the form. I put a picture box on the form. I get
the
| application path. I attach the filename to the path. But, the
visualstudio
| help tells me to use the command:
|
| picturebox.image = image.fromfile(filename)
|
| However, fromfile is not an option for the pocket_pc, only desktop
VB.NET.
|
| Below is the code I have:
|
|
|
| Imports System.IO
|
| Imports System.Reflection
|
|
|
| Private Sub frmLogo_Load(ByVal sender As System.Object, ByVal e As
| System.EventArgs) Handles MyBase.Load
|
| ' This is the full directory and exe name
|
| Dim fullAppName As String =
| [Assembly].GetCallingAssembly().GetName().CodeBase
|
| ' This strips off the exe name
|
| Dim fullAppPath As String = Path.GetDirectoryName(fullAppName)
|
| ' This adds a file name to the path
|
| Dim fullFileName As String = Path.Combine(fullAppPath, "Logo.bmp")
|
|
|
| Now how do I put the Logo.bmp on the image of the picturebox?
|
|
|
| Or is there a better way to get my image to appear on the form, maybe as
a
| background image on the form itself?
|
|
|
| James
|
|
|
|
|
| End Sub
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top