Posts

Showing posts with the label winforms

What is the correct way to call an extension method (TreeNodeCollection Add method)?

What is the correct way to call an extension method (TreeNodeCollection Add method)? The pertinent parts of my code are below. In the MyTreeView class (last block of code below), the line of code TncExtensions.TncNodeAdd(this, myTreeViewNode); generates the error CS7036 There is no argument given that corresponds to the required formal parameter 'myTreeViewNode' of 'TncExtensions.TncNodeAdd(TreeNodeCollection, MyTreeView_Abstract, MyTreeViewNode_Abstract)' MyTreeView TncExtensions.TncNodeAdd(this, myTreeViewNode); CS7036 There is no argument given that corresponds to the required formal parameter 'myTreeViewNode' of 'TncExtensions.TncNodeAdd(TreeNodeCollection, MyTreeView_Abstract, MyTreeViewNode_Abstract)' Why can't the compiler figure out what the 2nd formal parameter is for my TreeNodeCollection extension method? public static class TncExtensions { public static int TncNodeAdd(this TreeNodeCollection nodes, MyTreeView_Abstract myTreeView, ...

GetCursorInfo WinForms vs WPF C#

GetCursorInfo WinForms vs WPF C# I am having trouble of transferring pieces of my code from WinForms to WPF to have better control over the UI. The following piece of code return True in WinForms but False in WPF. I suspect WPF panels have effects on the cursor so I tried start the app minimized but it still failed. Since the GetCursorInfo is PInvoke I think it should work the same within a programming language. Any advices on this? private CURSORINFO ci; [StructLayout(LayoutKind.Sequential)] public struct CURSORINFO { public Int32 cbSize; // Specifies the size, in bytes, of the structure. public Int32 flags; // Specifies the cursor state. public IntPtr hCursor; // Handle to the cursor. Point point; // Should already marshal correctly. } [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetCursorInfo(ref CURSORINFO pci); public MainWindow() { ...