Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: Show HTML in Windows Application Pin
Stephane Rodriguez.2-Apr-03 20:14
Stephane Rodriguez.2-Apr-03 20:14 
GeneralRe: Show HTML in Windows Application Pin
D.D. de Kerf3-Apr-03 0:59
D.D. de Kerf3-Apr-03 0:59 
GeneralRe: Show HTML in Windows Application Pin
Roger Alsing2-Apr-03 21:53
Roger Alsing2-Apr-03 21:53 
GeneralADSI urgent help required Pin
Venkatraman2-Apr-03 19:15
Venkatraman2-Apr-03 19:15 
GeneralRe: ADSI urgent help required Pin
Velichko Sarev2-Apr-03 20:52
Velichko Sarev2-Apr-03 20:52 
GeneralRe: ADSI urgent help required Pin
Venkatraman2-Apr-03 21:28
Venkatraman2-Apr-03 21:28 
QuestionCWinThread equalant? Pin
bpavi2-Apr-03 10:38
bpavi2-Apr-03 10:38 
AnswerRe: CWinThread equalant? Pin
Oleksandr Kucherenko3-Apr-03 4:56
Oleksandr Kucherenko3-Apr-03 4:56 
Code below implement such thread

<br />
    [DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
    public static extern IntPtr PostThreadMessage( uint idThread, int msg, int wParam, int lParam);<br />
    [DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]<br />
    public static extern int GetCurrentThreadId();<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool PeekMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax, uint wFlag);<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool GetMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax);<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool TranslateMessage(ref MSG msg);<br />
    [DllImport("User32.dll", CharSet=CharSet.Auto)]<br />
    public static extern bool DispatchMessage(ref MSG msg);<br />
<br />
  #region MSG<br />
  [StructLayout(LayoutKind.Sequential)]<br />
  public struct MSG <br />
  {<br />
    public IntPtr hwnd;<br />
    public int message;<br />
    public IntPtr wParam;<br />
    public IntPtr lParam;<br />
    public int time;<br />
    public int pt_x;<br />
    public int pt_y;<br />
  }<br />
  #endregion<br />
<br />
<br />
    /// <summary><br />
    /// Start background message loop thread and show dialog<br />
    /// </summary><br />
    public void AsyncShow()<br />
    {<br />
      if( m_guiThread == null )<br />
      {<br />
        ThreadStart start = new ThreadStart( BackgroundGUIThread );<br />
        m_guiThread = new Thread( start );<br />
        m_guiThread.IsBackground = true;<br />
        m_guiThread.Start();<br />
      }<br />
    }<br />
<br />
    /// <summary><br />
    /// Hide dialog and stop background thread<br />
    /// </summary><br />
    public void Finish()<br />
    {<br />
      try<br />
      {<br />
        lock(this)<br />
        {<br />
          if( m_idThread >= 0 )<br />
          {<br />
            WindowsAPI.PostThreadMessage( (uint)m_idThread, (int)Msg.WM_CLOSE, 0, 0 );<br />
          }<br />
       <br />
          // abort background message loop thread and wait till real thread abort<br />
          m_guiThread.Abort(); <br />
          m_guiThread.Join();<br />
        }<br />
      }<br />
      catch( Exception exc )<br />
      { <br />
        Trace.WriteLine( exc.Message + "\r\n" + exc.StackTrace, "PrgDlg Exception" );<br />
      }<br />
    }<br />
    /// <summary><br />
    /// Background GUI thread<br />
    /// </summary><br />
    private void BackgroundGUIThread()<br />
    {<br />
      Thread.CurrentThread.Name = "Background GUI MsgLoop Thread";<br />
      <br />
      try<br />
      {<br />
        lock( this )<br />
        {<br />
          m_idThread = WindowsAPI.GetCurrentThreadId();<br />
          this.Show();<br />
        }<br />
<br />
        // Create an object for storing windows message information<br />
        MSG msg = new MSG();<br />
<br />
        while( WindowsAPI.GetMessage( ref msg, 0, 0, 0 ) )<br />
        {<br />
          WindowsAPI.TranslateMessage( ref msg );<br />
          WindowsAPI.DispatchMessage( ref msg );<br />
          <br />
          if( msg.message == (int)Msg.WM_CLOSE )<br />
          {<br />
            Trace.WriteLine( "Close", "thread (2)" );<br />
            break;<br />
          }<br />
        }<br />
      }<br />
      finally<br />
      {<br />
        Trace.WriteLine( "Quit thread" );<br />
      }<br />
    }<br />


Good Luck
Alex Kucherenko
GeneralRe: CWinThread equalant? Pin
Anonymous4-Apr-03 6:28
Anonymous4-Apr-03 6:28 
GeneralRe: CWinThread equalant? Pin
MikeKosak1-Mar-11 5:19
MikeKosak1-Mar-11 5:19 
GeneralActive Directory - Users or whatever Pin
Velichko Sarev2-Apr-03 9:32
Velichko Sarev2-Apr-03 9:32 
GeneralGDI+ flicker question Pin
Jon Newman2-Apr-03 9:27
Jon Newman2-Apr-03 9:27 
GeneralRe: GDI+ flicker question Pin
James T. Johnson2-Apr-03 9:41
James T. Johnson2-Apr-03 9:41 
GeneralRe: GDI+ flicker question Pin
Jon Newman2-Apr-03 9:49
Jon Newman2-Apr-03 9:49 
GeneralPressing DELETE button in DataGrid Pin
Mazdak2-Apr-03 7:45
Mazdak2-Apr-03 7:45 
GeneralRe: Pressing DELETE button in DataGrid Pin
Paul Riley2-Apr-03 7:50
Paul Riley2-Apr-03 7:50 
GeneralRe: Pressing DELETE button in DataGrid Pin
Mazdak2-Apr-03 7:53
Mazdak2-Apr-03 7:53 
GeneralRe: Pressing DELETE button in DataGrid Pin
Mazdak2-Apr-03 9:06
Mazdak2-Apr-03 9:06 
GeneralRe: Pressing DELETE button in DataGrid Pin
Mazdak2-Apr-03 9:34
Mazdak2-Apr-03 9:34 
QuestionC# Bitwise Operators? Pin
eidylon2-Apr-03 5:00
eidylon2-Apr-03 5:00 
AnswerRe: C# Bitwise Operators? Pin
James T. Johnson2-Apr-03 5:51
James T. Johnson2-Apr-03 5:51 
GeneralRe: C# Bitwise Operators? Pin
eidylon2-Apr-03 7:49
eidylon2-Apr-03 7:49 
GeneralRe: C# Bitwise Operators? Pin
James T. Johnson2-Apr-03 8:45
James T. Johnson2-Apr-03 8:45 
GeneralRe: C# Bitwise Operators? Pin
eidylon2-Apr-03 8:54
eidylon2-Apr-03 8:54 
GeneralRe: C# Bitwise Operators? Pin
James T. Johnson2-Apr-03 9:03
James T. Johnson2-Apr-03 9:03 

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.