|
I don't read unformatted code; use the PRE tags (e.g. through the "code block" button under the edit box.
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 all,
i was making a asp page with C# where i have display a data for a month or week for morning 8 am to 8 pm
for this shake am looping for whole month between 8am to 8 pm
can somebody suggest me something good as this logic looks like costly..
Thanks
vikas da
|
|
|
|
|
tasumisra wrote: asp page with C#
you need to first understand difference between asp and asp.net
tasumisra wrote: for this shake am looping for whole month between 8am to 8 pm
shakesake
tasumisra wrote: can somebody suggest me something good as this logic looks like costly..
Do you want to display the data or you want to create task which collects data between this time?
try to explain your problem clearly
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
woooow nice answer
suppose i am having a label x i want to assign the value that i have retrieved while executing the sql query for each day
so i want to do
x.text=retrievedvalue.Tostring()
vikas da
|
|
|
|
|
if you didnt understand my problem yet i can explain you with example..
vikas da
|
|
|
|
|
A formal analysis of the Algorithm you suggested would be O(n) which isn't so bad.
|
|
|
|
|
Thanks Ennis for your reply i will working with same piece of code
vikas da
|
|
|
|
|
Hi!
I want to catch all messages of an external application in my application. For exp. if user is using Microsoft word and if he/she clicks on file menu, my application should catch the message that File menu is clicked. I searched on SetWindowsHook API but could not get any C# sample similar to my target. Can anyone have any idea how to do it in C#?
|
|
|
|
|
I suspect you're looking for this[^]. Pay particular attention to the Notes section on limitations of .NET.
However, you aren't interested in all messages - you should only be interested in certain messages. Do you want your application, for instance, to know that Word responded to a Paint message?
"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
|
|
|
|
|
This is like asking "How to brush my teeth with sand?". Sure, it will work, but the results may not be as shining.
If you're writing global hooks, for the love of God, please write it in C or C++. Use the .NET framework for what it is supposed to be used. If you have a genuine reason why you want to do this in C#, can you please provide it?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: This is like asking "How to brush my teeth with sand?".
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi Rajesh
Its true that VC++ is a better language for global hooks with call back functionality but the question was specifically asked for C# for whatever reason. So if you dont know the answer then please dont reply with criticism instead try to look for the answers that would benifit all of us.
|
|
|
|
|
It would benefit only you, not anyone else.
Don't act like a dick to people who try to help, he has no obligation to help you. So if he asks you a question, answer it. Don't command people to look for your answer for you.
I assume your question will go unanswered due to your rudeness.
|
|
|
|
|
You seem to have missed that he is not the OP.
But, I still find his comments to be unjustified as he has nothing to do with the query by the OP or my question to the OP.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have posted the solution.
|
|
|
|
|
Hello!
There's no question of "better language" here. I am talking about the OP using a framework for a purpose that it isn't intended to be used.
I also asked for the reasoning behind him writing a hook with C# (there may be genuine reasons, and I am willing to help in that case). I cannot shut up and watch or help someone to do something the worst way. I am only trying to help him do it the correct way and may I politely remind you that my reply to the OP is none of your concerns?
I also think that it is OK to add a bit of criticism where and when needed.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Nothing Personal
Peace!!
|
|
|
|
|
Hi Muneeb
Yes its definitely possible with the help of delegates in C#
I came across the same situation when i needed to code for windows taskbar switching functionality.
Let the call back function you want to hook is
private static IntPtr HookCallback(
int nCode, IntPtr wParam, IntPtr lParam) {}
which would get executed when file button is clicked.
assign:-> private static LowLevelMouseProc _proc = HookCallback;
private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
and set the hook with
private static IntPtr SetHook(LowLevelMouseProc proc)
{
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
return SetWindowsHookEx(WH_MOUSE_LL, proc,
GetModuleHandle(curModule.ModuleName), 0);
}
}
You may need to use documented and undocumented Winapi calls to get the classid and Filebutton name in function HookCallback
You are done!
|
|
|
|
|
You may want to go back and re-read the OP's requirements. He wants to catch the messages going to a particular application. Your solution is completely different, capturing only the mouse messages comming out of the mouse driver system-wide. Those mouse messages don not tell you what has been clicked, only that the mouse has moved and mouse buttons have been pressed.
Since the .NET CLR doesn't support the exports required to do true "global" hooking, targeting other applications, there is no pure C# solution to his problem. He has to use C++ get something like this to work.
|
|
|
|
|
You are correct in terms of stating that he needs to use C++ to catch the messages going to a specific word application as C#.net is safe programming.
In order to make the solution possible in C# we need to take indirect route that could have been direct with VC++, with the call back function private static IntPtr HookCallback(
int nCode, IntPtr wParam, IntPtr lParam)
by using MouseMessages, we can find the point where the click happened.
Then we will use WindowFromPoint(hookStruct.pt)
We can now find the class id. and pass the message further by SendMessage(hToolbar, TB_MOVEBUTTON, 2, 12); and send the hook again CallNextHookEx(_hookID, nCode, wParam, lParam). By knowing the structure of the word application, we will then find the button control id and name of it from its structure.
|
|
|
|
|
Dave's point is that the whole idea of using the .NET framework for writing a system-wide hook should be dropped. There can be no sane reasoning behind writing this kind of stuff in .NET. I am also in agreement with him that what you provided is not going to solve the purpose, given this context.
I seriously believe that Dave is not in need of you to explain him how stuff works. As to your argument, it is pointless and is a waste of time as you seem not to understand what we are trying to tell.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
It would be better, if you utilize your time in providing solutions to other pending questions instead of wasting your valuable time on me.
|
|
|
|
|
saurabh sahay wrote: you utilize your time in providing solutions to o
I've been doing that for a few years now.
saurabh sahay wrote: wasting your valuable time on me.
I'm having to waste my time on you because your replies are consistently misleading and wrong.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Thanks, you Finally understood. Now we must get back to help the community instead of wasting time on each other.
|
|
|
|
|