|
Drag and Drop and Double click have nothing to do with each other. Remove the two Mouse handlers and you're code should work just fine.
|
|
|
|
|
I have a series of text boxes I want to add a popup menu to them. When someone right clicks on a text box, I want the popup menu to appear, then when they select an item I need to perform some action, based on which of the text boxes they were right clicking on.
My declaration
Private txtSlot() As System.Windows.Forms.TextBox
Then build the txtSlots:
Private Sub createTxtSlotArray()
Dim i As Short
ReDim txtSlot(10)
For i = 1 To 10
txtSlot(i) = New System.Windows.Forms.TextBox
With txtSlot(i)
.Tag = i
AddHandler .Click, AddressOf Me.txtSlot_Mouseclick
End With
Next
Me.Controls.AddRange(txtSlot)
then try to get it
Private Sub txtSlot_Mouseclick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click
Debug.Write("Clicked " & sender.tag()) 'for real I will set a global variable here so I know the ID
' what to do here to get popup? and make it pop up
?????
End Sub
I thought someting like
contextmenu1.Show (contextmenu1,????) ' where to I get pos (second parameter)?
Any help is appreciated
thanks
|
|
|
|
|
The position can be anything you want. If you want it to be where the mouse was clicked, you just have to get the mouse position from the event args in your mouse move handler (the e argument.)
|
|
|
|
|
but what would that be under the event args, nothing looks close
I am thinking I need to put a command such as:
ContextMenu1.show(control as system.windows.forms.control, pos as system.drawing.point)
Intellisense suggests nothing for the first parameter, and I am not sure what it is asking for. (the name of something?) I have no idea what to provide for the second parameter, or where to get the mouse position from.
modified on Friday, June 12, 2009 4:03 PM
|
|
|
|
|
Handle the MouseMove event, look in its event args, keep the values in a class scoped variable. Then, when the Click event happens, you've already got your position.
|
|
|
|
|
or read Control.MousePosition and turn them into relative coordinates using myControl.PointToClient().
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.
|
|
|
|
|
Doh!
Forgot about that one!
|
|
|
|
|
My code runs fine but the design view is messed up. That is, I can't edit the form, even though it displays fine at runtime. It may have been like this for a long time, so I'm having difficulty rewinding. Any thoughts about how I might recover? Here's the error that shows in the designer: Thanks
The path is not of a legal form.
Hide
at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck)
at System.IO.Path.GetFullPathInternal(String path)
at System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AddProjectDependencies(Project project)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchEntries(AssemblyName assemblyName, String typeName, Boolean ignoreCase, Assembly& assembly, ReferenceType refType)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.GetType(ITypeResolutionService trs, String name, Dictionary`2 names)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.FillStatementTable(IDesignerSerializationManager manager, IDictionary table, Dictionary`2 names, CodeStatementCollection statements, String className)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)
|
|
|
|
|
I should also say that doing the obvious things like copying the 3 form files from an older save which does run OK doesn't work. Also completely recreating the form by copying the code and copying the controls again creates the same error. Ouch
|
|
|
|
|
cstrader232 wrote: Also completely recreating the form by copying the code and copying the controls again creates the same error.
Of course it did. You copied what is creating the error, so why would the result be any different? The problem appears to be in the designed generated code somewhere. I can't really tell you where that would be since we know nothing of the code, what it looks like, or on which line the error occurs.
|
|
|
|
|
i have just passed my high school
i am about to start college
so i thought to learn c++
i have read the basic concepts and mastered them
i wanna do some serious programming
i have got some ideas too
i was wondering whether i should do programming in vc++ 2008 or in c++?
in terms of speed,cpu usage , memory taken
oh! I forgot! I know vb quite well
TheMrProgrammer
|
|
|
|
|
vc++ 2008 is an IDE, you can use c++.net or c++, C++ is always faster then a .net language and gives you more flexability, while the .net framework saves an incredible amount of time for typing as everything is basically at your fingertips.
It all depends on what you want to do really.
|
|
|
|
|
You asked about C++ here because you know VB ?
VB.NET and C# are essentially the same thing, and I'd expect more people want .NET than C++, in the windows world at least. You can call any C++ API from C# via interop, so it's unlikely that C# will hit any brick walls for you, unless you want to write games. I would say focus on being good at whatever language your course teaches, and then go from there.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I think what the other replies you have had to your question have failed to take into account, is the type of projects you are working on.
The type of project may determine the best language, for example the .NET languages are only really suitable for Windows based programs.
If you indent to write programs for embedding into other devices or Unix type systems, then C++ would be a better choice.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I have a solitaire game and got drag and drop to work. The thing is the random cards display every other card with a different backing to simulate the back of the card. I would like the player that when they move or click the backed card, it turns over to it's original card. Here's an example of my code: Note I set 001h as an example to test.
Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Image1(Index).Drag vbBeginDrag
End Sub
Private Sub Image1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, _
X As Single, Y As Single)
If Image1(Index).Picture = LoadPicture("C:\Program1\Back.gif") Then
Image1(Index).Picture = LoadPicture("C:\Program1\001h.gif")
MsgBox ("ok")
End If
End Sub
|
|
|
|
|
You didn't ask a question.
|
|
|
|
|
I want to know how to flip the cards with backing.gif over to the original card in the random pile. I have one face up, the next one face down, etc.
|
|
|
|
|
Okay. So wouldn't that mean you have a card with the back image and when you want it to flip you show the front image?
|
|
|
|
|
The card with the back image is from the loadpicture("aaaa.gif")
but the original picture bitmap formed in design view is the suit card.
|
|
|
|
|
You'd have to draw each frame the animation yourself. That's all it is. A series of still images that give the illusion of flipping a card.
|
|
|
|
|
Trying to understand completely what you are saying:
Basically, I have random cards of all suits on the left of the form. Each other card has a back.gif to show the back of the card. Each card is in an array of 52 cards. When a user clicks the backing card, I want the let's say queen of hearts to show up, hence image1(12), that picture; before they drag the card.
I tried this with If image1(index).picture = loadpicture("C:\backing.gif") Then
image1(12).picture = loadpicture("C:\queenhearts.gif")
and so forth; I would write all the images and set them to the correct gifs. At runtime, nothing worked when I clicked those cards....
I even thought of trying image1_click(Index As Integer), but that didn't work either.
Any ideas on how to within the same routine, to turn the cards or set them to the proper gif when the user clicks on them? Seems so simple, but I'm still confused.
|
|
|
|
|
In a card game I would keep all cards in memory, rather than reading them from disk every time.
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.
|
|
|
|
|
and pardon my less knowledge, but how would you do this?
|
|
|
|
|
Start a collection of images (array, List, Dictionary, ...) and load it using Image.FromStream at the start of the app.
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 already have an array of images in design view; it would be redundant to load them, wouldn't it?
|
|
|
|
|