기본 콘텐츠로 건너뛰기

C++ - SetWindowLong/GetWindowLong

해당 윈도우에 설정을 변경하거나 사용자의 특별한 정보(Data )를 저장하고 싶을때 사용하는 API.
만약 Window를 하나 만들면서 그 Window를 생성한 부모의 Window정보를 저장하고 싶거나 생성한 Window가 List용인지 Popup용인지를 알수 있도록 Window의 태생 정보를 저장해 두고 싶을 때 사용.
물론 이 API를 사용하지 않고 Window의 정보를 저장할 수 있는 방법은 많지만 별도의 저장 공간도 필요하고 관리 메커니즘도 필요.

Window 가 생성될때 소멸될때 일일이 처리 해 줘야 하니 SetWindowLong / GetWindowLong으로 깔끔하게 해결 할 수 있음.

댓글

이 블로그의 인기 게시물

C# - Serial Port ASCII/HEX Format

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace SerialTest1 {     public partial class Form1 : Form     {         delegate void MyDelegate();      //델리게이트 선언(크로스 쓰레드 해결하기 위한 용도)         bool SendForamt = true;          // true : ASCII   false : HEX         bool ReceiveFormat = true;       // true : ASCII   false : HEX         public Form1()         {             InitializeComponent();          ...

C# - Windows Form 에 있는 control 찾기

// 아래 코드는 form 의 최상위 control만 찾을 수 있음. // panle, groubbox ... 내부에 있는 control은 찾지 못함. Control GetControlByName(string Name) {     foreach (Control c in this.Controls)         if (c.Name == Name)             return c;     return null; } // form 의 모든 control을 찾을 수 있음. string name = "btnBit" + (i + 1).ToString("D2"); var tmpBtn = this.Controls.Find(name, true).FirstOrDefault(); if (tmpBtn != null) {     if (value == 1) tmpBtn.BackColor = Color.Lime;     else tmpBtn.BackColor = Color.Gray; }