Click here to Skip to main content
15,905,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: c# Pin
Michael Sync29-Aug-07 19:56
Michael Sync29-Aug-07 19:56 
AnswerGiven this is the C# forum, don't you think it would look terrible if all threads had the subject 'C#'? Pin
Vikram A Punathambekar29-Aug-07 20:54
Vikram A Punathambekar29-Aug-07 20:54 
QuestionHelp about Hipaa edi!! Pin
Kumar!29-Aug-07 18:45
Kumar!29-Aug-07 18:45 
Questionhow to search string in different file and comment it [modified] Pin
Situ1429-Aug-07 18:15
Situ1429-Aug-07 18:15 
AnswerRe: how to search string in different file and comment it Pin
WhiteGirl2329-Aug-07 22:49
WhiteGirl2329-Aug-07 22:49 
QuestionStart reading from end of file Pin
TheJudeDude29-Aug-07 18:09
TheJudeDude29-Aug-07 18:09 
AnswerRe: Start reading from end of file Pin
Michael Sync29-Aug-07 19:53
Michael Sync29-Aug-07 19:53 
QuestionThreaded Form Pin
xfitr229-Aug-07 16:30
xfitr229-Aug-07 16:30 
I am having trouble with closing a form created in a seperate thread. This is what I am trying to accomplish: I have a program that runs in the taskbar. When a user double-clicks a key, a form is created in a new thread and is shown on top of all other forms. When the user clicks anywhere outside the form, the thread will close, but the program will continue to run in the background. This is similar to the Google Desktop functionality. The code works the first time the form is created in a new thread, but if the form has been closed once, you have to click on the form to make it active and then click outside of it before it will close. I have tried using the Deactivate and LostFocus events, but they both only work the first time the form is shown. Any suggestions would be greatful. I have included a snippet of code below.

<br />
public class MyClass {<br />
    private Thread _thread;<br />
    private FMain _fmain;<br />
    private UserActivityHook _keyhook;<br />
<br />
    public MyClass() {<br />
        _keyhook = new UserActivityHook(false, true);<br />
        _keyhook += new KeyEventHandler(KeyDoubleClick);<br />
    }<br />
<br />
    private void KeyDoubleClick(object sender, KeyEventArgs e) {<br />
        if (e.KeyValue == 163) {<br />
            _thread = new Thread(new ThreadStart(OpenForm));<br />
            _thread.Start();<br />
        }<br />
    }<br />
<br />
    private void OpenForm() {<br />
        _fmain = new FMain();<br />
        _fmain.Deactivate += new EventHandler(form_Close);<br />
        _fmain.LostFocus += new EventHandler(form_Close);<br />
        _fmain.ShowDialog();<br />
    }<br />
<br />
    private void form_Close(object sender, EventArgs e) {<br />
        _thread.Abort();<br />
    }<br />
}<br />


References: The UserActivityHook was fortunately posted by George Mamaladze; http://www.codeproject.com/csharp/globalhook.asp[^]
AnswerRe: Threaded Form Pin
Michael Sync29-Aug-07 17:22
Michael Sync29-Aug-07 17:22 
GeneralRe: Threaded Form Pin
xfitr229-Aug-07 17:35
xfitr229-Aug-07 17:35 
GeneralRe: Threaded Form Pin
Michael Sync29-Aug-07 18:05
Michael Sync29-Aug-07 18:05 
GeneralRe: Threaded Form Pin
Spacix One30-Aug-07 3:51
Spacix One30-Aug-07 3:51 
Questionhow to backup sql database from c#2005 Pin
tech-progg29-Aug-07 16:30
tech-progg29-Aug-07 16:30 
AnswerRe: how to backup sql database from c#2005 Pin
\laddie31-Aug-07 1:05
\laddie31-Aug-07 1:05 
GeneralRe: how to backup sql database from c#2005 Pin
tech-progg2-Sep-07 16:30
tech-progg2-Sep-07 16:30 
QuestionInsert statment for multiple tables Pin
falles0129-Aug-07 15:49
falles0129-Aug-07 15:49 
AnswerRe: Insert statment for multiple tables Pin
tech-progg29-Aug-07 16:33
tech-progg29-Aug-07 16:33 
GeneralRe: Insert statment for multiple tables Pin
falles0129-Aug-07 16:40
falles0129-Aug-07 16:40 
GeneralRe: Insert statment for multiple tables Pin
Not Active29-Aug-07 17:35
mentorNot Active29-Aug-07 17:35 
AnswerRe: Insert statment for multiple tables Pin
xfitr229-Aug-07 16:38
xfitr229-Aug-07 16:38 
GeneralRe: Insert statment for multiple tables Pin
falles0129-Aug-07 16:42
falles0129-Aug-07 16:42 
GeneralRe: Insert statment for multiple tables Pin
xfitr229-Aug-07 17:02
xfitr229-Aug-07 17:02 
GeneralRe: Insert statment for multiple tables Pin
falles0129-Aug-07 17:10
falles0129-Aug-07 17:10 
GeneralRe: Insert statment for multiple tables Pin
xfitr229-Aug-07 17:14
xfitr229-Aug-07 17:14 
GeneralRe: Insert statment for multiple tables Pin
Michael Sync29-Aug-07 17:24
Michael Sync29-Aug-07 17:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.