|
so you mean that we could not throw WIN32 API down and depend just on .Net classes, ...
No problem thanks for help again
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
first thanks for you
and i hope to help me again i create managed c++ class library and used com in it when i compiled it any errors not found but when i build the library this error found
(unresolved token IID_IACCESSCONTROLENTRY)
|
|
|
|
|
|
Dear All,
I want to capture the keycode from keyboard buffer in VB.Net or C# Compact Framework.
Actually, I want to make a TSR(Terminate And Stay Resident) utility
which continuously look at the key strocks of keyboard and as soon as
a special key combination is pressed, it will invoke a function to
perform a series of actions.
For this purpose, I need to capture the keycode at system level not at
form level. So, how can i get keycode from keyboard buffer directly?
Tell me about some API for this purpose.
Regards,
Muhammad Arif
|
|
|
|
|
|
Dear Mazy,
There are two issues in the link you provided
1- This is for .NET Framework not for .NET Compact Framework
2- This code is for Mouse hooking not for keyboard
Please reply me for the code related to keyboard and written in .net compact framework.
Regards,
Muhammad Arif
|
|
|
|
|
aliarifpk wrote:
1- This is for .NET Framework not for .NET Compact Framework
Oh,sorry for that I didn't take attention to it.
aliarifpk wrote:
2- This code is for Mouse hooking not for keyboard
They follow the same procedure, you can find out yourself when you learn one.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Dear Mazy,
I am working on this task for last three days and the API's in .Net Framwork doesn't supported in .Net Compact Framework. That's why I am looking for some alternated which read the keyboard buffer and yet searching .... If someone has done this ... please let me know
Regards,
Muhammad Arif
|
|
|
|
|
Windows CE doesn't support message hooks. Hooking the keyboard isn't possible like it is under Windows 9x/2000/XP/2003.
RageInTheMachine9532
|
|
|
|
|
Dear Dave,
Can you provide me some authenticated URL which agree with your argument that Windows CE doesn't support hooking? I have to have a proof to my client for this argument.
Arif
Muhammad Arif
|
|
|
|
|
|
aliarifpk wrote:
This is for .NET Framework not for .NET Compact Framework
I don't think it make difference cause you have to call win32 API as you can see in that article, so I think you can use those API there too.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
UserControl in VisualBasic 6.0 has
UserControl_AsyncReadComplete(AsyncProp As AsyncProperty) Event,
UserControl_AsyncReadProgress(AsyncProp As AsyncProperty) Event and
UserControl.AsyncRead() Method
To create in C#, I should use what class?
Note: The event and method I mention is very excellent, No side effect while downloading
Sorry for bad English.
Thank You.
|
|
|
|
|
What do you want to exactly do? and what is that UserControl? Those are Async. methods and in your class you don'm implement them, you just call them in your client like that.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
hi,
I have some questions about making thread in my application, as I have no much experiences on Threading. Hope someone can help me.
In my application, I have a button function for outputing files. However, I need to generate some files and pictures before final step, the flow is simply like :
<br />
private void menuItem4_Click(object sender, System.EventArgs e)<br />
{<br />
....<br />
Main_generate_process();<br />
<br />
finalStep(); <br />
}<br />
The main problem is that before runing finalstep, I have to wait until the successful of Main_generate_process(), but I can't measure how long will the process take because the process is run in other DLL function, so I have an idea to use thread.
<br />
private void menuItem4_Click(object sender, System.EventArgs e)<br />
{<br />
....<br />
outThread = new Thread(new ThreadStart(ThreadProc));<br />
outThread.IsBackground = true;<br />
outThread.Start();<br />
<br />
do<br />
{ <br />
<br />
}while(this.outThread !=null);<br />
<br />
<br />
finalStep(); <br />
}<br />
<br />
public void ThreadProc()<br />
{ <br />
Main_generate_process();<br />
StopThread(); <br />
}<br />
<br />
private void StopThread()<br />
{<br />
if (this.outThread != null)<br />
{<br />
outThread.Interrupt();<br />
outThread = null;<br />
}<br />
}<br />
I found that the do-while loop also waste many times. Am I get a wrong idea?
The other quetion is :
can I call ThreadProc() directly in other function; i.e. if the thread has already started, and I need to run generate process again.
Thanks for help~~
|
|
|
|
|
The method Thread.Join() should exactly fit to your requirements. See MSDN for further information. Your code should look like that:
private void menuItem4_Click(object sender, System.EventArgs e)
{
....
//Start the background thread
outThread = new Thread(new ThreadStart(ThreadProc));
outThread.IsBackground = true;
outThread.Start();
outThread.Join();
}
public void ThreadProc()
{
Main_generate_process();
}
|
|
|
|
|
Thank you Troschi,
I have read and tried outThread.Join instead of using do-while loop, but Thread.Join() takes similar effect of do-while loop, it holds the main UI process, means caused the application in idle state.
I would like to run the process smoothly on background. so I need another good methods..
|
|
|
|
|
Maybe this could help you. It's not that elegant but it should work.
outThread.Start();
while (outThread.ThreadState != ThreadState.Terminated)
{
Application.DoEvents();
}
DoEvents-method will process all Windows messages currently in the message queue, so your application should not be idle.
Other solution could be raising an event before the outThread terminates.
|
|
|
|
|
THanks so much Troschi,
The code worked well, and the process does not held.
But will this method cause any hidden side effect?
I changed the code to :
outThread.Start();
while (outThread != null)
{
Application.DoEvents();
}
because I will call stopThread after processed the Thread function.
|
|
|
|
|
You should consider what Tom Larsen mentioned in his comments. Any use of multi threading could turn into a debugging nightmare. So I recommend you disable your menuitem while running the event handler, to prevent the user from starting it again before it finishes execution.
|
|
|
|
|
Try something like the following. I didn't test this so it may require some minor modifications.
private delegate void MyCallbackDelegate();
private void menuItem4_Click(object sender, System.EventArgs e)
{
outThread = new Thread(new ThreadStart(this.ThreadProc));
outThread.IsBackground = true;
outThread.Start();
}
private void ThreadProc()
{
Main_generate_process();
this.Invoke(new MyCallbackDelegate(this.InformUI));
}
private void InformUI()
{
}
|
|
|
|
|
The first thing you need to do is "join" the child process on the parent process. Doing this will insure that the parent will not proceed until the child processes have completed and therefore will call finalStep() at the right time.
The rest of the code snippet is unnecessarily complex. Just doing Thread.Join onto the parent thread should be more than enough syncronization. Threading topics like this can easily turn a simple task into a debugging nightmare. I would suggest you step back and read up on threading and the threading framework in .Net/C#.
|
|
|
|
|
I would avoid the use of Thread.Join in the UI thread because it is a blocking call. The UI thread will be unable to process messages during the execution of the worker thread. The whole reason for using a thread in the first place is keep the UI thread active.
|
|
|
|
|
Given the code snippet I am not even going to say I understand the user interaction. However, it looks like a user activated event. The user clicked on a menu item like "Run This..." Just the indictor that a "final step" is needed indicates that the system to be sane must be run in that order. There is no indication that UI events are handled asyncronously so why add that level of complexity and a different and somewhat advance form of bugs and debugging?
Or to put it another way, the user selects "Run This..." without Join so the application continues to be interactive. What is to stop the user from selecting again "Run This..."?
Its all hypothetical anyway. Neither of us know what the application does to make the right choice on action. I shy away from allowing the user choice of "forking" operations. We have a hard enough time making the right UI choices so that users will grasp the application easily. Adding "forking" invovles all sorts of complexity without much UI bang.
|
|
|
|
|
Is it possible to save the contents of a Rich Text Box to an XML File, including bold text, italics, etc? If not, could someone suggest an alternative way to do it?
Thanks in advance.
-Sean
|
|
|
|