|
Hey,
I receive always following error :
{"Could not bind to the new value member.\r\nParameter name: value" }
System.ArgumentException
I don't find the problem in my source. Can someone have a look to it.
I use the property "Omschrijving" for the displaymember and that is not a problem. Why I have a problem with the property Id? I also check the whole array and there are no null-values in Id.
tkx,
Jac
My code :
..
this.Cmb01.DataSource = Codes.Splitsingen.Items;
this.Cmb01.DisplayMember = "Omschrijving";
this.Cmb01.ValueMember = "Id";
..
In an other class :
public class Splitsingen
{
public static Splitsing Jaarlijks = new Splitsing (1,"1",1,12,"Jaarlijks","Annuel","Yearly");
public static Splitsing Halfjaarlijks = new Splitsing (2,"2",2,6,"Halfjaarlijks","Semestriel","6months");
public static Splitsing[] Items = new Splitsing[5]{Jaarlijks,Halfjaarlijks,Trimestrieel,Maandelijks,Eenmalig};
}
public class Splitsing : CodeX
{
public int AantalPeriodesPerJaar;
public int AantalMaandenPerPeriode;
internal Splitsing(int id, string code, int aantalPeriodesPerJaar, int aantalMaandenPerPeriode, string omschrijvingN, string omschrijvingF, string omschrijvingE) : base(id, code, omschrijvingN, omschrijvingF, omschrijvingE)
{
AantalPeriodesPerJaar = aantalPeriodesPerJaar;
AantalMaandenPerPeriode = aantalMaandenPerPeriode;
}
public Splitsing()
{
}
}
public abstract class CodeX
{
public int Id;
private string OmschrijvingN;
public string Code;
public CodeX()
{
}
internal CodeX(int id, string code, string omschrijvingN)
{
Id = id;
Code = code;
OmschrijvingN = omschrijvingN;
}
public string Omschrijving
{
get
{
if (OmgevingParameter.Taal == Talen.Ned)
{
return OmschrijvingN;
}
}
set
{
}
}
}
|
|
|
|
|
Id in your code is not property - it's a field. Data-binding against properties on objects uses the PropertyManager , which binds against properties. Make Id a property and that should work for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am writing a textbox validator control
how would I check to see if the person presses the backspace button and the delete button and then tell windows not to process those messages as I will do it all myself
------------------
I'm naked under my clothes...
|
|
|
|
|
Simple. Just handle the KeyDown event. Check the KeyCode that is passed to you on the KeyEventArgs for Keys.Delete or Keys.Back . If those are set, set Handled to true :
myTextBox.KeyDown += new KeyEventHandler(myTextbox_KeyDown);
private void myTextBox_KeyDown(object sender, KeyEventArgs e)
{
e.Handled = (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete);
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
is it possible to have a managed c++ class that inherits from an unmanaged c++ class? if so, how would i do that?
|
|
|
|
|
|
sorry. i meant c# class that inherits from unmanaged c++. is there a way to accomplish this?
|
|
|
|
|
No. You would have to encapsulate this unmanaged C++ class in a managed class. The easiest way would be to create a mixed mode Managed C++ assembly that encapsulates this in a managed class, then extend that from C#.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
easiest way would be to create a mixed mode Managed C++ assembly that encapsulates this in a managed class
ok. can you point me to some info about that?
thanks.
|
|
|
|
|
Um, try the .NET Framework SDK. You did install that with Visual Studio .NET or with the .NET Framework SDK download, did you not?
Specifically, see Managed Extensions for C++ Programming[^] in the VS.NET product documentation.
Most importantly, remember that the managed code has the same access to .NET assemblies (including the base class library) that every other .NET language. That's the whole point of language interoperability.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey,
I'd like to develop some open source software for the public mainly for gaming. I would like to take mouse input and convert it so that the computer will assume it as a keystoke.
For example on an intellimouse which has 5buttons if the middle mouse button is pressed i would like to fire say a Keystroke p.
The old microsoft software allowed you to do this, the new ones do not, and hence here i am
Atul
|
|
|
|
|
Do a search on hooks (intercepting the mouse input at a system wide low level) and the SendInput call (simulating a keyboard press).
Both of these things are low level and not represented in the framwork classes, so you'll have to do some interop to get this stuff done in C#.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Good Luck!
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
Update:
part of the solution[^]
the answer was under my nose
this is part of the solution just need to stick a gui on and work out how to fire a keyboard event and i'm nearly there
Hopefully all gamers can use this who have 5 button mice and no software
once i'm finished i'll stick the source up on here
|
|
|
|
|
SendInput is the Win32 function you want to use for this. It can be used to simulate keyboard and mouse actually. You'll definitely need to use interop to make the calls from C#.
I've played around with using it to simulate mouse calls, and it's worked fine in other DirectX games (at the time I was trying to do a little macroing in a popular MMORPG).
If you run into any problems, let me know.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
as.thakor@ntlworld.com
could i speak to you by email direct ?
it would be greatly appreciated
Thanks
Atul
|
|
|
|
|
Here's a chunk of code I wrote. This class was basically being hosted by remoting (thus the MarshalByRefObject), but it moves the mouse where you want it. It shows how to interop with SendInput (importing the definition and defining a few structures you'll need).
<div style="font-family:Courier New;font-size:10pt;background-color:#FFFFFF" >
<span style="color:#0000FF;">using </span><span style="color:#000000;">System;<br>
</span><span style="color:#0000FF;">using </span><span style="color:#000000;">System.Runtime.InteropServices;<br>
<br>
<br>
[StructLayout(LayoutKind.Explicit, Size=28)]<br>
</span><span style="color:#0000FF;">public struct </span><span style="color:#000000;">Input<br>
{<br>
[FieldOffset (0)]<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">type;<br>
[FieldOffset (4)]<br>
</span><span style="color:#0000FF;">public </span><span style="color:#000000;">MouseInput mi;<br>
[FieldOffset (4)]<br>
</span><span style="color:#0000FF;">public </span><span style="color:#000000;">KeyboardInput ki;<br>
[FieldOffset (4)]<br>
</span><span style="color:#0000FF;">public </span><span style="color:#000000;">HardwareInput hi;<br>
<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">INPUT_MOUSE = 0;<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">INPUT_KEYBOARD = 1;<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">INPUT_HARDWARE = 2;<br>
}<br>
<br>
[StructLayout(LayoutKind.Sequential, Size=24)]<br>
</span><span style="color:#0000FF;">public struct </span><span style="color:#000000;">MouseInput<br>
{<br>
</span><span style="color:#0000FF;">public int </span><span style="color:#000000;">dx;<br>
</span><span style="color:#0000FF;">public int </span><span style="color:#000000;">dy;<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">mouseData;<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">dwFlags;<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">time;<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">dwExtraInfo;<br>
<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_MOVE = 0x0001; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_LEFTDOWN = 0x0002; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_LEFTUP = 0x0004; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_RIGHTDOWN = 0x0008; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_RIGHTUP = 0x0010; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_MIDDLEDOWN = 0x0020; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_MIDDLEUP = 0x0040; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_XDOWN = 0x0080; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_XUP = 0x0100; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_WHEEL = 0x0800; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_VIRTUALDESK = 0x4000; </span><span style="color:#008000;"><br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">MOUSEEVENTF_ABSOLUTE = 0x8000; </span><span style="color:#008000;"><br>
</span><span style="color:#000000;">}<br>
<br>
[StructLayout(LayoutKind.Sequential, Size=24)]<br>
</span><span style="color:#0000FF;">public struct </span><span style="color:#000000;">KeyboardInput<br>
{<br>
</span><span style="color:#0000FF;">public ushort </span><span style="color:#000000;">wVk;<br>
</span><span style="color:#0000FF;">public ushort </span><span style="color:#000000;">wScan;<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">dwFlags;<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">time;<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">dwExtraInfo;<br>
<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">KEYEVENTF_EXTENDEDKEY = 0x0001;<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">KEYEVENTF_KEYUP = 0x0002;<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">KEYEVENTF_UNICODE = 0x0004;<br>
</span><span style="color:#0000FF;">public const uint </span><span style="color:#000000;">KEYEVENTF_SCANCODE = 0x0008;<br>
}<br>
<br>
[StructLayout(LayoutKind.Sequential, Size=24)]<br>
</span><span style="color:#0000FF;">public struct </span><span style="color:#000000;">HardwareInput<br>
{<br>
</span><span style="color:#0000FF;">public uint </span><span style="color:#000000;">uMsg;<br>
</span><span style="color:#0000FF;">public ushort </span><span style="color:#000000;">wParamL;<br>
</span><span style="color:#0000FF;">public ushort </span><span style="color:#000000;">wParamH;<br>
}<br>
<br>
<br>
<br>
</span><span style="color:#0000FF;">namespace </span><span style="color:#000000;">InputSimulation<br>
{<br>
</span><span style="color:#808080;"> </span><span style="color:#808080;"><br>
</span><span style="color:#0000FF;">public class </span><span style="color:#000000;">InputSimulation : MarshalByRefObject<br>
{<br>
<br>
[DllImport("user32.dll")]</span><span style="color:#0000FF;">public static extern uint </span><span style="color:#000000;">SendInput(</span><span style="color:#0000FF;">uint </span><span style="color:#000000;">nInputs, </span><span style="color:#0000FF;">ref </span><span style="color:#000000;">Input inputs, </span><span style="color:#0000FF;">int </span><span style="color:#000000;">sizeofInput);<br>
<br>
</span><span style="color:#0000FF;">public </span><span style="color:#000000;">InputSimulation()<br>
{<br>
}<br>
<br>
</span><span style="color:#0000FF;">public void </span><span style="color:#000000;">MouseMove(</span><span style="color:#0000FF;">ushort </span><span style="color:#000000;">x, </span><span style="color:#0000FF;">ushort </span><span style="color:#000000;">y)<br>
{<br>
Input[] i = {</span><span style="color:#0000FF;">new </span><span style="color:#000000;">Input()};<br>
i[0].type = 0;<br>
i[0].mi.dx = (</span><span style="color:#0000FF;">int</span><span style="color:#000000;">) x;<br>
i[0].mi.dy = (</span><span style="color:#0000FF;">int</span><span style="color:#000000;">) y;<br>
i[0].mi.dwExtraInfo = 0;<br>
i[0].mi.dwFlags = MouseInput.MOUSEEVENTF_ABSOLUTE | MouseInput.MOUSEEVENTF_MOVE | MouseInput.MOUSEEVENTF_VIRTUALDESK;<br>
i[0].mi.mouseData = 0;<br>
i[0].mi.time = 0;<br>
<br>
</span><span style="color:#0000FF;">uint </span><span style="color:#000000;">ret = SendInput(1, </span><span style="color:#0000FF;">ref </span><span style="color:#000000;">i[0], System.Runtime.InteropServices.Marshal.SizeOf(i[0]));<br>
}<br>
<br>
</span><span style="color:#0000FF;">public void </span><span style="color:#000000;">MouseClick()<br>
{<br>
Input[] i = {</span><span style="color:#0000FF;">new </span><span style="color:#000000;">Input(), </span><span style="color:#0000FF;">new </span><span style="color:#000000;">Input()};<br>
<br>
}<br>
}<br>
}<br>
</span>
</div>
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
|
I have just started playing with the code and read that its possible to make a global hook
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q319524
|
|
|
|
|
I was wondering how that was going to work (I'm actually not sure the exact purpose of installing a hook that's not global to be honest...I need to read more about that). I knew you had to write a DLL with a specific signature that gets loaded by every application (I wrote one once for a kiosk that disabled and enabled things like CTRL-ALT-DELETE once they typed in a password).
I looks like almost the entire project would have to be a straight Win32 DLL in C/C++ (since the keyboard hook would be calling SendInput). You'd most likely write an application that installs and uninstalls the hook as well (which wouldn't necessarily have to be written in C/C++).
Have you ever done any C++? This DLL wouldn't actually be that big...you just have to get it perfect since everything is calling it . If I get a chance tonight, I'll play around with writing a hook (busy at work at the moment).
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
i got hold of a dll hook someone used in VB maybe its convertable to be used in .net ?
http://www.allapi.net/php/redirect/redirect.php?action=download&id=372
thats the link to the sample prog and .dll
nope i havent much experience in c++
only the very basics of c but i am willing to learn
|
|
|
|
|
That app uses Visual Basic (not VB.NET) to create a DLL. His DLL might have even been written in C/C++, but in any event you can specify exactly how the DLL should look in any of those languages (some more easier than others)
I could be wrong (wouldn't be the first time), but I don't think you can create a .NET "Win32 Dll" (there might be some third party stuff that lets you do this, but I don't know). That is to say, I don't think you can create something in .NET that's just a DLL (and not a managed assembly). You can create a DLL that exposes COM functionality, but I don't think you can get as specific as you need for this DLL in .NET (either VB.NET or C#).
I think this job would actually require something other than .NET.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
http://msdn.microsoft.com/msdnmag/issues/02/10/cuttingedge/default.aspx
Apparently a Global hook.......
doesnt seem to do much though
|
|
|
|
|
Google 2 Win it seems
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=872&lngWId=10
has the source code for someone who has created something pretty much what i want in vb.net
just gotta translate ye old code to c# now or just use the vb.net stuff
if your still intrested in having a mess about with this project your very welcome
as your input has been extremely value!
|
|
|
|
|
k had a look at the source........
<br />
Private Declare Function GetCursor Lib "user32" () As Int32<br />
Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (ByRef lpPoint As POINTAPI) As Int32<br />
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Int32, ByVal yPoint As Int32) As Int32<br />
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Int32, ByRef lpdwProcessId As Int32) As Int32<br />
Private Declare Function AttachThreadInput Lib "user32" Alias "AttachThreadInput" (ByVal idAttach As Int32, ByVal idAttachTo As Int32, ByVal fAttach As Int32) As Int32<br />
Private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Int32) As Int16<br />
k i understand GetCursor is the function name and it returns in Integer ....... but "user32" refers to a library and i have no idea how to port that part of the code over to c#
just out of interest is this...... code actually intercepting the events or simply reading them as they fly by as i need to read process and act
|
|
|
|