|
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.
|
|
|
|
|
|
This was a great help for given by saurabh
respect your knowledge!
but i have seen Rajesh or many others who are helping badly, though criticism but proper yes most of us who visit this webiste CP needy of help there are few like Rajesh,Navneet,Christian Graus,Anshuman and finally Pallini who give performance tips also ... who helps us.
please dont mind there criticism it will help you to learn other language also ..
Rule:
More you involve here more help you get
so keep asking good question !!!!!!!!!!!!!!!!
vikas da
|
|
|
|
|
Thanks buddy
|
|
|
|
|
For the record, I'm not the one voting down you down. I've balanced it in fact.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Dear All,
I am using FileStream Class to read from pdf file and then set the DocumentStream of Web Browser to that FileStream object, but it seems web browser control doesent work so.
FileStream fs=new FileStream(filePath,FileMode.Open,FileAccess.Read);
webVr.DocumentStream=fs;
This shows a very missing things in web browser control.
basically i am using stream, that is bz i am getting my pdf file from another server.
can i show pdf files using WebBrowser Control?
i have got a reference which i can Ipersist Interface, but i didnt find any example of this interface.
i would appreciate to have an example of this interface "IPersist"
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
modified on Wednesday, June 10, 2009 7:34 AM
|
|
|
|
|
You don't need to do that at all. Just Navigate to filePath
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
thx dude, u might know when i use navigate, that bring the toolbox and other elements of adobe which i dont want.
My PDF is always one page document and i want that to appear very clean.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
modified on Thursday, June 11, 2009 1:51 AM
|
|
|
|
|
Hi Abdul
There are two options for you.
1) File should be in the webserver location in the server, be in wwwroot folder of IIS or in any apache webserver.
eg. C:\inetpub\wwwroot\pdf\a.pdf
You can then write a c# client code
if (browser == "Firefox" || browser == "firefox")
System.Diagnostics.Process.Start("firefox.exe", urlname);
else
System.Diagnostics.Process.Start("iexplore.exe", urlname);
where urlname = "http://10.1.1.23/pdf/a.pdf" coming from an xml file.
2) you may download the file from server to your machine through the below webservice code.
// name contains path of pdf file in the server
System.IO.FileInfo fInfo = new System.IO.FileInfo(name);
long numBytes = fInfo.Length;
System.IO.FileStream fStream = new System.IO.FileStream(name, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
// convert the file to a byte array
byte[] data = br.ReadBytes((int)numBytes);
br.Close();
fStream.Close();
fStream.Dispose();
// return pdf if we made it this far
return data;
and show it in the browser by the below code
if (browser == "Firefox" || browser == "firefox")
System.Diagnostics.Process.Start("firefox.exe", localpath);
else
System.Diagnostics.Process.Start("iexplore.exe", localpath);
where localpath="c:\a.pdf" coming from xml file
|
|
|
|
|
thx my friend, u might taught of webbrowswer like IE or firefox, but i am asking of WEBBROWSER control in windows Form Application which is in .Net Framework 2.0
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Hi Experts
I am Working With C#.Net in 2005.I Have a text File i read it to show in
Rich Text Box. After That I Want To Run Find Word In side The Rich Text Box and
Find Word Color is Dark(Highlight the Find Text )
Then How We Can Do Find and High light Operation on Rich text Box.
Thank u
Dinesh
|
|
|
|
|
You can use the RichTextBox.Find(string) method. That gives you the first instance of the string you pass it as a parameter (-1 otherwise). That's the SelectionStart. SelectionLength is fairly simple to calculate - just add the phrase's Length to SelectionStart. Then you simply have to change the SelectionFont property of the RichTextBox
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I have to convert any vedio file to flv format while uploading that vedio.while saving that vedio it should be in flv format.
ashishbisen
|
|
|
|
|
ashishbisen wrote: I have to convert any vedio file to flv format while uploading that vedio.while saving that vedio it should be in flv format.
Go ahead, it looks like a good idea.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Good luck.
What is your question?
What have you try'd? (if anything at all)
Any code?
Any errors? (if so where?)
...
We are NOT here to do your (home)work for you.
[EDIT]And cross posting is considered rude.[\EDIT]
|
|
|
|
|
The FileUpload control doesn't actually do any conversion. It simply allows the user to select a file, and then saves it to a specified path on the server. If you want to do any conversion on the file, you need to manipulate the file bytes. However, you could in theory check if the file is a video by looking at the FileUpload.PostedFile.ContentType property; if it starts with "video/" then it would appear to have the correct MIME type. I'm not certain whether this would work properly though - since it's just a byte stream, it could quite easily have the MIME type "application/octet-stream"
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi i am creating a GUI to represent a virtual joystick, (Prototype to represent features)
I am encountering the white background problem.
I used a picture of the joystick in a picture box then added the controls however a white background appears on the rectangle around them even though i used this.BackColor = Color.Transparent;
It only happens when i put a picture box not if i set the picture as the form background.
Is there a way of getting rid of the white rectangles?
|
|
|
|