Click here to Skip to main content
15,915,324 members
Home / Discussions / C#
   

C#

 
QuestionHow To Create a Image Cup Pin
Anubhava Dimri2-Jul-12 20:42
Anubhava Dimri2-Jul-12 20:42 
AnswerRe: How To Create a Image Cup Pin
Mycroft Holmes2-Jul-12 21:39
professionalMycroft Holmes2-Jul-12 21:39 
AnswerREPOST: How To Create a Image Cup Pin
Dave Kreskowiak3-Jul-12 1:28
mveDave Kreskowiak3-Jul-12 1:28 
QuestionFinger print matching Pin
smithakk2-Jul-12 20:28
smithakk2-Jul-12 20:28 
AnswerRe: Finger print matching Pin
Midnight Ahri2-Jul-12 21:09
Midnight Ahri2-Jul-12 21:09 
AnswerRe: Finger print matching Pin
Mycroft Holmes2-Jul-12 21:34
professionalMycroft Holmes2-Jul-12 21:34 
AnswerRe: Finger print matching Pin
Abhinav S2-Jul-12 22:01
Abhinav S2-Jul-12 22:01 
GeneralHow to read bytes from Stream into Objects? Pin
Software20072-Jul-12 17:27
Software20072-Jul-12 17:27 
GeneralRe: How to read bytes from Stream into Objects? Pin
Richard MacCutchan2-Jul-12 21:47
mveRichard MacCutchan2-Jul-12 21:47 
GeneralRe: How to read bytes from Stream into Objects? Pin
OriginalGriff2-Jul-12 23:25
mveOriginalGriff2-Jul-12 23:25 
GeneralRe: How to read bytes from Stream into Objects? Pin
Richard MacCutchan2-Jul-12 23:39
mveRichard MacCutchan2-Jul-12 23:39 
AnswerRe: How to read bytes from Stream into Objects? Pin
Eddy Vluggen3-Jul-12 1:01
professionalEddy Vluggen3-Jul-12 1:01 
GeneralRe: How to read bytes from Stream into Objects? Pin
Software20073-Jul-12 6:42
Software20073-Jul-12 6:42 
AnswerRe: How to read bytes from Stream into Objects? Pin
Eddy Vluggen3-Jul-12 7:00
professionalEddy Vluggen3-Jul-12 7:00 
GeneralRe: How to read bytes from Stream into Objects? Pin
Software20073-Jul-12 7:35
Software20073-Jul-12 7:35 
QuestionSpellChecker Pin
Murugavel Sadagopan2-Jul-12 15:43
Murugavel Sadagopan2-Jul-12 15:43 
AnswerRe: SpellChecker Pin
Abhinav S2-Jul-12 16:27
Abhinav S2-Jul-12 16:27 
AnswerRe: SpellChecker Pin
Unnikrishnan_S_N3-Jul-12 3:07
Unnikrishnan_S_N3-Jul-12 3:07 
QuestionMessage Removed Pin
2-Jul-12 8:19
professionalN_tro_P2-Jul-12 8:19 
AnswerRe: Modify Top most Pin
Alan N2-Jul-12 9:30
Alan N2-Jul-12 9:30 
This is one of the uses of the Windows SetWindowPos function and is demonstrated with an annoying program that makes all open Notepad windows topmost for 10 seconds. That's just long enough to click on them a few times to confirm the modified behaviour before they revert to normal.

Alan.

C#
using System;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
namespace MakeTopMost {
  internal sealed class App {
    /// <summary>
    /// Flags values for SetWindowPos function
    /// </summary>
    [Flags]
    public enum SWP : uint {
      NOSIZE = 0x0001,
      NOMOVE = 0x0002,
      NOZORDER = 0x0004,
      NOREDRAW = 0x0008,
      NOACTIVATE = 0x0010,
      DRAWFRAME = 0x0020,
      FRAMECHANGED = 0x0020,
      SHOWWINDOW = 0x0040,
      HIDEWINDOW = 0x0080,
      NOCOPYBITS = 0x0100,
      NOOWNERZORDER = 0x0200,
      NOREPOSITION = 0x0200,
      NOSENDCHANGING = 0x0400,
      DEFERERASE = 0x2000,
      ASYNCWINDOWPOS = 0x4000
    }

    // SetWindowPos hwndInsertAfter special values
    // Must cast to IntPtr
    public const Int32 HWND_TOPMOST = -1;
    public const Int32 HWND_NOTOPMOST = -2;

    // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
    [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SetWindowPos(
      [In] IntPtr hWnd,
      [In] IntPtr hWndInsertAfter,
      Int32 X, Int32 Y, Int32 cx, Int32 cy,
      SWP Flags);

    internal static void Main() {
      Process[] ps = Process.GetProcessesByName("notepad");
      foreach (Process p in ps) {
        Console.WriteLine("TopMost");
        MakeTopMost(p.MainWindowHandle);
      }
      Thread.Sleep(10000);
      foreach (Process p in ps) {
        Console.WriteLine("Not TopMost");
        RemoveTopMost(p.MainWindowHandle);
      }
      Console.WriteLine("...end");
      Console.ReadLine();
    }

    private static void MakeTopMost(IntPtr targetHwnd) {
      const SWP flags = SWP.NOSIZE | SWP.NOMOVE;
      SetWindowPos(targetHwnd, (IntPtr)HWND_TOPMOST, 0, 0, 0, 0, flags);
    }

    private static void RemoveTopMost(IntPtr targetHwnd) {
      const SWP flags = SWP.NOSIZE | SWP.NOMOVE;
      SetWindowPos(targetHwnd, (IntPtr)HWND_NOTOPMOST, 0, 0, 0, 0, flags);
    }
  }
}

GeneralMessage Removed Pin
2-Jul-12 10:48
professionalN_tro_P2-Jul-12 10:48 
AnswerRe: Modify Top most Pin
Alan N3-Jul-12 11:03
Alan N3-Jul-12 11:03 
GeneralRe: Modify Top most Pin
Abhinav S2-Jul-12 16:15
Abhinav S2-Jul-12 16:15 
GeneralColor Detection Using Emgu HSV Pin
caoc72-Jul-12 7:12
caoc72-Jul-12 7:12 
AnswerRe: Color Detection Using Emgu Pin
Dave Kreskowiak2-Jul-12 9:01
mveDave Kreskowiak2-Jul-12 9:01 

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.