|
OK, here is the situation. In the program I have a number of buttons, when you click on one an image is placed in a picture box which then can be moved and positioned on the screen. The image name is then listed in a list box. If you click another button another image is placed on the screen. If you go back and click the same button again the same image is place on the screen and is listed in the list box with the same name. Is there a way to add a number to the listbox picture name and have it correspond to the same item on the screen.
Thanks
|
|
|
|
|
Your best bet is to dispose of the picture boxes, and render a number on top of the images when you render them. Or, just load the image, build a graphics object, draw a number on it, and then put it in your wretched picture box.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Do you have any sample code on how to render a number on top of an image.
Thanks
|
|
|
|
|
Hi,
if you are already rendering the image, you can add text to it like so:
Graphics g=myPaintEventArgs.Graphics;
g.DrawImage(...);
g.DrawString(myText, myFont, ...);
But if you want to modify an image to include some text, get its graphics:
using (Graphics g=Graphics.FromImage(myImage)) {
g.DrawString(myText, myFont, ...);
}
myImage.Save(...);
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
This is the code for one of my buttons which places an image. Does it get added to this section?
Thanks
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim p As PictureBox
p = New PictureBox
Current_item = Item_names.door
p.Image = System.Drawing.Image.FromFile(door_image)
PictureBox1.Left = 84
PictureBox1.Top = 78
PictureBox1.Height = p.Image.Height
PictureBox1.Width = p.Image.Width
PictureBox1.Visible = True
PictureBox1.BorderStyle = BorderStyle.FixedSingle
PictureBox1.Image = System.Drawing.Image.FromFile(door_image)
PictureBox1.Select()
If PictureBox1.Controls.Count > 0 Then
PictureBox1.Controls.RemoveAt(0)
End If
p.Dispose()
End Sub
|
|
|
|
|
Hi Tom,
1.
my example code was C# not VB, sorry. VB.NET can do the same with a slightly different
syntax (except for the using statement, which is a shorthand for automatically calling
Dispose when done with an object).
2.
alternative one was about rendering, hence it goes in the Paint handler.
alterbative two was about modifying an existing image, hence it goes anywhere you like
(but such that it gets called only once for any given image)
3.
your code is a mess:
what is p and what is PictureBox1?? p is never really used/shown!
why would you set Top and Left again and again?
are you adding (and removing) Controls to a PictureBox???
4.
I am not exactly sure what it is you want to achieve, but
I concur with Cristian's suggestion to throw out all pictureboxes.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I have one data scraping project where my vb.net 2.0 application will browse pages and will extract information from there. The only problem is the IP address if the site comes to know that any IP is doing this job they block it. There are many softwares out there is in the market which hides the IP . Is there any way I can do this job in my application through code instead of buying any third party component ?
Any help would be precious
Best Regards
|
|
|
|
|
Do you understand what the purpose of an IP address is?
It allows servers to identify where the request for a page comes from and where to serve the results to.
This means that the server has to have an IP address supplied to it.
As far as I know all you can do is route yourself through a proxy server if you wish to hide your IP address.
You could write yourself a proxy server application - which is a task I am no expert in.
However that proxy server's IP address could get blocked.
You always pass failure on the way to success.
|
|
|
|
|
Written an app to play some sounds for me, in time with a text file I've got displayed.
Uses Microsoft.DirectX.AudioVideoPlayback (April 07 SDK I believe) and consists of an array of 7 Audio objects, where each is set to a particular file by the following:
Imports DXAV = Microsoft.DirectX.AudioVideoPlayback
Dim audioTracks(7) As DXAV.Audio
Private Sub SetSound(ByVal trackID As Byte, ByVal soundName As String)
Dim soundFullName As String = soundPath & soundName & soundExt ' Builds full filename
If IO.File.Exists(soundFullName) Then
audioTracks(trackID) = New DXAV.Audio(soundFullName)
Else
MsgBox("File not found: " & soundFullName & ".", MsgBoxStyle.Exclamation)
End If
End Sub
The actual play/stop actions are simply audioTracks(trackID).Play() and Stop() calls.
However, when I run this, the audioTracks(trackID) = New DXAV.Audio(soundFullName) fails because:
DLL 'C:\..dahdahdah..\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock.
I've seen LoaderLocks when using multi-threaded apps with calls to Me.Controls but my app is single-threaded.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
I am working on windows explorer style appliction.I have build the treeview and now what I want is that when user click on the treeview node it should get the information for that selected criteria and bound that data with the textboxes on right hand side?
How I can do this?Do I need to use class for this to select,update and insert data?
Thanks In advance.
Ejaz
|
|
|
|
|
Have you tried to solve the problem yourself?
I suggest that you go ahead and write some code. Google will throw up plenty of resources on treeview programming. If you have done that and are still experiencing difficulties, post again.
Paul
|
|
|
|
|
Thanks paul for ur reply.I tried to search on the net first and then I post my problem here.My treeview is working fine.Now I just want to know that how I can display the data on the base of treeview node selection.Either I need to run query every time to get the data from database on node selection or is this possible by storing the data in class and then just filter the data from class.
Any Idea how to store the data and then filter by providing criteria.
Thanks In advance
Ejaz
|
|
|
|
|
Handle the AfterSelect event to respond to node selection. The TreeViewEventArgs object supplied to the event handler has a Node property which will give you a reference to the selected node.
The TreeNode class exposes a Tag property which allows you to store any object data. You could consider creating your own data class to hold your associated and storing an object instance of it in this property for each node. It depends on how much data you need to associate with each node and how many items you are displaying in your TreeView. If the items/data are few, using the Tag property seems a good way to go. If the items/data are many, you may have to consider fetching the associated data from the database when a node is selected.
Regards
Paul
|
|
|
|
|
Hi,
Anyone know the code for a program to determine the screen size res etc so it can adjust the form size in runtime to fill the screen. Searching is not coming up with the goodies..
Thanks Heaps in advance.
|
|
|
|
|
The Screens class has all you need, but you can just maximise. Or are you worried about getting your form to lay itself out for the screen ? Then the anchor and dock properties of your controls are what you need.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Once again Christian your help has been most valuable
Many thanks
Frank
|
|
|
|
|
Dear All
I need your direction how to say an amount in words in visual absic.net program language, for the detail I will give an ilustration as follow:
I would like my program can automatically write 1,000,000.00 to be "one million and zero cent" in words.
Could any body from can help me ho to do that
Thank you for your help in advance
Best regards
ICE
|
|
|
|
|
That's the ubiquitous homework assignment. All you have to do is type "convert number to words" into Yahoo or Google and you'll come up with millions of hits.
|
|
|
|
|
Dave Kreskowiak wrote: ubiquitous homework assignment
I remember those kind of assignments from a long, long, long time ago
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
This is a common homework problem, I'm sure there's code to be found to do it. Essentially, you just parse the parts of the number and build your text representation of it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Here's something i found, might help you.
<br />
=SpellNumber(32.50)<br />
<br />
<br />
Option Explicit<br />
<br />
'****************<br />
' Main Function *<br />
'****************<br />
Function SpellNumber(ByVal MyNumber)<br />
Dim Dollars, Cents, Temp<br />
Dim DecimalPlace, Count<br />
<br />
ReDim Place(9) As String<br />
Place(2) = " Thousand "<br />
Place(3) = " Million "<br />
Place(4) = " Billion "<br />
Place(5) = " Trillion "<br />
<br />
' String representation of amount<br />
MyNumber = Trim(Str(MyNumber))<br />
<br />
' Position of decimal place 0 if none<br />
DecimalPlace = InStr(MyNumber, ".")<br />
'Convert cents and set MyNumber to dollar amount<br />
If DecimalPlace > 0 Then<br />
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))<br />
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))<br />
End If<br />
<br />
Count = 1<br />
Do While MyNumber <> ""<br />
Temp = GetHundreds(Right(MyNumber, 3))<br />
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars<br />
If Len(MyNumber) > 3 Then<br />
MyNumber = Left(MyNumber, Len(MyNumber) - 3)<br />
Else<br />
MyNumber = ""<br />
End If<br />
Count = Count + 1<br />
Loop<br />
<br />
Select Case Dollars<br />
Case ""<br />
Dollars = "No Dollars"<br />
Case "One"<br />
Dollars = "One Dollar"<br />
Case Else<br />
Dollars = Dollars & " Dollars"<br />
End Select<br />
<br />
Select Case Cents<br />
Case ""<br />
Cents = " and No Cents"<br />
Case "One"<br />
Cents = " and One Cent"<br />
Case Else<br />
Cents = " and " & Cents & " Cents"<br />
End Select<br />
<br />
SpellNumber = Dollars & Cents<br />
End Function<br />
<br />
'*******************************************<br />
' Converts a number from 100-999 into text *<br />
'*******************************************<br />
Function GetHundreds(ByVal MyNumber)<br />
Dim Result As String<br />
<br />
If Val(MyNumber) = 0 Then Exit Function<br />
MyNumber = Right("000" & MyNumber, 3)<br />
<br />
'Convert the hundreds place<br />
If Mid(MyNumber, 1, 1) <> "0" Then<br />
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "<br />
End If<br />
<br />
'Convert the tens and ones place<br />
If Mid(MyNumber, 2, 1) <> "0" Then<br />
Result = Result & GetTens(Mid(MyNumber, 2))<br />
Else<br />
Result = Result & GetDigit(Mid(MyNumber, 3))<br />
End If<br />
<br />
GetHundreds = Result<br />
End Function<br />
|
|
|
|
|
Wow. I'm unimpressed. You've managed to do all of his work for him, for an obvious homewrok assignment. Congratulations on helping him fail the class.
|
|
|
|
|
Sorry, I didn't mean it.All i wanted to do was help him...
|
|
|
|
|
The most valuable skill you can have as a developer is to know how to do your own research. You absolutely must be able to find out anything you need to to teach yourself anything from new techniques to entirely new technologies. Without that ability, you'd last about a year in a career writing code, if not any computer career.
There are three points to be made with every programming project in a class.
1. How do you logically break the problem down into smaller and smaller parts and code solutions to those small problems that work together.
2. How you manage your time to accomplish the task in the given time frame.
3. And how you do the research to teach yourself about the parts you're stuck on. This includes books, internet search engines and sites, and asking for help from appropriate resources by asking the proper questions.
Showing up on a site and asking for someone to hand over the entire source code is NOT the proper question. It just bypasses the other two points completely.
He really didn't ask for the source code, but he couldn't do point number 1 either. The answer he got pointed him in the correct direction to start doing his own research into the problem.
|
|
|
|
|
Thank you for your attention and your direction to me, I will trying to use of your valuable inforamtion
Thank you
ICE
|
|
|
|