예제 #1
0
		static public RECT RECTFromRectangle(Rectangle rc)
		{
			RECT rect = new RECT();
			rect.left = rc.Left;
			rect.top = rc.Top;
			rect.right = rc.Left + rc.Width;
			rect.bottom = rc.Top + rc.Height;
			return rect;
		}
예제 #2
0
		public static Size GetTextSize(Graphics graphics, string text, Font font)
		{
			IntPtr hdc = graphics.GetHdc();
			IntPtr fontHandle = font.ToHfont();
			IntPtr currentFontHandle = WindowsAPI.SelectObject(hdc, fontHandle);
			
			RECT rect = new RECT();
			rect.left = 0;
			rect.right = 0;
			rect.top = 0;
			rect.bottom = 0;
		
			WindowsAPI.DrawText(hdc, text, text.Length, ref rect, 
				(int)(DrawTextFormatFlags.DT_SINGLELINE | DrawTextFormatFlags.DT_LEFT | DrawTextFormatFlags.DT_CALCRECT));
			WindowsAPI.SelectObject(hdc, currentFontHandle);
			WindowsAPI.DeleteObject(fontHandle);
			graphics.ReleaseHdc(hdc);
				
			return new Size(rect.right - rect.left, rect.bottom - rect.top);
		}
예제 #3
0
		public static void DrawText(Graphics graphics, string text, Font font, Rectangle rect)
		{
			IntPtr hdc = graphics.GetHdc();
			IntPtr fontHandle = font.ToHfont();
			IntPtr currentFontHandle = WindowsAPI.SelectObject(hdc, fontHandle);
			WindowsAPI.SetBkMode(hdc, BackgroundMode.TRANSPARENT);
           						
            RECT rc = new RECT();
			rc.left = rect.Left;
			rc.top = rect.Top;
			rc.right = rc.left + rect.Width;
			rc.bottom = rc.top + rect.Height;
			
			WindowsAPI.DrawText(hdc, text, text.Length, ref rc, 
				(int)(DrawTextFormatFlags.DT_SINGLELINE | DrawTextFormatFlags.DT_LEFT 
				| DrawTextFormatFlags.DT_MODIFYSTRING| DrawTextFormatFlags.DT_WORD_ELLIPSIS));
			WindowsAPI.SelectObject(hdc, currentFontHandle);
			WindowsAPI.DeleteObject(fontHandle);
			graphics.ReleaseHdc(hdc);
		}
예제 #4
0
		static public Rectangle RectangleFromRECT(RECT rc)
		{
			return new Rectangle(rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
		}
예제 #5
0
		static public extern bool ValidateRect(IntPtr hWnd, ref RECT rcInvalidated);
예제 #6
0
		public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref RECT lParam);
예제 #7
0
		public extern static int GetClientRect(IntPtr hWnd, ref RECT rc);
예제 #8
0
		public extern static int InvalidateRect(IntPtr hWnd,  ref RECT rc, int bErase);
예제 #9
0
		public static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
예제 #10
0
		static public extern bool GetMenuItemRect(IntPtr hWnd, IntPtr hMenu, uint Item, ref RECT rc);
예제 #11
0
		public extern static int DrawText(IntPtr hdc, string lpString, int nCount, ref RECT lpRect, DrawTextFormatFlags flags);
예제 #12
0
		public extern static int DrawText(IntPtr hdc, string lpString, int nCount, ref RECT lpRect, int uFormat);
예제 #13
0
 static public Rectangle RectangleFromRECT(RECT rc)
 {
     return(new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top));
 }