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
G

goldli88

@goldli88
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C# , how to create object instance by using expression
    G goldli88

    I'm trying to using expression to create object instance, but i got an error 'System.Reflection.TargetParameterCountException'. my code is bellow , and i don't know what's the problem, please help. using BenchmarkDotNet.Attributes; using FastExpressionCompiler.LightExpression; using FastMember; using System; using System.Collections.Concurrent; using System.Diagnostics; using System.Reflection; using System.Threading.Tasks; using static FastExpressionCompiler.LightExpression.ExpressionCompiler; namespace ConsoleApp2 { public class Program { static void Main(string[] args) { TestExpressionCreate(); TestActivatorCreate(); //var summary = BenchmarkRunner.Run(); Console.ReadLine(); } #region [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public class FieldAttribute : Attribute { private bool _isSizeExtracted; private string _size; public FieldAttribute(string dataType = null) { if (!string.IsNullOrWhiteSpace(dataType)) { DataType = dataType.ToLower(); } } public int? Index { get; set; } public string FieldName { get; set; } public bool HasDefaultValue { get; set; } public string DataType { get; set; } internal string Size { get { if (string.IsNullOrWhiteSpace(DataType)) return null; if (!_isSizeExtracted) { _isSizeExtracted = true; var i = DataType.IndexOf('('); if (i > 0) { var j = DataType.IndexOf(')', i); if (j > 0) { //_size = DataType[(i + 1)..j]; } } } return _size; } } } internal class TableInfo { } internal class FieldInfoBase { internal int Index { get; set; } internal string FieldName { get; set; } internal bool HasDefaultValue

    C# help csharp database tutorial question

  • GetGuiThreadInfo can not get the caret's position
    G goldli88

    I want to get the caret position with my C# application.but in some cases ,GetGuiThreadInfo does not work creectly. it works well on 1. notepad 2. ie 3. explorer 4. word and works bad on (hwndCaret will be 0) 1. Visual Studio 2. Firefox 3. Sublime Text 2 Anyone who can helps me?

    public partial class Form1 : Form
    {

            \[DllImport("user32.dll")\]
            public static extern IntPtr GetForegroundWindow();
    
            \[DllImport("user32.dll", CharSet = CharSet.Auto)\]
            public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
            
            \[DllImport("user32.dll")\]
            static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);
    
            \[DllImport("user32.dll")\]
            static extern bool GetGUIThreadInfo(uint idThread, ref GUITHREADINFO lpgui);
    
    
            \[StructLayout(LayoutKind.Sequential)\]
            public struct GUITHREADINFO
            {
                public int cbSize;
                public int flags;
                public IntPtr hwndActive;
                public IntPtr hwndFocus;
                public IntPtr hwndCapture;
                public IntPtr hwndMenuOwner;
                public IntPtr hwndMoveSize;
                public IntPtr hwndCaret;
                public Rectangle rectCaret;
            }
    
            public  GUITHREADINFO? GetGuiThreadInfo(IntPtr hwnd)
            {
                if (hwnd != IntPtr.Zero)
                {
                    uint threadId = GetWindowThreadProcessId(hwnd, IntPtr.Zero);
    
                    GUITHREADINFO guiThreadInfo = new GUITHREADINFO();
                    guiThreadInfo.cbSize = Marshal.SizeOf(guiThreadInfo);
    
                    if (GetGUIThreadInfo(threadId, ref guiThreadInfo) == false)
                        return null;
                    return guiThreadInfo;
                }
                return null;
            }
    
            public void SendText(string text)
            {
                IntPtr hwnd = GetForegroundWindow();
                if (String.IsNullOrEmpty(text))
                    return;
                GUITHREADINFO? guiInfo = GetGuiThreadInfo(hwnd);
                AddMessage("go");
                if (guiInfo != null)
                {
                    IntPtr ptr = (IntPtr)guiInfo.Value.hwndCaret;
                    AddMessage("hwndCaret = " + ptr.ToInt32());
    
    C# csharp visual-studio question
  • Login

  • Don't have an account? Register

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