|
I would have suggested the same, but the fact that the DLL's function is executing and returning a value (an HRESULT, to be exact) means P/Invoke is managing to bind the function correctly. Yeah, it's not the greatest practice, but it works...
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
Hello!
I am writing a button generator application in where you type in a number within a text box and click the generate button in where it will randomly create buttons in different locations within the application.
I am also trying to make it so that an action is performed when i click these buttons, but i cant figure out how to do it. Here is my code so far.
FORM CODE:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim newInstance As New myButton
End Sub
End Class
BUTTON CODE:
Public Class myButton
Public Sub New()
Dim newButton As New Windows.Forms.Button
Form1.Controls.Add(newButton)
End Sub
Friend WithEvents newButton As Windows.Forms.Button
Public Sub mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles newButton.Click
MsgBox("hi")
End Sub
End Class
As you can see from the code, it should show a message box when each instance of a button gets clicked, but its not working. I'm not sure if im doing this the right way or not, can someone please help me with this because i cannot find anything on the internet about it.
Thankyou.
|
|
|
|
|
Hi,
in your code
[1] Public Class myButton
[2] Public Sub New()
[3] Dim newButton As New Windows.Forms.Button
[4] Form1.Controls.Add(newButton)
[5] End Sub
[6] Friend WithEvents newButton As Windows.Forms.Button
[7] Public Sub mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles newButton.Click
[8] MsgBox("hi")
[9] End Sub
[10] End Class
Class myButton represents a button, i.e. ONE button, however I see two declarations: lines [3] and [6].
The "Handles newButton.Click" in [7] refers to the newButton in [6] which is and remains Nothing.
The New Button in [3] ends up in the local variable newButton, which you add to the Form, but which is unrelated to the one in [6].
The solution should be obvious.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks for the help, i've got it working now!
Sorry if that seemed a stupid question
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I was trying to build a program to clean temp, unwanted, junk files from applications like chat clients, browsers, p2p applications, on windows platform. Can anyone please provide some guidance on how to proceed.
|
|
|
|
|
1) Find the folder
2) Delete the files
What more do you want?
only two letters away from being an asset
|
|
|
|
|
Hi,
1. use Directory.GetFiles();
2. use File.Delete();
3. do not use Process.Start("cmd.exe", "/C del *.*");
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: 3. do not use Process.Start("cmd.exe", "/C del *.*");
How about Process.Start("cmd.exe", "/c format c: /fs:ntfs") ?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Sorry, I forgot that one. I think it belongs in the "do not use" category.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: I think it belongs in the "do not use" category.
You only think that. We'll leave that in the toolbox, and let the OP try it out if he can't come up with any alternative; as long as he lets me know what his application is called so I can avoid downloading it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I would like to be able to join math variables. What I mean with this is that, for example, the following can be joined (I don't know if this is actually called joining):
2x^2 - 5x^2 + 2x + 3x - 5 + 6
join to (is equal to):
-3x^2 + 5x + 1
Is there a library or does someone have a code snippet for such actions? If you have a hint or an easy trick, also please tell me. Thanks.
|
|
|
|
|
The process you're talking about is called simplifying. I would assume it's done by going through each element (where element 0 is 2x2, element 1 is -5x2, etc) and making a note of each unique index (the power). When you encounter an index that's occurred before, add the current element to the unique element that's got the matching index and move on.
After that you just need to display it. With this, you just iterate through the list of unique elements and print them.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks very much for your suggestion. It's a great idea of performing the action, however, I tried using Regex to make an ordered list (array) of all items:
+2x^2
-5x^2
etc.
The expression is ([+-])(.*)x\^2
It works well, but now I have to simplify them - I will try doing so.
|
|
|
|
|
Just a note regarding your Regex. You're assuming that the letter following the number is always x, that there is only one such letter, and that the power it's raised to is always 2. If you move on to more advanced equations, like 2xy<sup>4</sup> - 3x + 4xy<sup>4</sup> , then you'll have to alter it.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
You're completely right. However, I am just creating a small application for the so-called abc-formula, and you just enter the formula instead of only a, b and c in most tutorials (then you have to calculate yourself anyway). It only works with quadratic formulas, therefore I have 3 static regex's (for x^2, x^1 and x^0; respectively a, b and c). It is going well by the way.
Thanks.
|
|
|
|
|
Hi All,
I am writing a small app that shows a dialog when its tray icon is clicked. The problem is, on Windows 7 the NotifyIcon does not appear at all. I checked both the normal tray and the hidden icons. It is not there. I also checked the visible property of the icon, both at designtime and runtime. Also, any balloon tips to be shown are not shown.
Any help in this matter would be appreciated.
Thanks.
~ Soumya92
|
|
|
|
|
Be sure you've assigned an icon to NotifyIcon component. Unlike Form s, there's no default icon for tray icons (so they won't show unless you've assigned one).
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
That was indeed the reason for my problem. Stupid of me not to see it.
~ Soumya92
|
|
|
|
|
I'm attempting to use managed code from unmanaged code using clr hosting.
This works fine but I'm having trouble creating one specific type.
I've gleaned the following values from the HResult, but can't find out exactly what the error code means.
Can anyone help?
hresult = -2146232828
severity = 1
facility = 19
error code = 5636
Thanks in advance!
M.
|
|
|
|
|
You seem to be getting a COR_E_TARGETINVOCATION exception. It's not a well documented exception; have a read of this[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks for the answer...that was the problem.
Some dependent assemblies were missing from the GAC.
|
|
|
|
|
foxymop wrote: Thanks for the answer
No problem. I'll tell you how I figured it out, so you know what to do next time - I converted the error code into hex using Windows calculator - enter the value in decimal, convert it into decimal and change it to a DWord. I searched for the HResult of that value, in corerror.h. From that point, it was easy to google on the "friendly" name and identify issues with it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks. I had been wondering how you achieved it, as I once created a tool that calls FormatMessage(), however it did return null/nada/Nothing for this error code.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Guys,
I've got two config files for a winforms app:
app.release.config
app.debug.config
I copy these into the appropriate folders using the following post build event:
if $(ConfigurationName) == Debug copy "$(ProjectDir)app.debug.config" "$(TargetPath).config"
if $(ConfigurationName) == Debug copy "$(ProjectDir)app.debug.config" "$(TargetDir)$(TargetName).vshost.exe.config"
if $(ConfigurationName) == Release copy "$(ProjectDir)app.release.config" "$(TargetPath).config"
if $(ConfigurationName) == Release copy "$(ProjectDir)app.release.config" "$(TargetDir)$(TargetName).vshost.exe.config"
This works if i only build the project, but if i run the project as well, then the files are replaced by the origional app.config.
If i change it to overwrite the app.config file (Either pre / post build):
if $(ConfigurationName) == Debug copy "$(ProjectDir)app.debug.config" "$(ProjectDir)app.config"
if $(ConfigurationName) == Release copy "$(ProjectDir)app.release.config" "$(ProjectDir)app.config"
Then it overwrites the app.config file fine, but doesn't actually copy it to the output directory.
Any thoughts? This should be a common problem that's got a solution right? It's driving me crazy
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
modified on Friday, August 14, 2009 6:17 AM
|
|
|
|