|
I created a control array (for slots)
Private Sub createlblSlotArray()
Dim i As Short
ReDim lblSlot(3)
For i = 1 To 3
lblSlot(i) = New System.Windows.Forms.Label
With lblSlot(i)
.Tag = i
.BackColor = System.Drawing.Color.Blue
.BorderStyle = BorderStyle.Fixed3D
AddHandler .MouseUp, AddressOf Me.Label1_MouseUp
End With
Next
Me.Controls.AddRange(lblSlot)
lblSlot(1).Location = New System.Drawing.Point(50, 50)
lblSlot(2).Location = New System.Drawing.Point(100, 70)
lblSlot(3).Location = New System.Drawing.Point(100, 90)
End Sub
I have an event to handle it
Private Sub Label1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = MouseButtons.Right Then
ContextMenu1.Show(sender, New Point(e.X, e.Y))
End If
End Sub
All is perfect with the world, except one little thing. When I click on the form itself, I get the popup. Why do I get it on the form, how can I prevent this?
No-e
|
|
|
|
|
Dunno, I copied your code into a test project and the ContextMenu is displayed when right clicking on the labels (I had to DirectCast(sender, Control) though). The menu is not displayed when clicking on the form.
There isn't a need to create a new question everytime for something you've already asked. You could have replied on your previous question since it is the same.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
huh?
Same question? Things change from vb6 to .net. I am trying to understand how things work. I tend to be a quick learner, but am just asking for help or a tip where to look when I do not understand something. This project was dropped in my lap and I have many other things to deal with.
last Q was why my mouse position was in an unexpected location. Thanks to Henry Minute, it saved me some time, perfect! that is all I ask, point me in a direction
should I not bother here? Am I asking unfair questions? Should I go away?
No-e
BTW, I found a way to address the problem. no thanks to your response. I am disappointed with your response, I thought CP members were a little more considerate. I am not a student asking you to do my homework.
|
|
|
|
|
Hmm, I recall a previous post related to a context menu and where it appeared the day before (and was appearing unexpectedly). Dunno, kinda seemed related to me.
Regardless, I'm sorry that I took time out of my day to create a test project with your code to find a possible error.
No need to apologize. I'll restrain from replying to any of your future posts.
Cheers!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I think it's better write this code:
Private Sub createlblSlotArray()
Dim i As Short
ReDim lblSlot(3)
For i = 1 To 3
lblSlot(i) = New System.Windows.Forms.Label
With lblSlot(i)
.Tag = i
.BackColor = System.Drawing.Color.Blue
.BorderStyle = BorderStyle.Fixed3D
.ContextMenu=ContexMenu1
End With
Next
Me.Controls.AddRange(lblSlot)
lblSlot(1).Location = New System.Drawing.Point(50, 50)
lblSlot(2).Location = New System.Drawing.Point(100, 70)
lblSlot(3).Location = New System.Drawing.Point(100, 90)
End Sub
bah10z
|
|
|
|
|
hi,
im new in vb.net
i did print using printdocument.
its perfectly working..
only drawback is nothing show in second page.
event also not occur.
plz help me...
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
Mail To : foreverkans@gmail.com
|
|
|
|
|
Hi,
Not sure I understood you correctly.
Anyway, in .NET you get one PrintPage event per page.
You have to set PrintPageEventArgs.HasMorePages true in order to get an event for the next page.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
ya i have put this event argument.
but page document page is counting morethan 100 pages...
i cant understand.. what s going on..
plz help me....
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
Mail To : foreverkans@gmail.com
|
|
|
|
|
Hello.
I am currently working on a project to extract data from a PDF document into structured database tables. I have solved the problem of extracti9g the text from a pdf into a text box in vb6 form by using a readymade dll component that I referenced in my program.
Now my problem is, how to extract only certain pieces of data from the text based on some keywords that appear in the text. for example in the pdf document:
Existing Chemical Substance ID: 50–00–0
CAS No. 50–00–0
EINECS Name formaldehyde
EINECS No. 200–001–8
Molecular Formula CH2O
I need to extract "50-00-0" that appears after the keyword "CAS No.", then
the text "formaldehyde" that appears after the keyword "EINECS Name" and "200-001-8" that comes after "EINECS No.". I have database table which contain these keywords as field names. What I want is the table to look like this:
Sno CAS No. EINECS Name EINECS No.
1 50–00–0 formaldehyde 200–001–8
I would really appreciate it if someone could point me towards the string manipulation functions that I would need to use i order to do this.
Also How to get count of a keyword if it appears multiple times between two other keywords.
Thanks and Regards,
Kumar
|
|
|
|
|
|
Dear Dave,
Thanks a lot for the suggestion.
I found just the perfect piece of code.
<br />
Public Function Extract(ByVal TextIN As String, Optional StartTag As String = " ", Optional ByVal EndTag As String = " ", Optional ByVal CheckCase As Boolean) As String<br />
On Error GoTo LocalError<br />
' Extracts Text from string using start and end "tags"<br />
'NB: If EndTag is ommitted the entire string from:<br />
' StartTag to EndOfString is returned...<br />
Dim lArray As Variant<br />
Extract = ""<br />
lArray = Split(TextIN, StartTag)<br />
If IsArray(lArray) Then<br />
Extract = lArray(1)<br />
lArray = Split(Extract, EndTag)<br />
If IsArray(lArray) Then<br />
Extract = lArray(0)<br />
Else<br />
Extract = ""<br />
End If<br />
End If<br />
Exit Function<br />
LocalError:<br />
Extract = ""<br />
End Function<br />
It works beautifully. Now, All I need to do is put all the keywords into a database and do a recursive search using those fields dynamically at runtime.
Thanks a million for your help.
Best Regards,
Kumar
|
|
|
|
|
kshincsk wrote: I found just the perfect piece of code.
Great. Yet another Copy'N'Paste programmer...
|
|
|
|
|
Hi,
i got a DSP function for a media player here. The problem is that it was made for VB 6 and uses "CopyMemory".
I read the article on "CopyMemory in .Net" here but the result i got isn't working :-S
This is the original code:
Public Sub SBVocalCut32(ByVal handle As Long, ByVal channel As Long, ByVal buffer As Long, ByVal length As Long, ByVal user As Long)<br />
Dim SBVocCut32Buf() As Single, SBVocCut32CSample As Long<br />
Dim SBVocCut32DM As Single<br />
ReDim SBVocCut32Buf(length / 2) As Single<br />
<br />
Call CopyMemory(SBVocCut32Buf(0), ByVal buffer, length)<br />
<br />
For SBVocCut32CSample = 0 To length / 2 - 1 Step 2<br />
SBVocCut32DM = ((0 - SBVocCut32Buf(SBVocCut32CSample)) + SBVocCut32Buf(SBVocCut32CSample + 1)) / 2<br />
SBVocCut32Buf(SBVocCut32CSample) = SBVocCut32DM<br />
SBVocCut32Buf(SBVocCut32CSample + 1) = SBVocCut32DM<br />
Next SBVocCut32CSample<br />
<br />
<br />
Call CopyMemory(ByVal buffer, SBVocCut32Buf(0), length)<br />
End Sub
Could anyone be so kind and help me out with the copymemory lines in here?
Thx!
|
|
|
|
|
Knight_Rider wrote: CopyMemory in .Net
which article, there are several here on CP.
Knight_Rider wrote: isn't working
that is really informative. Build problems? run-time problems? exceptions? what?
CopyMemory[^] seems to just copy some data in memory, something a simple for loop could do easily, provided source and destination do not overlap (if they do, the order must depend on the relative position).
Write your own copy loop and get done with it!
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi,
Equivalent of CopyMemory in .NET[^] This is the article i'm refering to
Yeah i tried that with the loop already:
For i As Integer = 0 To length / 2 - 1<br />
SBVocCut32Buf(i) = buffer.ToString(i)<br />
Next
and
<br />
For i As Integer = 0 To SBVocCut32Buf.Length - 1<br />
buffer += SBVocCut32Buf(i)<br />
Next<br />
But it doesn't work either because the song doesn't sound (-> Bass.NET Audio library) different after activating this function..
Thanks anyway!
BTW: There is an AccessViolationException when i use copymemory in .NET!
|
|
|
|
|
Hi,
that article is voted rather low, there is at least one that looks better.
Both these for loops stink; there is no ToString() and no += involved, just COPY data.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Well it seems i don't completely understand what copymemory does in this particular function:
This line: CopyMemory(SBVocCut32Buf(0), buffer, length) -
Will everything contained in the buffer variable be copied into SBVocCut32Buf(0)? Or is the length parameter indicating that SBVocCut32Buf will be filled as follows:
SBVocCut32Buf(0) = buffer
SBVocCut32Buf(1) = buffer
SBVocCut32Buf(2) = buffer
...? May you explain that, please? thanks ![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I don't know, I provided a link to some documentation, read that.
It sounds like the memcpy() function in C.
Maybe Array.Copy() is the .NET equivalent.
Whatever it is, it will take no more than two lines of code.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
This is what i got so far based on the arcticle... Maybe another person may help me?
Public Sub SBVocalCut32(ByVal handle As Long, ByVal channel As Long, ByVal buffer As Long, ByVal length As Long, ByVal user As Long)<br />
Dim SBVocCut32Buf() As Single, SBVocCut32CSample As Long<br />
Dim SBVocCut32DM As Single<br />
ReDim SBVocCut32Buf(length)<br />
<br />
Dim MyGC As GCHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned)<br />
Dim AddofLongValue As IntPtr = MyGC.AddrOfPinnedObject()<br />
<br />
Marshal.Copy(AddofLongValue, SBVocCut32Buf, 0, length)<br />
' Call CopyMemory(SBVocCut32Buf(0), buffer, length / 2)<br />
<br />
For SBVocCut32CSample = 0 To length / 2 - 1 Step 2<br />
SBVocCut32DM = ((0 - SBVocCut32Buf(SBVocCut32CSample)) + SBVocCut32Buf(SBVocCut32CSample + 1)) / 2<br />
SBVocCut32Buf(SBVocCut32CSample) = SBVocCut32DM<br />
SBVocCut32Buf(SBVocCut32CSample + 1) = SBVocCut32DM<br />
Next SBVocCut32CSample<br />
<br />
<br />
Marshal.Copy(SBVocCut32Buf, 0, AddofLongValue, length)<br />
'Call CopyMemory(buffer, SBVocCut32Buf(0), length / 2)<br />
End Sub
|
|
|
|
|
Luc Pattyn wrote: Write your own copy loop and get done with it!
I love it when you are masterful!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: I love it when you are masterful!
I thought as much.
No beating around the bush.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
i am having a control on a panel and their properties in the propertygrid .
How to identify the Ctrl + C in this method
Public Function PreFilterMessage(ByRef msg As Message) As Boolean Implements IMessageFilter.PreFilterMessage
Const WM_KEYDOWN As Integer = 256
If msg.Msg = WM_KEYDOWN Then
Dim keyCode As Keys = (CType(CType(msg.WParam, Integer), Keys) And Keys.KeyCode)
If pg.SelectedGridItem.PropertyDescriptor IsNot Nothing Then
If (pg.SelectedGridItem.PropertyDescriptor.DisplayName = "Picture" Or _
pg.SelectedGridItem.PropertyDescriptor.DisplayName = "BackgroundPicture" _
And Not keyCode = Keys.Delete And Not (keyCode = Keys.Control And keyCode = Keys.C) _
And Not (keyCode = Keys.Control And keyCode = Keys.V) _
And Not (keyCode = Keys.Control And keyCode = Keys.X) _
And Not (keyCode = Keys.Control And keyCode = Keys.A) _
And Not (keyCode = Keys.Control And keyCode = Keys.Z) _
And Not (keyCode = Keys.Control And keyCode = Keys.Y)) Then
Return True
End If
End If
End If
Return False
End Function
what i am doing is i am blocking keyboard characters and only Delete button i am allowing in the propertygrid for picture Property .
When Ctrl C , or ctrl v or ctrl x or ctrl y or ctrl z is pressed i have to work on the control to copy ,paste etc if the the propertygrid.selecteditem is picture also how can i achieve this one ??
|
|
|
|
|
|
|
Its a programming language. It comes in two flavours - legacy and normal. Legacy is obsolete, so I won't go into it here. Normal uses the .net framework, documentation for which is available on MSDN. It's easy to read, and is the beginners' language of choice (unless you like the elegant, flowing symbols of C#)
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|