|
Hi there i am trying to create a volume control for my mp3 player threw vb.net but seems that i can't find threw the internet i tried to check on here but i don't seem to see any can anyone help me here
Thank you
|
|
|
|
|
What do you want exactly ? A program to set the volume on your computer ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i want a volume control that allows me to mute the mastervolume and control the volume without useing sndvol32.exe its threw vb.net
got any thing that will help
|
|
|
|
|
Never mind about it i created one of my own thanks anyway
|
|
|
|
|
vb.net /framework 1.1
i am printing a string in printpage-event like this:
e.graphics.drawstring(mystring, myfont, mybrush, myrectangleF, new stringformat()) most times the string is so long that it doesn't fit into myrectangleF. how can i find out how many characters of mystring have been already printed into this rectangleF?
|
|
|
|
|
I think the only way to do this, is using a monospace font
like for instance 'Courier New'. Here every character uses
the same pixel width & height, so that you can predict your
Rectangle using the stringlength.
But probably you don't want to use a monospace font?
|
|
|
|
|
no, i don't want to use monospace font.
|
|
|
|
|
What you need to do is use the Graphics object method: MeasureString() to know what the width/height is of your text.
You can specify the maximum width you want the text to extend to and the method will adjust the height accordingly.
Hope it helps!
Richard
may your code be error free.
(okay, maybe two lines.)
|
|
|
|
|
thanks richard. but i think i can't solve my problem like this.
sure, i could easily find out the height of my complete text ( i alreday did that), bit i thinks that doesn't help.
let me explain, what i want to do:
in my app i need to print data:
name & address & some other information (no problem so far)
some description (which varies in length between nothing at all to some pages (taken from a memo-column in my underlying database)
for drawing this description i use the space (as rectangleF), that is left on the page after printing the other stuff like name/address/and so on.
but if the description is longer than the space still available, i have to find out which part of the description did already fit on the page, and what part of that string is left to print on the following page/pages.
i can't figure out a possibility to come to a result with graphics.measurestring. maybe i need to strip down the text line by line, but i tried this earlier and didn't like it at all.
|
|
|
|
|
I see what your getting at now. I did some digging and found that an overload on MeasureString() will output the characters fitted, which should be just what you need!
I've create an example on how to use this feature. Originally I was going to write all of the code in a button handler but it got a little messy. I ended up writing a light wieght class called "StringGenerator" that you can customize. To try this sample, perform the following steps:
1. Create a new class called "StringGenerator" and insert the code below marked: // <<<< StringGenerator Code >>>>>>
1. create a blank form and set it to be the startup form
2. add a button with it's position set to: x=5,y=5
3. double click on the button to generate an event handler.
4. Insert the code snippet below:
'begin code snippet
Dim g As Graphics = Me.CreateGraphics()
Dim sf As StringFormat = New StringFormat()
Dim intY As Integer = 20
Dim originalText As String = "This is very boring text but I don't look at what the text says, I just look at what results the text will bring."
Dim stringG As New MyClasses.StringGenerator( _
originalText, g, Me.Font, New RectangleF(80, intY, 60, 50), sf)
stringG.DrawCurrentString()
While (stringG.HasMoreCharsToDraw)
intY += 60 'in this sample, 60 creates a 10 px padding
stringG.SetNewBounds(New RectangleF(80, intY, 60, 50))
stringG.DrawCurrentString()
End While
'cleanup
g.Dispose()
sf.Dispose()
'End code snippet
Note:This code is still very primitive but it will definitely get you started. If you step through the code, you won't see any output. Remove all the breakpoints to see the dynamically generated graphics. Let me know how it turns out!
' <<<< StringGenerator Code >>>>>>
'insert into -> EMPTY <- class file!
Namespace MyClasses
Public Class StringGenerator
Dim g As Graphics
Dim rectF As RectangleF
Dim sf As StringFormat
Dim fnt As Font
Dim chars() As Char
Dim startIndex As Int32
Dim charsFitted As Int32
Dim linesFilled As Int32
Dim strDisplayText As String
Dim strCurText As String
Dim blnHasMoreChars As Boolean
Public blnClipToNearestWord As Boolean = True
Public Sub New(ByVal text As String, ByRef graphics As Graphics, ByRef font As Font, ByRef rectStartingBounds As RectangleF, ByRef stringFormat As StringFormat)
chars = text.ToCharArray()
rectF = rectStartingBounds
strCurText = text
g = graphics
fnt = font
'set blnHasMoreChars to an initial value of true;
blnHasMoreChars = True
End Sub
Public Sub DrawCurrentString()
MeasureMyCharacters()
'you can write your own custom code here, such as
'allowing a different color input. Don't allow a
'different font because it will mess you measurements up!
g.DrawRectangle(Pens.Red, Rectangle.Round(rectF))
g.DrawString(strDisplayText, fnt, Brushes.Black, rectF, sf)
End Sub
Public Sub SetNewBounds(ByVal rectFBounds As RectangleF)
rectF = rectFBounds
End Sub
Private Sub MeasureMyCharacters()
'This method takes 'strCurText' and measures it with the
'bounds supplied. MeasureString() returns a SizeF object
'but we are only interested in the output generated by the
' 'charsFitted' variable.
g.MeasureString(strCurText, fnt, rectF.Size, sf, charsFitted, linesFilled)
'If amount of chars fitted in rectF is less than
'the number of characters remaining to fit...
If (charsFitted < strCurText.Length - 1) Then
'do we want to clip to the nearest word?
If (blnClipToNearestWord) Then
'we will now loop backwards to find the first
'occurrence of a character separation: " "
For i As Integer = charsFitted + startIndex To 0 Step -1
If chars(i) = " " Then 'is the char a space?
'reduce the amount of characters fitted
'to the first word occurrence
charsFitted = (i - startIndex) + 1
i = -1 'terminate the loop
End If
Next
End If
blnHasMoreChars = True
Else
blnHasMoreChars = False
End If
'create the display contents
strDisplayText = New String(chars, startIndex, (charsFitted))
startIndex = (charsFitted + startIndex)
'assign strCurText the chars remaining to print
strCurText = New String(chars, startIndex, (chars.Length - startIndex))
End Sub
Public Function HasMoreCharsToDraw() As Boolean
HasMoreCharsToDraw = blnHasMoreChars
End Function
End Class
End Namespace
may your code be error free.
(okay, maybe two lines.)
modified on Thursday, February 7, 2008 5:20 PM
|
|
|
|
|
sorry that i come back with an answer that late. have been off for the last days.
thanks for the string generator code (and special thanks for converting it to vb.net - i just wanted to start to do it myself, when i spotted your message modification).
i integrated it to my printing routine, and it worked great. only very little modifications where necessary to make it suit to my needs.
thanks a lot.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Glad to help. Maybe one day you'll pull me out of a fix!
If you could rent a programmer a hour and a half for a dollar and a half, how much would he charge for 10 hours?
|
|
|
|
|
I want to know how to get the files byte codes encrypt them and also able to decrypt
I intent to use a simple encryption algo the XOR operation
But i dun even know how to do it where do i store the files values to and how do i make sure the file gets encrypted.
|
|
|
|
|
Quit re-posting this crap all over the forums. You have gotten answeres in your previous posts. Look at the links provided. You can also use Google to find examples on how to do it. As a developer you need to learn to do research on your own.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
I keep asking questions till they get answered. Bub!!!
|
|
|
|
|
Way to wait 7 minutes between duplicate posts.
duo!@# wrote: I keep asking questions till they get answered. Bub!!!
You mean that you keep asking questions until someone does the work for you. You have been given many suitable suggestions that would get you started on the path of doing it yourself. However, you are too freaking lazy to do it on your own. Part of being a developer is being able to do research, and then applying what you learned to your project. You however, are just asking questions until someone does it for you. Lazy ass.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
In my post did i ask for someone to type out the code for me.Hmmm... let me see NO!!!. Your a real dumb guy. Of course no ones gonna do the code for me. I just asked for simple guide lines to me help out. And one more thing "what u think is not what u think" Bub!!!...
And quite interpreting my posts wrongly. If u can't help buzz off.
|
|
|
|
|
duo!@# wrote: n my post did i ask for someone to type out the code for me.
In your first thread about this question, you give specific instructions on where the code should go and what it should do, but no effort on your side to write any of it.
duo!@# wrote: I just asked for simple guide lines to me help out.
Asking the same question over and over, disregardning the suggestions that you actually get, is not a method that is likely to succeed.
duo!@# wrote: If u can't help buzz off.
Rudeness is a method that is even less likely to work.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
This is a community of people who offer help freely. You are pretty much doing exactly what I'd recommend someone do, if they never want to be given any free help. If you want to talk to people like this, there are sites where you can pay people for their help, you may be able to get away with this sort of attitude there.
I see two questions, in a short space of time, both of which show that what you really need is to learn how to use google. If you want free help, you need to wait for it. Asking twice like that decreases the odds of people helping you, because you're polluting our forums with double posts of the same question. If we can see the second time you asked, we can also see the first, so what's the point ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
duo!@# wrote: In my post did i ask for someone to type out the code for me
No, you didn't. However, you have posted the same question, 4 times. Again, You need to learn to use google, like real developers do to research their projects. You are completely rude, you think that your problem is more important than everyone else’s. You kept bumping your thread to get it to the top as to attract attention. You had been given multiple answers to the first 2 posts, however, you still kept posting the same question. Just plugging in the answers you received here into Google would have given you a full explanation of the who, what, where, when, and why.
You don't need to say you want someone to write code for you, when you exhibit the above type of behavior. It is completely obvious to everyone here. You expect to get answers to your questions, with full, commented, compilable code. And judging by your behavior, I bet it is urgent.
duo!@# wrote: Your You're a real really dumb guy.
There you go, I'll do a little "peer editing" for you. Well, I can't really call you a peer, because we aren't equals. You aren't a developer, you are a code monkey. Begging for answers and code, expecting someone to do your work? I'm dumb, huh? After the behavior you have shown, and the lack of ability to implement such a simple concept, I'm dumb?
duo!@# wrote: Of course no ones gonna do the code for me. I just asked for simple guide lines to me help out.
You sure seem to be hoping someone will. Why else would you re-post, 4 times? Two of those within 7 minutes. It's because you are lazy, unintelligent, and impatient. You got your "simple guidelines," but they didn't cater to your inability to think for yourself, so you decided to keep asking until someone would write the code for you.
duo!@# wrote: And one more thing "what u think is not what u think" Bub!!!...
Ok...?
duo!@# wrote: And quite interpreting my posts wrongly.
I interpreted your post perfectly. I hit the nail right on the freaking head. It's obvious to everyone here, take a look at all the replies.
duo!@# wrote: If u can't help buzz off.
Okay, gladly. I'm not going to help someone so ungrateful and lazy. Oh yeah, good luck getting ANY help around here. We here at codeproject help for free, out of the kindness of our hearts. No one is going to help someone like you.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
You might as well as pull a stranger off the street and tell him to build you a house.
ROFLOLMFAO
|
|
|
|
|
Your profile will soon become platinum if are going to be that way.
Give a man a fish, he'll eat for a day. Teach a man how to fish, he'll eat for lifetime.
Pradeep Joe
|
|
|
|
|
We should also consider suggesting to CP Team to carve out a unique 'Hall of Fame' for mediocre people of this category.
There is already a good historic comparison of his feats here:
http://www.codeproject.com/script/Forums/View.aspx?fid=1159&msg=2418285[^]
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Hey Bub, at this rate you'll get sweet FA answered, change your attitude or take up gardening.
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
|
How do you make stuff grow ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|