코딩/C# 썸네일형 리스트형 [C#] 남아있는 Process Kill System.Diagnostics.Process[] pros = System.Diagnostics.Process.GetProcessesByName("Test_Process"); //Process name foreach (System.Diagnostics.Process p in pros) { p.Kill(); } 더보기 [C#] Global Keyboard Hooking class globalKeyboardHook { #region Constant, Structure and Delegate Definitions /// /// defines the callback type for the hook /// public delegate int keyboardHookProc(int code, int wParam, ref keyboardHookStruct lParam); private static keyboardHookProc callbackDelegate; public struct keyboardHookStruct { public int vkCode; public int scanCode; public int flags; public int time; public int dwExt.. 더보기 [C#] 스크롤 이벤트 private void Mouse_Wheel(object sender, MouseEventArgs e) { if (e.Delta this.vScrollBar1.Maximum) { this.vScrollBar1.Value = this.vScrollBar1.Maximum; } else { this.vScrollBar1.Value = this.vScrollBar1.Value + Math.Abs(e.Delta); } } else if (e.Delta > 0 && this.vScrollBar1.Value > 0) //스크롤 올릴때 { if (this.vScrollBar1.Value - Math.A.. 더보기 [코딩] Linefeed 방지 private void txtYourTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) e.SuppressKeyPress=true; } 1. KeyDown/KeyUp 핸들러에서 Handled 속성을 true로 설정하면 KeyPress로 처리되는 문자를 제외한 키 입력 처리가 되지 않는다. 즉, 문자열 입력은 정상적으로 되지만 방향키나 Home/End 등이 제대로 동작하지 않는다. 엔터키의 경우는 문자열로 취급되기 때문에 KeyPress가 호출되어 전달은 되지만 시스템적인 처리(라인피드 등)는 되지 않는다. 2. KeyPress 핸들러에서 Handled 속성을 true로 설정하면 C# TextBox(Rich 포함)에서 .. 더보기 [코딩] 3 var obj = sender as TextBox; int left, right, bottom, top; var curserPos = System.Windows.Forms.Control.MousePosition; curserPos = this.PointToClient(curserPos); left = obj.Location.X; right = obj.Location.X + obj.Size.Width; bottom = obj.Location.Y + obj.Size.Height; top = obj.Location.Y; if (left curserPos.X && bottom curserPos.Y) return; if (tex.. 더보기 [코딩] 2 var obj = sender as Label; int left, right, bottom, top; var curserPos = System.Windows.Forms.Control.MousePosition; curserPos = this.PointToClient(curserPos); left = obj.Location.X; right = obj.Location.X + obj.Size.Width; bottom = obj.Location.Y + obj.Size.Height; top = obj.Location.Y; if (left curserPos.X && bottom > curserPos.Y && top < curserPos.Y) return; if (textB.. 더보기 [코딩] 1 if (textBox1.Visible == ) { textBox1.Visible = true; var obj = ()sender; var langth = obj.Text.Length; int varticalLineCount = (langth / 100) + 1; var StandardHeight = 10; var hight = StandardHeight * varticalLineCount; textBox1.Size = new >Size(obj.Size.Width, hight); var currntPos = obj.Location; textBox1.Location = new Point(10 + currntPos.X, 10 + currntPos.Y);//obj.Location; textBox1.Text = .. 더보기 [C#] 제네릭(Generics) 제네릭은 int, float, double 같은 데이타 요소 타입을 확정하지 않고 이 데이타 타입 자체를 타입파라미터로 받아들이도록 클래스를 정의한다. 클래스를 사용시 클래스명과 사용타입을 함께 지정해 사용한다. 사용시 같은 타입 파라미터를 붙여 구현한다.제네릭의 장점- 캐스팅으로 인한 낭비가 줄어듬- 형식의 안정성- 박싱, 언박싱으로 인한 부하가 없다.제네릭의 제약조건제네릭 타입인수 T는 별다른 지정이 없으면 object이므로 object의 메서드만 사용할 수 있다.제약 조건 설 명 where T : struct T는 값 타입이어야 하며 참조 타입을 쓸 수 없다. 단 Nullable 타입은 값 타입이지만 예외적으로 이 제약 조건에서 허용되지 않는다. where T : class T는 참조 타입이어야 하.. 더보기 [C#] 인터페이스와 추상클래스 인터페이스와 추상클래스의 공통점1. 스스로 객체를 생성할 수 없다.2. 업캐스팅이 가능하다.3. 모든 추상 멤버를 구현해야한다.4. 추상클래스와 인터페이스의 추상함수는 가상함수이다. 인터페이스1. 변수 선언 불가능2. 함수 구현 불가능(선언만 가능)3. 접근제한자는 쓸 수 없으며 public으로 자동선언된다.4. 인터페이스는 인터페이스들 끼리의 상속과 중복구현이 가능하다. interface IRunnable { int nVar; // 변수 선언 불가능 void Run(); //함수 선언 가능 void Fly() {...} // 함수 구현 불가능 } class Runner : IRunnable { private void Run() {...} //private 불가능, public만 가능 } interfac.. 더보기 [C#] 언박싱(UnBoxing) 언박싱은 박싱된 참조타입을 다시 값타입으로 변환하는 것을 말한다. 언박싱의 순서 1. 해당 객체가 지정한 값타입을 Boxing한 값인지 확인한다. 2. 박싱된 객체라면 객체의 값을 값타입 변수에 복사한다. 3. 박싱한 메모리와 언박싱한 메모리 두개가 존재한다. (스택에 생성된 메모리와 힙메모리는 전혀 별개의 메모리이다.) using System; class UnBoxing{ public static void Main(){ int b=123; object o = b; // boxing int ub = (int) o; // unboxing은 명시적으로 캐스팅해주어야한다. Console.WriteLine("b = " + b); Console.WriteLine("ub = " + ub); Console.Write.. 더보기 이전 1 2 다음