๋ฐ˜์‘ํ˜•

MFC UI ์ฒซ ํฌ์ŠคํŒ…์€ Button Control ์ž…๋‹ˆ๋‹ค.

์‹œ์ž‘ํ•˜๊ธฐ์— ์•ž์„œ, Dialog ๊ธฐ๋ฐ˜ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ฏธ๋ฆฌ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜ ๋งํฌ๋ฅผ ํด๋ฆญํ•ด ์ฃผ์„ธ์š”.

๋งํฌ : MFC Dialog Project ์ƒ์„ฑ


๋ฐ”๋กœ ์‹œ์ž‘ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


1. 'Tool Box' ์—์„œ 'Button Control' ์„ Drag & Drop ๋˜๋Š” ๋งˆ์šฐ์Šค ํด๋ฆญ์œผ๋กœ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.



2. Control ์˜ 'Caption' ๋ฐ 'ID' ๋ฅผ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.


3. ์ƒ์„ฑํ•œ Button ์— Event ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

Control Event ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฒซ ๋ฒˆ์งธ ๋ฐฉ๋ฒ•์œผ๋กœ๋Š”, ๋งˆ์šฐ์Šค ์šฐ ํด๋ฆญํ•˜์—ฌ 'Add Event' ๋ฉ”๋‰ด๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.


4. 'Event Handler Wizard' ๊ฐ€ ์ƒ์„ฑ๋˜๋ฉด 'Class List' ์—์„œ 'CMyButtonDlg' ๋ฅผ ํด๋ฆญํ•˜์—ฌ Main Dialog Class ์— ์ถ”๊ฐ€๋˜๋„๋ก ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.


5. ๋‘ ๋ฒˆ์งธ ๋ฐฉ๋ฒ•์œผ๋กœ๋Š”, Button Control ์„ '๋”๋ธ” ํด๋ฆญ' ํ•ฉ๋‹ˆ๋‹ค. (์ด๊ฒŒ ๋” ๊ฐ„๋‹จํ•˜์ฃ .)


6. Event ๊ฐ€ ์ถ”๊ฐ€๋˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๊ฐ€ ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค.

Message Map ์— ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฉ”์‹œ์ง€๊ฐ€ ์ถ”๊ฐ€๋˜๊ณ ,

'OnBnClickedBtnTest' ํ•จ์ˆ˜๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™์ด ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค.


7. ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ๋ฉ”์‹œ์ง€์ฐฝ ๋ช…๋ น์–ด๋ฅผ ์ถ”๊ฐ€ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.


8. ์ด์ œ Build ํ›„ ์‹คํ–‰ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.


9. ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด ๋ณผ๊นŒ์š”?


์—ฌ๊ธฐ๊นŒ์ง€๊ฐ€ Button Control ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด์—ˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ ํฌ์ŠคํŒ… ๋ถ€ํ„ฐ๋Š” Button Control ์„ ์ข€ ๋” ์ƒ์„ธํ•˜๊ฒŒ ๋‹ค๋ฃจ๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!

๋ฐ˜์‘ํ˜•