|
Ah, I got your idea
Looks very interesting!!!
Thanks for your great help, and yes, if it works very well, I think I will do a little
article (as its really just very small).
Again, thank for your support
Matthias Rost
Edit: It works just perferctly, Thanks, Thanks, Thanks!
-- modified at 12:33 Sunday 21st May, 2006
|
|
|
|
|
Hi,
I'm just starting to use C# after several years of C++ and there are quite a few confusing things.
For ex. if I'd like to write a function that sums two objects for which there is an operator+, how should I do that? I tried to do something like this, but ofcourse it's not correct.
<br />
Object sum(Object a, Object b)<br />
{<br />
return (a.GetType())a+(b.GetType())b;<br />
}<br />
So what it the way things in C# should be written, if it something for one would use templates in C++?
Thanks,
Greg
|
|
|
|
|
You need to know of which type a,b is.
You can check it like this:
if(a is MyType && b is MyType)
{
return (MyType)a + (MyType)b;
}
I'm not sure if the abstract GetType()-way will work.
For templates you might want to take a look at Generics
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks, but the point is I can not tell the types beforehand, so I'd like to make it work for any type that has the appropriate methods, operators, etc.
If it changes anything, the function would be some non-static method of a class for which further specializations are likely to take place.
Generics sound nice, but for now I'd like to stick to .NET 1.1.
Cheers,
Greg
|
|
|
|
|
seikou wrote: Thanks, but the point is I can not tell the types beforehand, so I'd like to make it work for any type that has the appropriate methods, operators, etc.
That sounds like a job for an interface. If you specify an interface containing the methods and make the classes implement the interface, you can handle any object from those classes using the interface as data type, regardless of which actual data type they are.
---
b { font-weight: normal; }
|
|
|
|
|
I agree, this is a good solution.
If you need some sample code, feel free to ask.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi everyone,
I have made a c# application (from the article: Global System Hooks in .NET
By Michael Kennedy link) that installs a systemwide keyboard hook. This application emulate mouse clicks when specified key pressed.
It's work fine, only a little problem with it:
When keypess occures, my app hooks it, and Windows hoo too.
How can I told windows not to do that?
Example:
I set the 0 key to do left mouse click, when I press 0 in a textbox or in TotalCommander the click occures, and a 0 character appears in the textbox too
Hope somebody can help me :->
PS:
Sorry about my english
|
|
|
|
|
Hi,
I think you can download the Full Source of that article and make some changes on it. and recompile it.
In SystemHookCore.cpp at InternalKeyboardHookCallback function you should mark last line and add
return 1; instead of that line:
static LRESULT CALLBACK InternalKeyboardHookCallback(int code, WPARAM wparam, LPARAM lparam)
{
if (code < 0)
{
return CallNextHookEx(hookKeyboard, code, wparam, lparam);
}
if (UserKeyboardHookCallback != NULL && !keyboardFilter.IsFiltered((int)wparam))
{
UserKeyboardHookCallback(code, wparam, lparam);
}
return 1;
}
But I think it is a rapid solution. in addition you should add some mechanism in other class to check in application level that you want to take this action on this character or not.
Ahmadreza Atighechi
|
|
|
|
|
Thank's a lot!
It's works fine
Can you tell me, how can I modify the ManagedHook or HookCore project to tell them witch cases makes this return 1 trick, and witch not.
So how can I tell to the class from my C# app to do the return 1 action when my defined keys pressed, and otherwise do the normal action?
I think i shoud add somethink like this:
List<keys> l;
Than I add my specila keys to the list, and every time keypress occures I search the list for the actual key, when I find it, do the return 1...
Sorry for my stupid questions, but i not familiar with dll manipulation
I trí to modify SystemHookCore.cpp, and add a method, and a global witch set/store the keycodes, witch is exclude from system hooks. also modify the, managedhooks class, rebuild all, but when I start my app get error:
"Entry point(my new function name) was nt found on systemhook.dll"
Thank's for help!
-- modified at 10:29 Sunday 21st May, 2006
|
|
|
|
|
I am making a tray application with a custom ApplicationContext. Application exits OK when i close application manually. When i try to close application by doing Shutdown windows, windows aborts shutdown. I realize my problem is because application is not cleaning up.
What do i need to do so that my application will exit OK when a user chooses to Shutdown windows instead of closing manually? I am at a loss where to put clean up code.
|
|
|
|
|
Search this forum, I posted the answer to the same question only a week or 2 ago.
|
|
|
|
|
Please , can anyone here tell me where I can find significant information about Stacks and Queues in C#? I've been consulting many tutorials but nothing objective ...And I need it a lot now . Thanks
BiGjOe
Passez Ce Qu'il Passe
|
|
|
|
|
What sort of 'objective' information do you want ? Do you want to know about existing container classes, how to write your own, or just the nature of those container types ( regardless of language ) ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If I have to decide , I could say the third , but really , I need general information about .
Thanks
BiGjOe
Passez Ce Qu'il Passe
|
|
|
|
|
OK. Google would have tons of info, what do you mean by 'objective' ?
Get the coins out of your pocket. Start putting them in a pile on your desk. This is a stack. When you take items off, the last item to go on is the first to go off.
When you go to the cinema, if it's busy, you need to stand in line to buy a ticket. This is a queue - the first person in the queue gets to leave the queue first.
That's all there is to how these two containers work. What other information were you looking for ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well , that's what I know , and anything more . I've ever worked with stacks or queues , so , I think there's anything more . That's why the question .
I mean , arrays are too very simple , but I can read chapters about
BiGjOe
Passez Ce Qu'il Passe
|
|
|
|
|
I'm sorry, I don't understand the question at all. A stack or queue is probably implimented as a list, but you can think of it as an array which limits which items you can access at any time. There is tons of info around on container types, I have an O'Reilly book called Algorithms in C ( or something like that ) which is great for learning about this stuff.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Try this link: An Extensive Examination of Data Structures (including stacks and queues)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/datastructures_guide.asp
Osama E. Adly
|
|
|
|
|
Thanks , a very good one
BiGjOe
Passez Ce Qu'il Passe
|
|
|
|
|
Hi,
To be able to playback Wav MemoryStreams from a console I have to call this function
ApplicationDevice = new Device();
ApplicationDevice.SetCooperativeLevel(NEED_POINTER_TO_CONSOLE, CooperativeLevel.Normal);
I have tried calling
[DllImport("kernel32")]
static extern IntPtr GetConsoleWindow();
to get the a pointer to the console, but it doesn't work.
The CTOR takes either a Control like a Form or a IntPtr. Please help me.
TIA
------------------
I'm naked under my clothes...
-- modified at 19:10 Saturday 20th May, 2006
|
|
|
|
|
I have TreeList. This TreeList have TLNode(TreeListNode).
To set value i use public override void SetValue(object columnID, object val).
But it don't call. How to set this value?
public class TLNode : TreeListNode
{
String Title;
String Url;
public TLNode(int id, TreeListNodes owner, String title, String url) : base(id, owner)
{
Title = title;
Url = url;
}
public override string GetDisplayText(object columnID)
{
return Title;
}
public override void SetValue(object columnID, object val)
{
DevExpress.XtraTreeList.Columns.TreeListColumn id = (DevExpress.XtraTreeList.Columns.TreeListColumn)columnID;
switch (id.AbsoluteIndex)
{
case 0:
val = Title;
break;
}
}
public override object GetValue(object columnID)
{
DevExpress.XtraTreeList.Columns.TreeListColumn id = (DevExpress.XtraTreeList.Columns.TreeListColumn)columnID;
switch (id.AbsoluteIndex)
{
case 0:
return Title;
default:
return "";
}
}
}
SetValue have stop point and debuger don't go in this metod after end edit string in TreeList.
|
|
|
|
|
Hi,
I want to write "Hello World" using Notepad and then create the HelloWorld.exe using
the >csc HelloWorld.cs (from the command prompt). "Inside C# -- Chapter 1".
1. How should I save the file with Notepad? *.txt? *.cs? "all files"?
2. I'm almost certain that I have set the environment variables for the Framework SDK
correctly.
3. I have installed on my machine VS.NET 2003.
4. The file is located on the desktop. I can use the command prompt to open any file on the desktop. HelloWorld.txt will open. HelloWorld.cs will not open (although it will create a file as a ".cs" icon) and any "csc" command will not be recognized.
Any help would be greatly appreciated. Go easy on me -- I'm just trying to learn the basics -- thanks
|
|
|
|
|
Hi!
1. It doesn't matter. You just have to look at the filename your source file gets - when you save it with "*.txt" as filter, Notepad automatically adds ".txt" to the filename. So if you save your source file as "HelloWorld.cs", you'll end up with a file "HelloWorld.cs.txt".
But for compiling the final filename really doesn't matter.
2. If you did, "csc.exe" will be found. If you didn't, it won't be found. Simple as that.
3. Then you'll have a VS.NET 2003 command prompt in your start menu. Use this to get the console window, then the correct paths will be set.
4. Putting source files on the desktop usually isn't such a good idea. Create yourself a dedicated source directory (C:\Sources, for example). This is far easier to reach, especially if you're using a command prompt.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hi! I'm pretty new to C#, but, i wanna learn...
I have a question... i have a datagridview binded to a database, but i wanted to add also a delete column to erase that row. The problem is i can't find an event to trigger when i push the delete button. this would be the first part of the problem. the second problem is how do i know which row to delete when the button of one raw is pressed?(i would be regardful if u gave me some code examples, too).
|
|
|
|
|
Hi,
First of all, are you using asp.net or windows? If it is windows you can use the code below:
private void dataGrid1_Click(object sender, System.EventArgs e)
{
DataTable dt = dataGrid1.DataSource as DataTable;
if(dt!=null)
{
string firstField = (dt.Rows[dataGrid1.CurrentRowIndex][0].ToString());
}
}
As you can see, what I'm doing is casting the datasource datagrid's property to a datatable object. Then using the CurrentRowIndex property I can obtain any field's values from the datatable.
If it is an asp.net application, then you can use the code below:
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="Select")
{
string id = e.Item.Cells[1].Text;
Response.Write(id);
}
}
In this case, I'm assuming the ID of the row is presented in the second column (since the first one is the SELECT link).
I created a tutorial about GridView control (asp.net 2.0) at www.KYNOU.com. I'm always in this website's chat room. If you want to chat with me live logon to it.
I hope I helped
|
|
|
|
|