How to find the application path in code

J

JamesL

I am trying to convert a program from eVB to VB.NET.

I can hardly get past the first step. I want to display a bitmap of my logo
on the first screen. To do this I need to know the application path in
order for the code to find the bitmap.

Apparently the Background Image property for a form does not work in the
handheld side of VB.NET, only in desktop. So I am still trying to use a
picture box and load the bitmap to the image property in code.
Unfortunately, the app object no longer exists.

How do I determine the application path for a PocketPC?

James
 
J

JamesL

G

Guest

Sure. It's a lot like any custom control. First, load your image in your
ctor. Next, override the OnPaint method for your Form. You'll get a
Graphics object as the input param. Use the DrawImage method of the
Graphics object to paint your image to the Form, then call base.OnPaint to
draw the rest of the form.

-Chris
 
J

JamesL

I'm sorry, but I am not following these examples very well.

They create more questions then they answer. Is there anything more
detailed.

In the example in this link, I don't know what type the variable
backgroundImage should be Dimensioned as. I don't know where the statement
should go.

And then: the subroutine Protected Overrides Sub OnPaint(ByVal e As
PaintEventArgs)
I have no idea where this should go. Just stand on it's own inside that
form?

Is anything easy in VB.NET?

James
 
D

Daniel Moth

On the page you just went there is a link right at the bottom: "[View
Source]".
Click it.

Cheers
Daniel
 
J

JamesL

AAAHHHH!!!!

Now that is the kind of stuff I learn well from.

Thank you very much!

I'm just a little red faced now but I'll get over it.

Thanks.

James


Daniel Moth said:
On the page you just went there is a link right at the bottom: "[View
Source]".
Click it.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


JamesL said:
I'm sorry, but I am not following these examples very well.

They create more questions then they answer. Is there anything more
detailed.

In the example in this link, I don't know what type the variable
backgroundImage should be Dimensioned as. I don't know where the
statement should go.

And then: the subroutine Protected Overrides Sub OnPaint(ByVal e As
PaintEventArgs)
I have no idea where this should go. Just stand on it's own inside that
form?

Is anything easy in VB.NET?

James
 
J

JamesL

OK....

The image itself is listed as "BkgndImage.MyBkgnd.jpg"

Do I replace that with just my filename Logo.Bmp as it appears in Solution
Explorer?

James


Daniel Moth said:
On the page you just went there is a link right at the bottom: "[View
Source]".
Click it.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


JamesL said:
I'm sorry, but I am not following these examples very well.

They create more questions then they answer. Is there anything more
detailed.

In the example in this link, I don't know what type the variable
backgroundImage should be Dimensioned as. I don't know where the
statement should go.

And then: the subroutine Protected Overrides Sub OnPaint(ByVal e As
PaintEventArgs)
I have no idea where this should go. Just stand on it's own inside that
form?

Is anything easy in VB.NET?

James
 
J

JamesL

ummm....
No.

App.Path does not work in VB.NET.

That is what I had in eVB.

I am finding that VB.NET is worlds apart from eVB.

James
 
D

Daniel Moth

You see the example uses A.B.fileextension
You are asking if you can use B.fileextension
Is it not apparent that you are missing A?
Even if it is not apparent, why not try it and see what exception you get
and then when you post here you have more details to provide (e.g. some code
and the exception thrown).

Since by your own admission you are new to .NET CF, may I suggest you learn
to use the archives before posting here:
http://groups-beta.google.com/group...urceStream&qt_g=1&searchnow=Search+this+group

The CF FAQ (look at 7.3):
http://msdn.microsoft.com/smartclient/understanding/netcf/FAQ/default.aspx#7.3

Also remove the evb group as VB.NET questions are irrelevant to it.

Please understand it is easier for me to just give you the answer rather
than write all of the above but I think you'll appreciate learning how to
find things for yourself and rely on the ng for harder questions (that
preferably have not been asked/answered before).

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


JamesL said:
OK....

The image itself is listed as "BkgndImage.MyBkgnd.jpg"

Do I replace that with just my filename Logo.Bmp as it appears in Solution
Explorer?

James


Daniel Moth said:
On the page you just went there is a link right at the bottom: "[View
Source]".
Click it.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


JamesL said:
I'm sorry, but I am not following these examples very well.

They create more questions then they answer. Is there anything more
detailed.

In the example in this link, I don't know what type the variable
backgroundImage should be Dimensioned as. I don't know where the
statement should go.

And then: the subroutine Protected Overrides Sub OnPaint(ByVal e As
PaintEventArgs)
I have no idea where this should go. Just stand on it's own inside that
form?

Is anything easy in VB.NET?

James


http://samples.gotdotnet.com/quickstart/CompactFramework/doc/bkgndimage.aspx

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


The key that I do not know:

How do I override the OnPaint method?

James

"<ctacke/>" <ctacke_AT_OpenNETCF_com> wrote in message
Sure. It's a lot like any custom control. First, load your image in
your ctor. Next, override the OnPaint method for your Form. You'll
get a Graphics object as the input param. Use the DrawImage method
of the Graphics object to paint your image to the Form, then call
base.OnPaint to draw the rest of the form.

-Chris

can you expand on the OnPaint?

James


CE doesn't have a notion of app path. You can use reflection to
find out where your assembly was started from though:

For your Form you can override OnPaint and paint in the background
there.
http://wiki.opennetcf.org/ow.asp?CompactFrameworkFAQ/StartupDirectory

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


I am trying to convert a program from eVB to VB.NET.

I can hardly get past the first step. I want to display a bitmap
of my logo on the first screen. To do this I need to know the
application path in order for the code to find the bitmap.

Apparently the Background Image property for a form does not work
in the handheld side of VB.NET, only in desktop. So I am still
trying to use a picture box and load the bitmap to the image
property in code. Unfortunately, the app object no longer exists.

How do I determine the application path for a PocketPC?

James
 
C

Chris Tacke, eMVP

Um, no. App.Path doesn't exist. It doesn't even exist on the desktop in
VB.NET - it's Application.StartupPath. It's still not available in the CF.

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

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

Similar Threads


Top