mirror of
				https://github.com/raylib-cs/raylib-cs
				synced 2025-11-02 05:06:44 -05:00 
			
		
		
		
	- Added DrawControl class to test windows forms with raylib. Need a way to get the window handle?
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Drawing;
 | 
						|
using System.Runtime.InteropServices;
 | 
						|
using System.Windows.Forms;
 | 
						|
 | 
						|
namespace Raylib
 | 
						|
{
 | 
						|
    class DrawControl : Form
 | 
						|
    {
 | 
						|
        private Panel panel;
 | 
						|
 | 
						|
        [DllImport("user32.dll")]
 | 
						|
        private static extern IntPtr SetParent(IntPtr child, IntPtr newParent);
 | 
						|
        [DllImport("user32.dll")]
 | 
						|
        private static extern IntPtr ShowWindow(IntPtr handle, int command);
 | 
						|
 | 
						|
        public static void Run()
 | 
						|
        {
 | 
						|
            Application.EnableVisualStyles();
 | 
						|
            Application.SetCompatibleTextRenderingDefault(false);
 | 
						|
            Application.Run(new DrawControl());
 | 
						|
        }
 | 
						|
 | 
						|
        public DrawControl()
 | 
						|
        {
 | 
						|
            panel = new Panel();
 | 
						|
            panel.Size = new Size(640, 480);
 | 
						|
            panel.Location = new Point(80, 10);
 | 
						|
            panel.BackColor = System.Drawing.Color.Red;
 | 
						|
            Controls.Add(panel);
 | 
						|
 | 
						|
            // TODO: get raylib window handle?
 | 
						|
            IntPtr winHandle = IntPtr.Zero;
 | 
						|
            SetParent(winHandle, panel.Handle);
 | 
						|
            ShowWindow(winHandle, 1);
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |