728x90

Application/C# (WinForm) 37

[C# WinForm] Property 사용 (get & set)

클래스 함수를 사용 중 지역 변수의 값을 수정 혹은 참조하고 싶다면 C# 프로퍼티의 get과 set을 사용하면 된다 사용 법의 경우 아래와 같다 private bool m_bFlag; private string m_strData; public bool IsFlag { get { return m_bFlag; } set { m_bFlag = value; } } public string GetData { get { return m_strData; } } public string SetData { set { m_strData = value; } } 위와 같이 IsFlag 와 같이 한 곳에서 선언하여 사용할 수도 있고 GetData 혹은 SetData 처럼 다르게 선언하여 사용 가능하다 내부에서만 변수를 수정하고..

[C# WinForm] Delegate, Event, Invoke, Cross Thread 사용법

Main Form 외 다른 Class 선언 후 해당 클래스에 추가 Thread로 동작을 하고 있을 시 Main Form의 컨트롤을 제어하고 싶다면 아래처럼 코드를 설계하면 Cross Thread 오류가 나지 않는다 Class 영역 public class MainModule { public delegate void _Delegate(string strMsg); public event _Delegate EventDelegate; private Thread m_h1; public MainModule() { } public bool ServerStart() { m_h1 = new Thread(new ThreadStart(Proc)); m_h1.Start(); } public void ServerStop() { ..

[C# WinForm] INI 파일 읽기 및 쓰기

C# 에서 INI 파일을 읽고 쓰기 위해선 kernel32.dll을 import 하여 사용 하여야 한다 간단한 사용 방법을 예제로 올려본다 using System.Runtime.InteropServices; public class Module { private string m_strINIPath = Application.StartupPath + @"\info.ini"; [DllImport("kernel32")] private static extern long WritePrivateProfileString(string strSection, string strKey, string strVal, string strFilePath); [DllImport("kernel32")] private static exte..

[C# WinForm] 프로그램 광고 달기 (Ads Jumbo)

기본적인 광고의 경우 구글에서 지원하는 광고를 많이 쓴다 (수익이 다른 곳에 비해 좋다) 예를 들어 웹에서는 Google AdSense를 달아서 광고를 하고 모바일 앱에서는 Google AdMob을 이용해 광고를 한다 하지만 윈도우 프로그램에서는 광고 제공을 하지 않고 있다 우회적으로 윈도우 프로그램에 IE을 달아서 할 수도 있지만 기본적으로 윈도우 프로그램에서 광고를 달 수 있게 해주는 패키지를 소개한다 사이트 명은 제목에서 적은 AdsJumbo.com 이라는 곳이다 https://adsjumbo.com/ AdsJumbo.com: Windows App Monetization & Advertising for UWP apps Monetize your Windows 10 apps & games with be..

[C# WinForm] 자석 효과 구현

부모폼에 착착 달라붙는 자석효과 자식폼 생성하기 //Snap Class 부분 using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; class CSnap { [StructLayout(LayoutKind.Sequential)] private struct WINDOWPOS { public IntPtr hwnd; public IntPtr hwndInsertAfter; public Int32 x; public Int32 y; public Int32 cx; public Int32 cy; public UInt32 flags; }; bool bDock = false; private Form ..

[C# WinForm] 마우스 커서 정보 얻기

현재 마우스의 커서 위치 및 마우스 커서의 모양을 알고자 할때 쓰는 유용한 함수 Class using System; using System.Drawing; using System.Runtime.InteropServices; class CGetCursor { [StructLayout(LayoutKind.Sequential)] public struct ICONINFO { public bool fIcon; public Int32 xHotspot; public Int32 yHotspot; public IntPtr hbmMask; public IntPtr hbmColor; } [StructLayout(LayoutKind.Sequential)] public struct CURSORINFO { public Int32..

728x90
반응형