Example #1
0
        private static void Main()
        {
            const string szAppName = "OwnDraw";

            ModuleInstance  module   = ModuleInstance.GetModuleForType(typeof(Program));
            WindowClassInfo wndclass = new WindowClassInfo
            {
                Style           = ClassStyle.HorizontalRedraw | ClassStyle.VerticalRedraw,
                WindowProcedure = WindowProcedure,
                Instance        = module,
                Icon            = IconId.Application,
                Cursor          = CursorId.Arrow,
                Background      = StockBrush.White,
                ClassName       = szAppName
            };

            Windows.RegisterClass(ref wndclass);

            WindowHandle window = Windows.CreateWindow(
                szAppName,
                "Owner-Draw Button Demo",
                WindowStyles.OverlappedWindow,
                bounds: Windows.DefaultBounds,
                instance: module);

            window.ShowWindow(ShowWindowCommand.Normal);
            window.UpdateWindow();

            while (Windows.GetMessage(out WindowMessage message))
            {
                Windows.TranslateMessage(ref message);
                Windows.DispatchMessage(ref message);
            }
        }
Example #2
0
        static void Main()
        {
            // Hack for launching as a .NET Core Windows Application
            WInterop.Console.Console.TryFreeConsole();

            const string szAppName = "RandRect";

            ModuleInstance  module   = ModuleInstance.GetModuleForType(typeof(Program));
            WindowClassInfo wndclass = new WindowClassInfo
            {
                Style           = ClassStyle.HorizontalRedraw | ClassStyle.VerticalRedraw,
                WindowProcedure = WindowProcedure,
                Instance        = module,
                Icon            = IconId.Application,
                Cursor          = CursorId.Arrow,
                Background      = StockBrush.White,
                ClassName       = szAppName
            };

            Windows.RegisterClass(ref wndclass);

            WindowHandle window = Windows.CreateWindow(
                szAppName,
                "Random Rectangles",
                WindowStyles.OverlappedWindow,
                bounds: Windows.DefaultBounds,
                instance: module);

            window.ShowWindow(ShowWindowCommand.Normal);
            window.UpdateWindow();

            while (true)
            {
                if (Windows.PeekMessage(out WindowMessage message, options: PeekMessageOptions.Remove))
                {
                    if (message.Type == MessageType.Quit)
                    {
                        break;
                    }
                    Windows.TranslateMessage(ref message);
                    Windows.DispatchMessage(ref message);
                }

                // We're crazy fast 20 years past the source sample,
                // sleeping to make this a bit more interesting.
                Thread.Sleep(100);
                DrawRectangle(window);
            }
        }
Example #3
0
        static void Main()
        {
            // Hack for launching as a .NET Core Windows Application
            WInterop.Console.Console.TryFreeConsole();

            const string szAppName = "HelloWin";

            ModuleInstance  module   = ModuleInstance.GetModuleForType(typeof(Program));
            WindowClassInfo wndclass = new WindowClassInfo
            {
                Style           = ClassStyle.HorizontalRedraw | ClassStyle.VerticalRedraw,
                WindowProcedure = WindowProcedure,
                Instance        = module,
                Icon            = IconId.Application,
                Cursor          = CursorId.Arrow,
                Background      = StockBrush.White,
                ClassName       = szAppName
            };

            Windows.RegisterClass(ref wndclass);

            WindowHandle window = Windows.CreateWindow(
                szAppName,
                "The Hello Program",
                WindowStyles.OverlappedWindow,
                instance: module,
                bounds: Windows.DefaultBounds);

            window.ShowWindow(ShowWindowCommand.Normal);
            window.UpdateWindow();

            while (Windows.GetMessage(out WindowMessage message))
            {
                Windows.TranslateMessage(ref message);
                Windows.DispatchMessage(ref message);
            }
        }