 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 17th, 2004, 01:05 PM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
help: creating "resources"
Can anyone help me with building "resources"? I have several plain-text files and .jpg images that my app needs to access...
I have searched extensively on MSDN, just can't seem to get the info I need.
|
|

March 17th, 2004, 01:16 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Rissa,
Take a look at this article. It explains the general idea for embedding stuff. It uses images in a Pocket PC application, but the principe holds true for desktop apps as well.
Also, check out this post for details about embedding text documents:
http://p2p.wrox.com/topic.asp?TOPIC_ID=9341
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

March 17th, 2004, 01:35 PM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you WROCK!!!!!
That's exactly what I needed... I forgot to mention that I'm actually writing an app for Pocket PC.
But what in the world is a resourceSet? Is the documentation on MSDN meant for much older versions of VB? Should I create a satellite assembly -- and is that, essentially, a project within my project?
Last question for today...Even after setting properties to "embedded resource", nothing appears in the "Resource View" tab... what's that tab for?
again, huge thanks!
|
|

March 17th, 2004, 02:45 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What do you mean with the Resource View tab?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

March 17th, 2004, 05:19 PM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When you select from the menu "View, Resource View" It opens a Window (in the same place as the Solution window)
BTW, I am deeply grateful for your hints above. It's working!!!!
But I had to delete "ImageFromResourceStream." from the show-image code, and "embeddedTextFiles." from the load-text code. Also, even though I have these resources tucked into folders, I did not have to name the folders in my code. Could be a difference in newer versions of .NET?
And I love your signature!
|
|

March 17th, 2004, 07:48 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
No, not that I am aware of. The article was written with Visual Studio .NET 2003, although it would work as well on 2002.
Are you using VB.NET or C#? There is a difference between the languages in respect to naming embedded resources. If you think you found an error, would you mind e-mailing me about it? Like you said, it's hard to find solid resources in this area, so it's possible I made things more difficult than necessary in the article, although it worked for me.
I did quite a large project on the Pocket PC with .NET a while ago. I know where you're going through right now. You'll get plenty of odd bugs, events not firing, reboot issues and other frustrating behavior.... But it's really nice when it all comes together, and you can order lunch through your pocket PC, while sitting outside in the sun.... ;)
Good luck, (you'll need it),
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

March 18th, 2004, 12:08 PM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm using VB -- But I had to delete the "ImageFromResourceStream" segment from your VB code. I was able to translate the c# code in the text sample into VB easily enough, but still had to delete the "embeddedTextFiles" segment. So I don't know... were those your assembly names, perhaps? Yeah, that's probably what they were...
Still, I didn't have to include folder names.
Anyway, it's working and I'm thrilled. Now, If I could just get this stupid thing to leave the SIP enabled when I close the SaveFileDialog.... arrrrgggghhhhhh!
|
|

March 18th, 2004, 12:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
embeddedTextFiles was indeed the name of the Default Namespace and the Assembly.
Like I said in my article, the folder names are only necessary for C#:
Quote:
quote:When you have stored your images in separate folders (in a Project in VS.NET it's easy to create subfolders to group related files more logically together), you'll need to add the name of that folder between the default namespace and the name of the image, separated by a period. This applies only to C# projects:
Bitmap MyBitmap = new Bitmap(Assembly.GetExecutingAssembly().
GetManifestResourceStream(
"ImageFromResourceStream.Images.Demo.DemoImage.gif "
));
pictureBox1.Image = MyBitmap;
This code will display an image that is embedded as DemoImage.gif in a subfolder called Demo which is located in the Images folder at the root of your project.
|
So I think it makes sense you didn't have to include the folder names.
The SIP can indeed be a pain to works with. Can't you re-enable it after the File dialog is closed?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

March 18th, 2004, 01:36 PM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Right, got it.... missed the spec that only C# needed folder name. Sorry.
On the SIP issue, here's what I have:
Code:
Private Sub SaveNotes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveNotes.Click
If (SaveFileDialog1.ShowDialog() = DialogResult.OK) Then
'stuff to save the file
End If
End Sub
I've tried adding both "inputPanel1.enabled=true" and "TextBox2.Focus()" within the Save Button handler. NOTE: I already have a separate handler that enables the SIP when this TextBox has focus.
But neither of these ideas has solved the problem. The SIP still closes when the Dialog closes.
sigh.....
|
|

March 18th, 2004, 03:26 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
No problem. Glad you got it to work anyway.
The SIP is one weird control in the Framework. I remember my colleague trying to do some fancy stuff by instantiating a global SIP that was accessible by our presentation layer. I also remember him screaming and throwing stuff ;)
Does the behavior take place in a real Pocket PC as well? We found that there were lots of differences between the emulator and the device (max number of loadable forms, odd SIP behavior, appearance / flickering of the main menu, etc).
You want to try something like:
SaveNotes.Dispose()
inputPanel1.Enabled = True
This will kill the SaveNotes object before it tries to restore your InputPanel.
Otherwise, you could look into some GotFocus event (maybe for a text box, or the form) to restore the SIP, although that's a bit dirty, IMO.
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Conditional Resources |
Jose Silva |
Visual Studio 2005 |
0 |
March 16th, 2008 04:55 PM |
| Resources |
mike72 |
ASP.NET 2.0 Professional |
0 |
January 3rd, 2006 08:25 AM |
| MCAD resources |
khautinh |
ADO.NET |
0 |
February 9th, 2004 08:58 PM |
| Resources |
vijay |
VB.NET 2002/2003 Basics |
2 |
November 3rd, 2003 11:25 AM |
|
 |