Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Creating blinking I-Beam

Creating blinking I-Beam

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vertyg0
    wrote on last edited by
    #1

    Anyone got idea how to create blinking I-Beam cursor like one that has textbox when it receive focus? Can I do it trough unmanaged code or I need to implement it with timers/overriding OnPaint event? Thanks, Ivan.

    L 1 Reply Last reply
    0
    • V Vertyg0

      Anyone got idea how to create blinking I-Beam cursor like one that has textbox when it receive focus? Can I do it trough unmanaged code or I need to implement it with timers/overriding OnPaint event? Thanks, Ivan.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi .... I hope this Example will help you ... I used 2 Files - mycaret.cs (Class) - caretsample.cs ( Example How to use it ) Optional File : mycaret.cs using System; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing; public class MyCaret { [DllImport("user32.dll")] public static extern int CreateCaret(IntPtr hwnd, IntPtr hbm, int cx, int cy); [DllImport("user32.dll")] public static extern int DestroyCaret(); [DllImport("user32.dll")] public static extern int SetCaretPos(int x, int y); [DllImport("user32.dll")] public static extern int ShowCaret(IntPtr hwnd); [DllImport("user32.dll")] public static extern int HideCaret(IntPtr hwnd); Control ctrl; Size size; Point pos; bool bVisible; public MyCaret(Control ctrl) { this.ctrl = ctrl; Position = Point.Empty; Size = new Size(1, ctrl.Font.Height); Control.GotFocus += new EventHandler(OnGotFocus); Control.LostFocus += new EventHandler(OnLostFocus); if (ctrl.Focused) OnGotFocus(ctrl, new EventArgs()); } public Control Control { get { return ctrl; } } public Size Size { get { return size; } set { size = value; } } public Point Position { get { return pos; } set { pos = value; SetCaretPos(pos.X, pos.Y); } } public bool Visible { get { return bVisible; } set { bVisible = value; if (bVisible) ShowCaret(Control.Handle); else HideCaret(Control.Handle); } } public void Dispose() { if (ctrl.Focused) OnLostFocus(ctrl, new EventArgs()); Control.GotFocus -= new EventHandler(OnGotFocus); Control.LostFocus -= new EventHandler(OnLostFocus); } private void OnGotFocus(object sender, EventArgs e) { CreateCaret(Control.Handle, IntPtr.Zero, Size.Width, Size.Height); SetCaretPos(Position.X, Position.Y); Visible = true; } private void OnLostFocus(object sender, EventArgs e) { Visible = false; DestroyCaret(); } } caretsample.cs using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Runtime.InteropServices; public class MyForm : Form { private Container components = null; MyCaret caret; string[] lines; Point cur; Point org; bool bSel; public MyFor

      V L 2 Replies Last reply
      0
      • L Lost User

        Hi .... I hope this Example will help you ... I used 2 Files - mycaret.cs (Class) - caretsample.cs ( Example How to use it ) Optional File : mycaret.cs using System; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing; public class MyCaret { [DllImport("user32.dll")] public static extern int CreateCaret(IntPtr hwnd, IntPtr hbm, int cx, int cy); [DllImport("user32.dll")] public static extern int DestroyCaret(); [DllImport("user32.dll")] public static extern int SetCaretPos(int x, int y); [DllImport("user32.dll")] public static extern int ShowCaret(IntPtr hwnd); [DllImport("user32.dll")] public static extern int HideCaret(IntPtr hwnd); Control ctrl; Size size; Point pos; bool bVisible; public MyCaret(Control ctrl) { this.ctrl = ctrl; Position = Point.Empty; Size = new Size(1, ctrl.Font.Height); Control.GotFocus += new EventHandler(OnGotFocus); Control.LostFocus += new EventHandler(OnLostFocus); if (ctrl.Focused) OnGotFocus(ctrl, new EventArgs()); } public Control Control { get { return ctrl; } } public Size Size { get { return size; } set { size = value; } } public Point Position { get { return pos; } set { pos = value; SetCaretPos(pos.X, pos.Y); } } public bool Visible { get { return bVisible; } set { bVisible = value; if (bVisible) ShowCaret(Control.Handle); else HideCaret(Control.Handle); } } public void Dispose() { if (ctrl.Focused) OnLostFocus(ctrl, new EventArgs()); Control.GotFocus -= new EventHandler(OnGotFocus); Control.LostFocus -= new EventHandler(OnLostFocus); } private void OnGotFocus(object sender, EventArgs e) { CreateCaret(Control.Handle, IntPtr.Zero, Size.Width, Size.Height); SetCaretPos(Position.X, Position.Y); Visible = true; } private void OnLostFocus(object sender, EventArgs e) { Visible = false; DestroyCaret(); } } caretsample.cs using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Runtime.InteropServices; public class MyForm : Form { private Container components = null; MyCaret caret; string[] lines; Point cur; Point org; bool bSel; public MyFor

        V Offline
        V Offline
        Vertyg0
        wrote on last edited by
        #3

        Thanks alot !

        1 Reply Last reply
        0
        • L Lost User

          Hi .... I hope this Example will help you ... I used 2 Files - mycaret.cs (Class) - caretsample.cs ( Example How to use it ) Optional File : mycaret.cs using System; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing; public class MyCaret { [DllImport("user32.dll")] public static extern int CreateCaret(IntPtr hwnd, IntPtr hbm, int cx, int cy); [DllImport("user32.dll")] public static extern int DestroyCaret(); [DllImport("user32.dll")] public static extern int SetCaretPos(int x, int y); [DllImport("user32.dll")] public static extern int ShowCaret(IntPtr hwnd); [DllImport("user32.dll")] public static extern int HideCaret(IntPtr hwnd); Control ctrl; Size size; Point pos; bool bVisible; public MyCaret(Control ctrl) { this.ctrl = ctrl; Position = Point.Empty; Size = new Size(1, ctrl.Font.Height); Control.GotFocus += new EventHandler(OnGotFocus); Control.LostFocus += new EventHandler(OnLostFocus); if (ctrl.Focused) OnGotFocus(ctrl, new EventArgs()); } public Control Control { get { return ctrl; } } public Size Size { get { return size; } set { size = value; } } public Point Position { get { return pos; } set { pos = value; SetCaretPos(pos.X, pos.Y); } } public bool Visible { get { return bVisible; } set { bVisible = value; if (bVisible) ShowCaret(Control.Handle); else HideCaret(Control.Handle); } } public void Dispose() { if (ctrl.Focused) OnLostFocus(ctrl, new EventArgs()); Control.GotFocus -= new EventHandler(OnGotFocus); Control.LostFocus -= new EventHandler(OnLostFocus); } private void OnGotFocus(object sender, EventArgs e) { CreateCaret(Control.Handle, IntPtr.Zero, Size.Width, Size.Height); SetCaretPos(Position.X, Position.Y); Visible = true; } private void OnLostFocus(object sender, EventArgs e) { Visible = false; DestroyCaret(); } } caretsample.cs using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Runtime.InteropServices; public class MyForm : Form { private Container components = null; MyCaret caret; string[] lines; Point cur; Point org; bool bSel; public MyFor

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          I see this same #$%# in lotsa managed code (see SharpDevelop too)! Why??? A managed caret is just as easy to make...

          **

          xacc.ide-0.2.0.57 - now with C# 2.0 parser and seamless VS2005 solution support!

          **

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups