기본 콘텐츠로 건너뛰기

C++ - SendMessage - MESSAGE_HANDLER 예제

define.h
#define     TM_START   WM_USER + 2000        // 자동검사시작
#define     TM_STOP   WM_USER + 2001        // 검사중지


FormMeasureInfo.cpp
SendMessage(BaseForm->nForm[stage]->Handle, TM_START, 0, 0);

FormTotal.h
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(TM_START, TMessage, OnStart)
MESSAGE_HANDLER(TM_STOP , TMessage, OnStop)
MESSAGE_HANDLER(TM_SIZE  , TMessage, OnSize)
MESSAGE_HANDLER(TM_IR  , TMessage, OnIr)
MESSAGE_HANDLER(TM_OCV  , TMessage, OnOcv)
END_MESSAGE_MAP(TForm)

void __fastcall OnStart(TMessage& Msg);    // 상태 전환
void __fastcall OnStop(TMessage& Msg); // 수동 시작


FormTotal.cpp
void __fastcall TTotalForm::OnStart(TMessage& Msg){}


SendMessage(TM_START) -> MESSAGE_HANDLER(TM_START,  TMessage, OnStart)  -> OnStart(TMessage& Msg)

댓글

이 블로그의 인기 게시물

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; }