|
Thank you, James, but how about 2nd question?
I'm amumu, and you?
|
|
|
|
|
I've never used the binding redirect before so I can't really comment on how to get it working properly.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I need to hook the keyboard messages system wide. This can be done by using SetWindowsHookEx() to do this.
HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId);
I got everything to work except the third param. What do I use for a handle if I want to do System wide hook?
Thanks for your time
|
|
|
|
|
This is not a C# question, but I'll answer anyway. Use 0 as the thread ID. Also, you will need to put your hook funcion in a DLL, so it can be loaded in every process.
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Thanks for the information provided.
This is what I have right now:
public void StartHook()
{
int hookType = (int)NativeMethods.WH.KEYBOARD;
myHookProc = new NativeHookMethods.HookProc(this.hookProc);
hookHandle = NativeHookMethods.SetWindowsHookEx(hookType,
myHookProc, ??? ??, 0);
}
What do I put in the third parameter? Please help
|
|
|
|
|
|
Anybody can help me how can I implement C++ Copy Constructor in C# with a generic example.
Thanks in advance
|
|
|
|
|
You do it just like you would with C++; however the more correct method is to implement the ICloneable interface.
class Foo : ICloneable
{
public int bar;
public SomeClass baz;
public Foo()
{
bar = 0;
baz = new SomeClass();
}
public Foo(Foo sourceCopy)
{
bar = sourceCopy.bar;
baz = sourceCopy.baz;
}
public Foo Clone()
{
Foo f = new Foo();
f.bar = bar;
f.baz = new SomeClass();
return f;
}
object ICloneable.Clone()
{
return Clone();
}
} James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Thanks James you are always a good resource.
|
|
|
|
|
Hi,
I was wondering if the the Clone() method in the Foo class needs to be public. I've been using C# now for about 10 minutes,;P so please forgive me if this is a dumb question.
Thanks.
|
|
|
|
|
Its not a dumb question at all because the answer isn't obvious.
In the Foo class there are two different implementations of Clone(), one which is a member of the class and the other is Foo's implementation of ICloneable.
Interfaces in C# (and .NET) require that their members be public; so when I specifically implemented the Clone method as Foo's implementation of ICloneable I didn't need to specify the public access modifier.
In C# there are two different ways to implement an interface.
The first method is by adding a public member for each item in the interface you are implementing. Most people probably use this technique to implement an interface.
interface IBar
{
object Bar();
}
class Foo : IBar
{
....
public object Bar()
{
....
}
} The second method is to specify in the member's signature what interface it is implementing.
class Baz : IBar
{
...
object IBar.Bar()
{
....
}
} Unlike the first method the only way to use this member is cast the object to the interface (IBar ib = (IBar) myBaz; ). Now you can use the member as if it were any other interface.
This also gives an advantage for the users of your class. You can provide two different implementations of a member: one to be used when dealing with the interface, the other to be used when dealing with the class itself.
Most of the collections in the .NET class library do this to provide a strongly-typed collection while also implementing the generic interfaces that provide a standard way of using a collection.
Hope that answers your question
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I am trying to read a custom config section but its not working. ConfigurationSetting.GetConfig() returns null;
CONFIG FILE:
<configuration>
<configSections>
<section name="data" type="System.Configuration.SingleTagSectionHandler"/>
</configSections>
<data Server="GODSWORKSTATION" Username="MedWizard" Password="MedWizard" Security="SSPI"
PersistSecurity="false" Pooling="false" MinPool="20" MaxPool="1000" NetworkLibrary="dbmssocn"/>
</configuration>
CODE:
IDictionary valueTable = (IDictionary)ConfigurationSettings.GetConfig("data");
string Server = (string)valueTable["Server"];
string Username = (string)valueTable["Username"];
string Password = (string)valueTable["Password"];
string Encrypt = (string)valueTable["Encrypt"];
string Security = (string)valueTable["Security"];
Any ideas? Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
You need to change the section line to specify the full assembly name (since the assembly has a strong name this means the typename, the assembly name, version, and public key token).
<section name="data" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
I have an article that's done but needs formatting and proofreading before I post it.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
|
Oops
it should have been configurationhandler not section
Correct link[^]
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I have a c# project that is causing me problems at the moment.
I have a file that looks like this
------------
using System ;
namespace MyNameSpace.System
{
public class Test
{
public Test ()
{
System.Diagnostics.Trace.Writeline ("Hello World!") ;
}
}
}
------------
the problem is that when I compile this it VS complains that the namespace Diagnostics does not exist in MyNameSpace.System
Also when I type System. the intelisense gives me a choice of 'Test' only i.e. my clases in the MyNameSpace.System namespace.
if I change the line to
Diagnostics.Trace.Writeline ("Hello World!")
dropping the System it all compiles.
Is this normal namespace behaviour? If not (hope not as this sucks) anyone got any idea on how to fix it?
Thanks
Stephen.
|
|
|
|
|
Stephen Woolhead wrote:
Is this normal namespace behaviour?
Yep. Perhaps Eric can explain it better (I just spent 10 minutes trying to and couldn't get it out right) but IIRC namespaces are evaluated from right to left, so the System matches before it gets to the root System namespace; however Diagnostics doesn't match until it gets to the root System namespace.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Just seemed strange to me that as I was in the namespace MyNameSpace.System and had a using statement for System when I was used System.Diagnostics, that it should resolve to MyNameSpace.System.Diagnostics instead of trying the following
MyNameSpace.System.System.Diagnostics (Current namespace)
System.System.Diagnostics (Using System Statement)
System.Diagnostics (using the global namespace)
Of which the last one would have been resolved.
Is there a way to say that this is the start of the namespace do not append to anything, something like ::System in C++ ?
Thanks
Stephen
|
|
|
|
|
Stephen Woolhead wrote:
Just seemed strange to me
It does to me too; perhaps this will be addressed in the future (so that it tries all the way up instead of stopping at the first failure -- MyNameSpace.System.Diagnostics)
Stephen Woolhead wrote:
Is there a way to say that this is the start of the namespace do not append to anything
Not that I know of, I think something is needed at any rate.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
Stephen Woolhead wrote:
Is there a way to say that this is the start of the namespace do not append to anything, something like ::System in C++ ?
No but you can try this code example. It's an almost solution to the problem.
using System;
using WinSystem=System;
namespace Test.System {
public class Test {
public static void Main(String[] args) {
WinSystem.Console.WriteLine("Hello World");
}
}
}
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
Hi everybody!
I have the following code in the constructor:
lstUsers = new ListView();<br />
lstUsers.Parent = this;<br />
lstUsers.Location = new Point(0, panelTitle.Height);<br />
lstUsers.Size = new Size(Width, Height - lstUsers.Location.Y + 1);<br />
lstUsers.Anchor = AnchorStyles.Left | AnchorStyles.Top |<br />
AnchorStyles.Right | AnchorStyles.Bottom;<br />
lstUsers.View = View.Details;<br />
<br />
lstUsers.Columns.Add("Clave", 150, HorizontalAlignment.Left);<br />
lstUsers.Columns.Add("Nombre", 250, HorizontalAlignment.Left);<br />
lstUsers.Columns.Add("Permisos", 100, HorizontalAlignment.Right);<br />
The list view appears ok, and when I add items, I can see them in large icon mode (if I remove the View = Details), but in Details mode I don't see anything... not even the column headers (after adding the columns I verified and Columns.Items.Count is indeed 3)
Any ideas???
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Hi, try adding
listUsers.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
or Clickable.
Hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Sorry, it didn't work
The only one that seemed to have an effect was ColumnHeaderStyle.None, which removed the place where columns are supposed to appear.
Thanks anyway,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Luis Alonso Ramos wrote:
The list view appears ok, and when I add items, I can see them in large icon mode (if I remove the View = Details), but in Details mode I don't see anything...
How are u adding the ListViewItems? If u want to see "multi-columns" make sure it looks like this.
listUser.Items.Add( new ListViewItem( new string[] {"col1itemtext","col2itemtext","col3itemtext"}));
and NOT:
listUser.Items.Add( "colitemtext")
Are u not maybe overwriting the columnheaders?
Hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Hello,
<br />
while(oReader.Read())<br />
{<br />
ListViewItem lvi = new ListViewItem();<br />
<br />
lvi.Text = (string) oReader.GetValue(oReader.GetOrdinal("LoginName"));<br />
lvi.SubItems.Add((string) oReader.GetValue(oReader.GetOrdinal("Name")));<br />
lvi.Tag = (int) oReader.GetValue(oReader.GetOrdinal("ID_user"));<br />
<br />
lstUsers.Items.Add(lvi);<br />
}<br />
This is what I'm using... If I set another view (View.List) for example, the items show OK. It's just the details view that I'm having trouble with.
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|