File: Caret.cs

package info (click to toggle)
hexbox 1.5.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,440 kB
  • ctags: 1,210
  • sloc: cs: 6,784; makefile: 21; sh: 1
file content (71 lines) | stat: -rw-r--r-- 1,989 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
´╗┐using System;

namespace Be.Windows.Forms
{
    internal static class Caret
    {
        public static bool Create(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight)
        {
            try
            {
                return NativeMethods.CreateCaret(hWnd, hBitmap, nWidth, nHeight);
            }
            catch (Exception ex)
            {
                // Let's pretend CreateCaret() is available on Linux
                if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
                    return true;

                throw;
            }
        }

        public static bool Show(IntPtr hWnd)
        {
            try
            {
                return NativeMethods.ShowCaret(hWnd);
            }
            catch (Exception ex)
            {
                // Let's pretend ShowCaret() is available on Linux
                if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
                    return true;

                throw;
            }
        }

        public static bool Destroy()
        {
            try
            {
                return NativeMethods.DestroyCaret();
            }
            catch (Exception ex)
            {
                // Let's pretend DestroyCaret() is available on Linux
                if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
                    return true;

                throw;
            }
        }

        public static bool SetPos(int X, int Y)
        {
            try
            {
                return NativeMethods.SetCaretPos(X, Y);
            }
            catch (Exception ex)
            {
                // Let's pretend SetCaretPos() is available on Linux
                if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
                    return true;

                throw;
            }
        }
    }
}