@ 2004-06-16 @
^^* ¿©±â¿¡ Á¤¸®µÈ ³»¿ëÀº Ã¥°ú ÀÎÅÍ³Ý µîÀ» Âü°í·Î °³ÀÎÀûÀÎ ¸ñÀûÀ¸·Î Á¤¸®
1 ±âŸ ##.Control* ( (CDirect9MFCView *)(((CMainFrame *)m_pMainWnd)->GetActiveView()) )->OpenFileMapData(); * if( GetAsyncKeyState( 'F' )) Isfollow = !Isfollow;
if( GetAsyncKeyState( 'T' )) IsThreat = IsThreat;
* MFC¿¡¼ Escape Å°Á¤ÀÇif( GetAsyncKeyState( 'H' )) IsHeat = IsHeat; if( GetAsyncKeyState( 'Z' )) IsZoom = IsZoom;
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
* MessageBox(NULL, "BuildHeightMap- Error", "Cannot found", 0);BEGIN
VK_ESCAPE, ID_APP_EXIT, VIRTKEY, NOINVERT
END...... 2 (MFC) Class #2.1 (MFC) CImage Ŭ·¡½º #CImage´Â MS¿¡¼ .net ÀÌÈĺÎÅÍ Á¦°øµÇ´Â ±×¸² °ü·Ã Ŭ·¡½º·ÎÀÌÀü CBitmapÀÇ bmp¸¸ ´Ù·ç´ø°Å¿¡¼ Á»´õ È®ÀåÇÏ¿© Png, Jpg, gifµî ´Ù¾çÇÑ Æ÷¸äÀ» Áö¿øÇÑ´Ù.
CImage ¸¦ ÀÌ¿ëÇϸé À̹ÌÁö ·ÎµùÀº ¹°·ÐÀÌ°í
ÁöÁ¤ÇÑ Æ÷¸ËÀÇ À̹ÌÁö ÆÄÀÏÀ» ¸¸µå´Â°Í ¶ÇÇÑ °£´ÜÈ÷ ÇÒ¼ö ÀÖ´Ù.
// View::OnPaint()
// À̹ÌÁö°¡ ÀúÀåµÈ À§Ä¡
//¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤ÑCString strImagePath = _T("Image.bmp"); // CImage Ŭ·¡½º º¯¼ö¸¦ »ý¼ºÇÑ´Ù. CImage Image; // ÀúÀå µÈ À§Ä¡¿¡ À̹ÌÁö¸¦ ºÒ·¯¿Â´Ù. HRESULT hResult = Image.Load( strImagePath ); // À̹ÌÁö¸¦ ºÒ·¯ ¿À´Âµ¥ ½ÇÆÐ ÇßÀ» °æ¿ì. if( FAILED( hResult ) ) {
CString strtmp = _T("ERROR : Failed to load");
}strtmp += strImagePath + _T("\n"); TRACE(strtmp); return; // ÇÁ·Î±×·¥ÀÌ Á¾·á µÇÁö ¾Ê¾Ò´Ù¸é À̹ÌÁö°¡ Á¤»óÀûÀ¸·Î ºÒ·¯¿ÍÁø °ÍÀÌ´Ù. // À̹ÌÁö¸¦ Ãâ·ÂÇØ º¸ÀÚ. Image.TransparentBlt( dc.m_hDC, 0, 0, Image.GetWidth(), Image.GetHeight(), RGB(255, 0, 0) ); Image.BitBlt( dc.m_hDC, 300, 0 ); // Èæ¹éÀ¸·Î º¯°æÇØ º¸ÀÚ. COLORREF rgb; for( int x=0; x<Image.GetWidth(); ++x ) { } // Èæ¹éÀÇ À̹ÌÁö Ãâ·Â Image.BitBlt( dc.m_hDC, 0, 300 ); // View.cpp ; Èæ¹éÀ¸·Î º¯°æÇÏ´Â ¾Ë°í¸®Áò //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ inline void RGBtoGray( COLORREF& rgb ) { } 2.1.2 CImage¸¦ ÀÌ¿ëÇÑ À̹ÌÁö ÆÄÀÏ Æ÷¸Ë º¯È¯ #Ãâó ; http://blog.naver.com/PostView.nhn?blogId=kzh8055&logNo=140100162253
1. À̹ÌÁö ÆÄÀϸ¦ ·ÎµùÇÏ°í
2. ·ÎµùÇÑ À̹ÌÁöÀÇ Æ¯Á¤ ¿µ¿ªÀ» ÁöÁ¤ÇÑµÚ 3. ±×°ÍÀ» ´Ù½Ã ¶Ç ´Ù¸¥ À̹ÌÁö ÆÄÀÏ¿¡ ÀúÀåÇÏ´Â °ÍÀÌ´Ù.
//¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ
// ¿øº»À̹ÌÁöÀÇ Æ¯Á¤ ¿µ¿ªÀ» ÇϳªÀÇ À̹ÌÁö·Î ¸¸µç´Ù //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ
BOOL MakeCellFrameImage(
// CImage::Save( LPCTSTR ImageFileName, REFGUID ImageFormatToMake );
LPCTSTR InSourceImageFileName, LPCTSTR InDestImageFileName,
{const CRect& InTagetRect, REFGUID InImageFormatToMake )
CImage TempSourceImage;
CImage TempDestImage; //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ // 1. ¿øº» À̹ÌÁö¸¦ TempSourceImage¿¡ ·Îµù //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ TempSourceImage.Load( InSourceImageFileName ); CDC* pSourceDC = CDC::FromHandle( TempSourceImage.GetDC() ); // ¿øº» À̹ÌÁöÀÇ DC¸¦ ¾ò´Â´Ù
//¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ
// 2. ÆÄÀÏ·Î ¸¸µé À̹ÌÁö °´Ã¼ TempDestImage »ý¼º //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ int BitPerPixel = pSourceDC->GetDeviceCaps( BITSPIXEL ); TempDestImage.Create( TempTargetRect.Width(), TempTargetRect.Height(), BitPerPixel ); CDC* pDestDC = CDC::FromHandle( TempDestImage.GetDC() );
if( !pSourceDC || !pDestDC )
{ return FALSE; } //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ // 3. Ÿ°Ù DC( ¸¸µé À̹ÌÁöÀÇ DC )¿¡ ¿øº» À̹ÌÁö DC ÀÇ ³»¿ëÀ» ¸¦ ¾´´Ù //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ pDestDC->BitBlt( 0, 0, TempTargetRect.Width(), TempTargetRect.Height(), TempDestImage.ReleaseDC(); TempSourceImage.ReleaseDC(); //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ // 4. À̹ÌÁö ÆÄÀÏ·Î ÀúÀå //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ TempDestImage.Save( InDestImageFileName, InImageFormatToMake );
return TRUE;
}The file type to save the image as. Can be one of the following:
• ImageFormatBMP An uncompressed bitmap image.
¸¸ÀÏ BMP Æ÷¸ËÀÇ À̹ÌÁö ÆÄÀÏÀ» ¸¸µé°í ½Í´Ù¸é ´ÙÀ½°ú °°ÀÌ ÇϸéµÈ´Ù.• ImageFormatPNG A Portable Network Graphic (PNG) compressed image. • ImageFormatJPEG A JPEG compressed image. • ImageFormatGIF A GIF compressed image. ...
Image.Save( _T("Test"), Gdiplus::ImageFormatBMP );
...2.1.3 ȸé ĸÃÄÇϱâ #Ãâó ; http://rainbrolly.tistory.com/entry/MFC-VC-%ED%99%94%EB%A9%B4-%EC%BA%A1%EC%B3%90-JPEG-CImage
CImage capImage;
HDC hProcessDC = ::GetDC(this->m_hWnd); // <-- ĸÃÄ ÇÏ°íÀÚÇÏ´Â processÀÇ HWND ¸¦ ³Ö¾îÁØ´Ù. CRect rect; ::GetClientRect(this->m_hWnd, rect); // <-- ĸÃÄ ÇÏ°íÀÚÇÏ´Â processÀÇ HWND ¸¦ ³Ö¾îÁØ´Ù.
if(!capImage.Create(rect.Width(), rect.Height(), 32))
return;
HDC hDC = capImage.GetDC();BitBlt(hDC, 0, 0, rect.Width(), rect.Height(), hProcessDC, 0, 0, SRCCOPY); 3 ÀÔ·Â µµ±¸ #3.1 Button #* ºñ½ÁÇÑ ·ùÀÇ ¹öÆ° ó¸®
MFC¿¡¼ Áö¿øÇÏ´Â ¾Æ·¡¿Í °°Àº ¸ÅÅ©·Î¸¦ »ç¿ëÇÏ´Â ¹æ¹ý
ON_COMMAND_RANGE(id1, id2, memberFxn ) 1) ¿©±â¼ ¸®¼Ò½º ¹øÈ£ id1, id2 ´Â ½ÃÄö½ºÇÑ ¹øÈ£·Î ºÎ¿©
¿¹·Î
2) ÀÌ°ÍÀº À§ÀÚµå·Î ¾ÈµÇ°í ¼öÀÛ¾÷À¸·Î ÄÚµùÇÑ´Ù.IDC_BUTTON1 1000 ÀÌ¿´´Ù¸é IDC_BUTTON2 1001 IDC_BUTTON3 1002 : IDB_BUTTON8 1007 id1 = IDC_BUTTON1, id2 = IDC_BUTTON8 ·Î ¼³Á¤ÇÏ¸é ¸â¹öÇÔ¼ö memberFxn À» ÇØÁÖ¸é IDC_BUTTON1 ~ IDC_BUTTON8 ¹öÆ°À» ´·¯ ÁÙ ¶§¸¶´Ù ¸â¹öÇÔ¼ö memberFxn ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù.
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
3) ¸¸¾à À̺¥Æ®°¡ ¹ß»ýÇÏÁö ¾ÊÀ¸¸é ¸ÞÀÎÇÁ·¹ÀÓ¿¡ IDR_MYMENU ÀÌ·±½ÄÀ¸·Î ¸Þ´º¸¦ Çϳª ´õ µî·ÏÇÏ°í ¿©±â¿¡ °¢°¢ÀÇ ¹öÆ° ¸®¼Ò½º ¾ÆÀ̵ð¶û °°Àº°ÍÀ¸·Î ¸Þ´º¸¦ Ãß°¡ÇÑ´Ù.
// ...
ON_COMMAND_RANGE(IDC_BUTTON1, IDC_BUTTON8, OnButtonClick) END_MESSAGE_MAP() void CMyView::OnButtonClick(UINT nID) { } Çì´õÆÄÀÏ¿¡´Â... // Generated message map functions //{{AFX_MSG(CSourceEditView) //}}AFX_MSG DECLARE_MESSAGE_MAP() 3.2 Button/ CBitmapButton #* CBitmapButton ¸¸µå´Â ¹ý_1
CBitmapButtonÀ¸·Î ¸¸µç ¹öÆ°Àº push button Çü½ÄÀÌ´Ù.
* CBitmapButton ¸¸µå´Â ¹ý_2 1) ¸ÕÀú Form¿¡ ¹öÆ°À» ¸¸µé°í Style¿¡¼ Owner Draw¸¦ ²À üũ 2) ¹öÆ°ÀÇ Ä¸¼ÇÀ» °£´ÜÇÏ°Ô ÁöÁ¤(Áß¿ä)
¿¹¸¦ µé¾î ĸ¼ÇÀÌ "ONE"À̶ó¸é..
3) ÀÌÁ¦ ¸®¼Ò½º¿¡ ¹öÆ° ±×¸²µéÀ» Ãß°¡ÇÕ´Ï´Ù.
À̶§ Ãß°¡ ÇÏ´Â ¸®¼Ò½º À̸§Àº
4) CBitmapButton °´Ã¼¸¦ ¸â¹öº¯¼ö·Î ¸¸µì´Ï´Ù.2¹ø¿¡¼ ÁöÁ¤ÇÑ Ä¸¼ÇÀÇ À̸§µÚ¿¡ "D" "F" "U" "X" ¸¦ ºÙÀÔ´Ï´Ù À̸¦Å׸é "ONED" "ONEF" "ONEU" "ONEX" °°Àº ½ÄÀ¸·Î ¸»ÀÔ´Ï´Ù. "U"=UP/ "D"=Down/ "F"=Æ÷Ä¿½º/ "X"=disable ÀÇ ¶æ 5) OnInitialUpdate() ¿¡ ´ÙÀ½°ú °°ÀÌ ¾¹´Ï´Ù
¹æ¹ý 1°ú Å©°Ô ´Ù¸£Áö ¾Ê°í, ¸Ê ¿¬°á ¹æ¹ý¿¡¼ Â÷ÀÌ°¡ ÀÖ´Ù.
1) ¹öÆ°ÀÇ ¼Ó¼ºÁß¿¡ property -> style ¿¡¼ Owner draw ²À check !! 2) ºñÆ®¸ÊÀ¸·Î ¾º¿ï ±×¸²µéÀ» ÇÁ·ÎÁ§Æ®ÀÇ Bit ¸ã ºÎºÐ¿¡ Insert ½ÃÅ´
(Á¤ÀûÀÎ ´À³¦À» ÇÇÇϱâ À§ÇØ ±×¸²Àº µÎ°³¸¦ Áغñ)
3) ÇØ´ç ´ÙÀÌ¾Ë·Î±× ¹Ú½ºÀÇ ¹öÆ°¿¡ ÇØ´çÇÏ´Â º¯¼ö¸¦ Ãß°¡½ÃÄÑ ÁÜ(¹°·Ð Çص忡 º¯¼ö¸¦ Á¤ÀÇ).h ÆÄÀÏ ºÎºÐ¿¡¼ public ºÎºÐ¿¡ ¸¸µé¾î Áֽðí .cpp ºÎºÐ¿¡
void CADD_AND_DEL_FRIEND::DoDataExchange(CDataExchange* pDX)
4) ´ÙÀ̾˷αװ¡ »ý¼ºµÇ´Â ÃʱâÈ ºÎºÐ¿¡¼ ¹öÆ°°ú À̹ÌÁö¸¦ ¿¬°á½ÃÄÑÁØ´Ù.{
CDialog::DoDataExchange(pDX);
}//{{AFX_DATA_MAP(CADD_AND_DEL_FRIEND) ... DDX_Control(pDX, IDOK, m_OK); // º¯¼ö¸¦ ÇØ´ç ¾ÆÀ̵ð¿Í ¿¬°á ½ÃÄÑÁØ´Ù. DDX_Control(pDX, IDCANCEL, m_Cancel); //}}AFX_DATA_MAP
BOOL CADD_AND_DEL_FRIEND::OnInitDialog()
{
CDialog::OnInitDialog();
}// ¹öÆ°ÀÌ ´·¯Áö±âÀü À̹ÌÁö¿Í ´·ÈÀ»¶§ À̹ÌÁö¸¦ ¼³Á¤ÇØ ÁØ´Ù. m_OK.LoadBitmaps( IDB_OKU, IDB_OKD ); m_Cancel.LoadBitmaps( IDB_CancelU, IDB_CancelD ); // ¹öÆ°À» À̹ÌÁö Å©±â¿¡ ¸ÂÃç¼ ¾º¿öÁØ´Ù. m_OK.SizeToContent(); m_Cancel.SizeToContent(); return true; 3.3 ListCtrl #* ItemÀ» º¯°æÇßÀ»¶§ À̺¥Æ® ó¸®
ItemÀ» º¯°æÇßÀ»¶§ Áï OnItemChanged¸Þ¼¼Áö°¡ ¹ß»ýÇϴµ¥
* ÃʱâȽà ÀÓÀÇÀÇ ¾ÆÀÌÅÛ ¼±ÅÃÇϱâ Ŭ·¡½º À§Àúµå¿¡¼ NM_CLICK À̺¥Æ® Çڵ鷯¸¦ ³Ö°í.. ¾Æ·¡¿Í °°Àº ³»ºÎ Äڵ带 »ðÀÔÇÏ¿© ¿øÇÏ´Â ÀÛ¾÷À» ÇÑ´Ù void CxxxDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) {
NM_LISTVIEW* pList = (NM_LISTVIEW*)pNMHDR;
}ASSERT(pList); '*' pResult = 0; if(pList->iItem == -1) return; ¸®½ºÆ®ÄÁÆ®·Ñ.GetItemData(pList->iItem); ¸®½ºÆ®ÄÁÆ®·Ñ.GetItemText(pList->iItem, ¼ºê¾ÆÀÌÅÛ À妽º);
¸ÕÀú OnInitDialog()¿¡¼ ÃʱâÈ ÇÑ´Ù.
* Full Row Select style·Î º¯È¯ m_ListCtrl.SetExtendedStyle(LVIS_SELECTED| LVS_NOLABELWRAP | LVS_EX_GRIDLINES | LVS_EX_FLATSB | LVS_EX_FULLROWSELECT); m_ListCtrl.ModifyStyle(0,LVS_SHOWSELALWAYS); <-- ¿ä°Å Áß¿äÇÔ ¹Ýµå½Ã ÇÒ°Í. ¼±ÅÃÇÏ°íÀÚ ÇÒ¶§ ¿ä·¸°Ô ÇÏ¸é µÊ´Ï´Ù. m_ListCtrl.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED); <-- ¼±ÅÃÇÏ°í, ȸ»öÀ¸·ÎµÊ m_ListCtrl.EnsureVisible(i,false); <--½ºÅ©·ÑÇÏ°í m_ListCtrl.SetFocus();<--Æ÷Ä¿½ºÁÖ°í ÆĶõ»öÀ¸·Î µÊ ¼±ÅÃÇϸé ÀÌÀü²¨´Â ÀÚµ¿ ÇØÁ¦.
m_ListCtrl.SetExtendedStyle( LVS_NOLABELWRAP | LVS_EX_GRIDLINES | LVS_EX_FLATSB | LVS_EX_FULLROWSELECT );
* ƯÁ¤ ¾ÆÀÌÅÛÀÌ º¸À̵µ·Ï ½ºÅ©·Ñ Çϱâ * Âü°í»çÀÌÆ® 3.4 Property Sheet #* ÇÁ·ÎÆÛƼ ½¬Æ®¿¡¼ Ã¹È¸é ¼³Á¤ mysheet.SetActivePage(npage);3.5 CFileDialog¿¡¼ µð·ºÅ丮¸¦ ¼³Á¤Çϱâ #
OPENFILENAME CFileDialog::m_ofn ;
typedef struct tagOFN { ...
LPCTSTR lpstrInitialDir; // ¿©±â¼ ¼³Á¤
...} OPENFILENAME;»ç¿ë¿¹)
char currentDir[ 256 ]; // ÇöÀçÀÇ °æ·Î
GetCurrentDirectory( NAME_MAX_SIZE, currentDir ); strcat( currentDir, "\\Data\\" ); 3.6 Check Box üũÇϱâ #
üũ¹Ú½º.SetCheck(int A); A°¡ 1À̸é üũ, 0À̸é ÇØÁ¦
1) CButton* chkbox1 = (CButton*)GetDlgItem(IDC_CHECK1); int i = chkbox1->GetCheck(); ÇöÀçÀÇ »óŸ¦ ±¸ÇÔ chkbox1->SetCheck(1); 2) GetDlgItem(ID_Model_CHK)->SetCheck(1); 3) Chk : Chk ÇØÁ¦ : 4 ÇÔ¼ö #4.1 OnInitDialog() ÇÔ¼ö; ´ëÈ»óÀÚ°¡ ȸ鿡 óÀ½ ³ªÅ¸³¯ ¶§ È£ÃâµÇ´Â ÇÔ¼ö #4.2 OnTimer() ÇÔ¼ö #À©µµ¿ì üÁ¦ÇÏ¿¡¼ ¾îÇÃÀº ¸Þ½ÃÁö¿Í ÇÁ·Î½ÃÁ®·ÎºÎÅÍ ½ÇÇàÀÌ ½ÃÀ۵ǰí, ½Ç»óÀº ¸ðµÎ Äݹé ó¸®ÇÑ´Ù.
ŸÀ̸Ӷõ °ÍÀº ¾î¶»°Ô »ý°¢ÇÏ¸é ¾²·¹µå¿Í ºñ½ÁÇÑ ¸éÀÌ Àִµ¥, Â÷ÀÌÁ¡À» ¾Ë¾Æ¾ß ÇÑ´Ù.
ŸÀ̸Ӷõ ÁöÁ¤ÇÑ ½Ã°£¸¶´Ù WM_TIMER ¸Þ½ÃÁö¸¦ ¹ß»ý½ÃÄÑ ÀÌ°ÍÀÇ Çڵ鷯¸¦ ÅëÇØ ÁÖ±âÀûÀ¸·Î ¾î¶² JOBÀ» ó¸®ÇÏ´Â °ÍÀ» ¸»ÇÑ´Ù. ÁÖ±âÀûÀ¸·Î ¸Þ½ÃÁö¸¦ ¹ß»ý½ÃÄÑ¾ß Çϱ⠶§¹®¿¡ ÀÌ ¿ªÇÒÀº ¹°·Ð ¾²·¹µå°¡ ´ã´çÇÑ´Ù.
¿©±â¼ WM_TIMER ¸Þ½ÃÁö¸¦ ÁÖ±âÀûÀ¸·Î ¹ß»ý½ÃÄÑÁÖ´Â ¾²·¹µå´Â Ä¿³Î¿¡¼ µ¹¾Æ°£´Ù. »ç¿ëÀÚ°¡ ¾²·¹µå¸¦ ¸¸µé¾î ŸÀ̸ÓÀÇ ±â´ÉÀ» 100% ±¸ÇöÇÒ ¼ö ÀÖÁö¸¸ ¿î¿µÃ¼Á¦¿¡¼ Áö¿øÇÏ´Â ÀÌÀ¯´Â Å©°Ô 2°¡ÁöÀÌ´Ù.
1. ¿î¿µÃ¼Á¦°¡ °ü¸®ÇÏ´Â°Ô ºÒÇÊ¿äÇÑ ¸®¼Ò½º ¼Ò¸ð¸¦ ÁÙÀÓ 2. Á¤È®µµ Çâ»ó
¾²·¹µå°¡ ÀÏÁ¤ÇÑ ½Ã°£ °£°ÝÀ¸·Î ¸Þ½ÃÁöÅ¥¿¡ WM_TIMER ¸¦ ³Ö¾îÁÖ´Â °Í°ú ±×³É ¾²·¹µå¸¦ ÀÌ¿ëÇÏ´Â °ÍÀº Â÷ÀÌ°¡ ÀÖ´Ù.
¾²·¹µå¿¡¼ ÇÊ¿äÇÑ Ã³¸®¸¦ ÇßÀ» °æ¿ì ½ÇÇà È帧Àº ´ç¿¬È÷ ¾²·¹µå ÀÚ½ÅÀÌ °¡Áö°Ô µÈ´Ù. ÇÏÁö¸¸ WM_TIMER ¸¦ ¸Þ½ÃÁöÅ¥¿¡ ³Ö¾îÁÙ °æ¿ì ¿î¿µÃ¼Á¦°¡ ÀÌ¿Í ¿¬°áµÈ Çڵ鷯 ÇÔ¼ö¸¦ CALL ÇØÁØ´Ù. #. °á°úÀûÀ¸·Î ¾îÇÃÀº ÀÚ±â Àڽſ¡ ÇÒ´çµÈ ƽŸÀÓ ÀϺθ¦ ÂÉ°³ ó¸®ÇÏ´Â Çü½ÄÀÌ µÈ´Ù. ÀÌ°ÍÀº ¸Å¿ì Áß¿äÇѵ¥, ¾î¶² ¸ÞÀÎ ¾²·¹µå A ¿¡¼ B ¶ó´Â ¾²·¹µå¸¦ »ý¼ºÇß´Ù°í °¡Á¤ÇÒ ¶§... A ¾²·¹µå°¡ Ä¿³Î ¸®¼Ò½º¸¦ ÇÒ´ç¹Þ¾Æ »ç ¿ëÇÏ°í ÀÖ´Ù°í °¡Á¤ÇßÀ» ¶§ B ¾²·¹µå¿¡¼ ÀÌ ¸®¼Ò½º¿¡ Á¢±ÙÇÏ·Á°í ÇÒ °æ¿ì °ÅºÎ´çÇÒ °¡´É¼ºÀÌ ³ô´Ù. API ¸¦ ÅëÇØ ¾î¶² ¾îÇÃÀ̵ç ÇÁ·Î¼¼½º À̸§¸¸ ¾Ë¸é À©µµ¿ì ÇÚµéÀ̳ª, ÀνºÅϽº ÇÚµéÀ» ½±°Ô °¡Á®¿Ã ¼ö ÀÖ´Ù.
Áï, ¿î¿µÃ¼Á¦¿¡¼ ¸·¾ÆÁÖÁö ¾ÊÀ¸¸é ¾ÇÀÇÀûÀÎ ¸ñÀûÀÇ ¾îÇÃÀÌ ´Ù¸¥ ¾îÇÃÀ» ½±°Ô Á¶ÀÛÇÒ ¼ö ÀÖ´Ù´Â ¶æÀÌ´Ù.
½±°Ô ¿¹¸¦ µé¾î ¾î¶² ÇÁ·Î¼¼½º »ó¿¡¼ À©µµ¿ì(Ä¿³Î ¸®¼Ò½º)¸¦ »ý¼ºÇÏ°í, ¾²·¹µå¿¡¼ ±× ÇÁ·Î¼¼½ºÀÇ À©µµ¿ì ¸¦ Á¶ÀÛÇÒ °æ¿ì ¿î¿µÃ¼Á¦¿¡°Ô ºí·°´çÇØ ¿À·ù ¹ß»ý È®·üÀÌ ³ô´Ù. #. ¹°·Ð ÀÌ·² ¶§ ŸÀ̸Ӹ¦ »ç¿ëÇϸé ÀÚ±â ÀÚ½ÅÀÌ Á¢±ÙÇÏ´Â °ÍÀ̹ǷΠ¾Æ¹«·± Á¦¾àÀÌ ¾ø´Ù. µû¶ó¼ ÁÖ±âÀûÀ¸·Î ±×·¡ÇÈ º¯È°¡ ÇÊ¿äÇÑ °ÔÀÓ µî¿¡¼ÀÇ Ã³¸®´Â ¸ðµÎ ŸÀ̸ӷΠ󸮵ȴÙ.
ŸÀ̸Ӵ ¾à°£ÀÇ Á¦¾à »çÇ×ÀÌ ÀÖ´Ù. À§¿¡¼ ¸»Çßµí ¸Þ½ÃÁöÅ¥°¡ ÇÊ¿äÇѵ¥, ¸Þ½ÃÁöÅ¥´Â À©µµ¿ì¸¦ »ý¼º ÇÒ °æ¿ì ¸¸µé¾îÁø´Ù. ±×·¡¼ ³×Æ®¿÷ °ü·Ã ¾îÇà Áß Å¸ÀÌ¸Ó »ç¿ëÀ» À§Çؼ ºó À©µµ¿ì¸¦ Çϳª »ý¼ºÇÏ´Â ¹æ½ÄÀÇ ¼³°èµµ ÀÖ´Ù. MFCÀÇ °æ¿ì CWnd Ŭ·¡½º¸¦ »ó¼Ó¹ÞÀº Ŭ·¡½º¸¦ ¸¸µé¾î Create ÇØÁÖ´Â µîÀÇ Ã³¸®°¡ µé¾î°£´Ù.
Ä¿³Î ¸®¼Ò½º Á¢±ÙÀÌ ÇʼöÀÎ °æ¿ì, ŸÀ̸Ӹ¦ ÀÌ¿ëÇÏ´Â°Ô ¹Ù¶÷Á÷ÇÏ´Ù.
4.2.1 ŸÀÌ¸Ó »ç¿ë¹ý #UINT_PTR SetTimer(m_hWnd, nIDEvent, nElapse, lpfnTimer);
1¹ø ÀÎÀÚ´Â À©µµ¿ì ÇÚµé. ¿Ö ÇÚµéÀÌ µé¾î°¡´À³Ä.. À§¼ ¼³¸íÇßµí ¸Þ½ÃÁöÅ¥°¡ ÇÊ¿äÇϱ⠶§¹®
void Func(HWND, UINT, UINT_PTR, DWORD) ÇüÅ·ΠÇÔ¼ö Æ÷ÀÎÅ͸¦ ÁöÁ¤ÇØÁÙ ¼ö Àִµ¥,2¹ø ÀÎÀÚ´Â À̺¥Æ® ID. ½±°Ô ¸»ÇØ Å¸À̸Ӹ¦ ¿©·¯°³ µ¹¸± ¼ö ÀÖÀ¸¹Ç·Î ÀÌ°ÍÀ» ±¸ºÐÇϱâ À§ÇÑ ³Ñ¹ö°ªÀ¸·Î 0 À» Á¦¿ÜÇÑ °ªÀ» ³Ö¾îÁØ´Ù. 3¹ø ÀÎÀÚ´Â ms ´ÜÀ§ÀÇ ½Ã°£ °£°Ý. 1ÃÊ´Â 1000ms.. 4¹ø ÀÎÀڴ ŸÀÌ¸Ó À̺¥Æ® ¹ß»ý ½Ã Äݹé Çڵ鷯. ÀÌ°ÍÀº NULL ·Î ÁöÁ¤ÇÒ °æ¿ì µû·Î ÇÁ·Î½ÃÁ®¿¡¼ WM_TIMER ¹ß»ý ½Ã Çڵ鷯 󸮸¦ Çصµ »ó°ü¾ø´Ù.
¸®ÅÏ°ªÀº nIDEvent ¿¡ ÁöÁ¤ÇÑ °ªÀ¸·Î ³ª¿Â´Ù. À̶§ ÀÌ¹Ì ÁöÁ¤ÇÑ ID·Î »ý¼ºÇÑ Å¸À̸Ӱ¡ ÀÖÀ» °æ¿ì ȤÀº ±âŸ ´Ù¸¥ ÀÌÀ¯·Î ŸÀÌ¸Ó µî·ÏÀÌ ½ÇÆÐÇÏ¸é ¸®ÅÏ°ªÀº 0 ÀÌ µÈ´Ù. ¿¡·¯ ¿©ºÎ´Â 0 ÀÌ³Ä ¾Æ´Ï³Ä·Î ÆǴܵǹǷΠnIDEvent ¿¡ 0 À» ÁöÁ¤ÇÒ ¼ö ¾ø´Ù.
4.2.2 2°³ ŸÀ̸Ӹ¦ »ç¿ëÇÑ ¿¹ (Ãâó; www.winapi.co.kr ) #LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam){
HDC hdc;
}PAINTSTRUCT ps; RECT rt; char Mes[]="ŸÀÌ¸Ó ¿¹Á¦ÀÔ´Ï´Ù."; switch(iMessage) { case WM_CREATE: case WM_TIMER:
switch(wParam)
case WM_PAINT:{ case 1:
GetWindowRect(hWnd,&rt);
case 2:rt.left+=5; rt.right+=5; MoveWindow(hWnd,rt.left,rt.top,rt.right-rt.left,rt.bottom-rt.top,TRUE); break; case WM_DESTROY: } return(DefWindowProc(hWnd,iMessage,wParam,lParam)); 4.2.3 (MFC) UINT_PTR CWnd::SetTimer(UINT_PTR nIDEvent, UINT nElapse, (*handler)); #MFCÀÇ °æ¿ì CWnd ÀÇ ¸Þ½áµå·Î µî·ÏµÈ SetTimer ¸¦ È£ÃâÇÑ´Ù.
UINT_PTR CWnd::SetTimer(UINT_PTR nIDEvent, UINT nElapse, (*handler)); ÇüÅ·Î,
CWnd ÀÚü°¡ À©µµ¿ì¸¦ »ý¼º ¹× °ü¸®Çϱâ À§ÇÑ ·¡ÇΠŬ·¡½ºÀ̹ǷΠµû·Î À©µµ¿ì ÇÚµéÀÌ ÇÊ¿äÇÏÁö ¾Ê´Ù.
ŸÀ̸Ӹ¦ Á×ÀÏ ¶§´Â¶Ç Çڵ鷯¸¦ ÁöÁ¤ÇØÁÖÁö ¾ÊÀ» °æ¿ì ±âº» Çڵ鷯´Â CWnd::OnTimer ·Î ÁöÁ¤µÈ´Ù. BOOL CWnd::KillTimer(UINT_PTR nIDEvent); ¸¦ »ç¿ëÇÑ´Ù.
Çڵ鷯´Â MFCÀÇ °æ¿ì ±âº»À¸·Î
void CWnd::OnTimer(UINT nIDEvent); ·Î ÁöÁ¤µÇ¸ç,
ID ¸¦ ÅëÇØ Å¸ÀÌ¸Ó À̺¥Æ®·Î·Î ±¸ºÐµÇ°í 󸮵ȴÙ.
ÇÁ·Î¼¼½º´Â ¿ì¼± ¼øÀ§¿¡ µû¶ó ¿î¿µÃ¼Á¦·ÎºÎÅÍ ÁöÁ¤µÈ ƽ´ÜÀ§·Î ½ÇÇà È帧À» ÇÒ´ç¹Þ´Â´Ù. ƽŸÀÓÀº ¼¹ö¿ëÀÌ³Ä °³ÀοëÀ̳Ŀ¡ µû¶ó ´Ù¸¥µ¥, Áß¿äÇÑ °ÍÀº ÇöÀç ÇÁ·Î¼¼½º¿¡ ¾ðÁ¦ ½ÇÇà È帧ÀÌ µ¹¾Æ¿ÃÁö, ±×¸®°í ¸î ƽÀÌ ÇÒ´çµÉÁö ¸ð¸¥´Ù´Â Á¡ÀÌ´Ù.
µû¶ó¼ ŸÀÌ¸Ó »ý¼º ½Ã ÁöÁ¤ÇÑ ½Ã°£Àº ¸Å¿ì Á¤È®µµ°¡ ¶³¾îÁø´Ù. ±×·¡¼ º°µµÀÇ º¸Á¤ÀÌ ÇÊ¿äÇѵ¥,
½Ã°£ ÃøÁ¤ ÇÔ¼ö·ù¸¦ »ç¿ëÇÑ´Ù.
-. time ÇÔ¼öÀÇ °æ¿ì ÃÊ´ÜÀ§¹Ç·Î ÀÏ´Ü Á¦¿Ü
-. clock ÇÔ¼öÀÇ °æ¿ì ms ´ÜÀ§À̱ä ÇÏÁö¸¸ ´Ü¼øÈ÷ ÇöÀç ÇÁ·Î¼¼½ºÀÇ ½ÃÀÛ ½Ã°£°ú ƽÀÌ µ¹¾Æ¿Â ½Ã°£¸¸ °è»êÇÑ °ÍÀ̹ǷΠÁ¦¿Ü.. -. QueryPerfomanceCounter ´Â Á¤¹Ðµµ´Â °¡Àå ³ôÁö¸¸ ºÎÇÏ°¡ Ä¿¼ Á¦¿Ü.. -. °á±¹ °¡Àå ¸¹ÀÌ »ç¿ëÇÏ´Â °Ç timeGetTime ÀÌ´Ù. 4.3 OnWindowPosChanging() ÇÔ¼ö; Dialog¸¦ hidden »óÅ·Π½ÇÇàÇϱâ #
-. À©µµ¿ìÁî ÇÁ·Î±×·¥¿¡¼ À©µµ¿ì¸¦ °¨Ãâ ¶§´Â ShowWindow(SW_HIDE); ¸¦ È£ÃâÇÏ¸é µÇÁö¸¸, ¹®Á¦´Â ´ÙÀ̾ó·Î±×¸¦ hidden»óÅ·Π½ÇÇà ÇÏ·Á°í, ShowWindow(SW_HIDE)¸¦ OnInitDialog()¿¡¼ È£ÃâÇϸé 󸮰¡ ¾ÈµÈ´Ù.
OnInitDialog()ÀÇ Ã³¸®°¡ ³¡³ª´Â ½ÃÁ¡¿¡¼ ShowWindow(SW_SHOW)¸¦ È£ÃâÇϱ⠶§¹®ÀÌ´Ù. -. hiddenÀ¸·Î ½ÇÇàÇϱâ À§Çؼ´Â »ý¼ºµÇ´Â À©µµ¿ìÀÇ ½ºÅ¸ÀÏ¿¡¼ ¼Ó¼ºÀ» »©ÁÖ¾î¾ß ÇÑ´Ù. ¼Ó¼º 󸮸¦ À§Çؼ "WM_WINDOWPOSCHANGING" À©µµ¿ì ¸Þ½ÃÁö ó¸® ÇÔ¼ö¸¦ »ý¼ºÇÏ°í ´ÙÀ½°ú °°ÀÌ ¼³Á¤ÇÑ´Ù. void CYourDialog::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) {
lpwndpos->flags &= ~SWP_SHOWWINDOW; // ¼Ó¼º¿¡¼ SWP_SHOWWINDOW Á¦°Å
} CDialog::OnWindowPosChanging(lpwndpos); 4.4 »õ·Î¿î Ŭ·¡½º¸¦ Ŭ·¡½º À§Á®µå¸¦ ÅëÇÏ¿© ÀνĽÃÅ°±â #
-. ¸ÕÀú ÇÁ·ÎÁ§Æ® À̸§À¸·Î µÈ XXXX.clw ÆÄÀÏÀ» »èÁ¦ÇÑ´Ù. ¸¸ÀÏÀ» À§ÇØ À̸§À» ¹Ù²ãµÎ´Â °ÍÀÌ ÁÁ´Ù.
-. ±× ´ÙÀ½ Ŭ·¡½º À§Á®µå¸¦ ½ÇÇà½ÃÅ°¸é Ŭ·¡½º¿¡ ´ëÇÑ Á¤º¸°¡ ¾ø±â ¶§¹®¿¡ »õ·Ó°Ô ¼³Á¤ÇÏ´Â ´ÙÀ̾ó·Î±×°¡ ³ªÅ¸³´Ù. ¿©±â¼ Project List¿¡ ¸ðµÎ µî·Ï½ÃÅ°¸é µÈ´Ù. ±×·± ÈÄ ´Ù½Ã Ŭ·¡½º À§Á®µå¸¦ ½ÇÇà½ÃÅ°¸é ±âÁ¸ÀÇ Å¬·¡½º »Ó¸¸ ¾Æ´Ï¶ó »õ·Ó°Ô Ãß°¡ÇÑ Å¬·¡½ºµµ À§Á®µå°¡ ÀνÄÇÏ´Â °ÍÀ» ¾Ë ¼ö ÀÖ´Ù. 4.5 UpdataData() ÇÔ¼ö #
-. ȸ鿡 µ¥ÀÌÅ͸¦ ³ªÅ¸³»±â À§Çؼ´Â º¯¼ö¿¡ µî·ÏµÇ¾î ÀÖ´Â µ¥ÀÌÅ͸¦ ´ëÈ »óÀÚ·Î Àü¼ÛÇÏ´Â ÇÔ¼ö
(º¯¼ö¿¡ µ¥ÀÌÅ͸¦ ±â·ÏÇÏ¿´´Ù ÇÏ¿©µµ ȸ鿡´Â ÀÔ·ÂµÈ ¸ð½ÀÀÌ ³ªÅ¸³ªÁö ¾Ê´Â´Ù´Â ÀǹÌ)
-. UpdateData(FALSE); º¯¼ö¸¦ ´ëÈ »óÀÚ·Î Àü¼Û
(ÇöÀç º¯¼ö¿¡ µ¥ÀÌÅ͸¦ µî·ÏÇÏ°í ÀÌ°ÍÀ» ´ëÈ »óÀÚ·Î Àü¼ÛÇÒ ¶§)
UpdateData(TRUE); ´ëÈ »óÀÚ¿¡¼ º¯¼ö·Î µ¥ÀÌÅ͸¦ Àü¼Û
(´ëÈ »óÀÚ¿¡¼ ¿¡µðÅÍ »óÀÚ °°Àº ÀÚ¿ø¿¡ Á¤º¸¸¦ º¯ÇüÇÏ°í, ÀÌ º¯ÇüµÈ µ¥ÀÌÅ͸¦ ´Ù½Ã ÀÚ¿øÀ¸·Î ¹Þ¾Æ¾ß ÇÒ °æ¿ì)
4.6 »ç¿ëÀÚ ¸Þ½ÃÁö¸¦ ¹Þ¾Æ CMyViewŬ¶óÀ̾ðÆ® ¿µ¿ª¿¡¼ ó¸®Çϱâ #
-. ºäŬ·¡½º¿Í ´ÙÀ̾ó·Î±×Ŭ·¡½ºÀÇ ¿ªÇÒÀº ´ÙÀ½°ú °°°í, ´ÙÀ̾ó·Î±×Ŭ·¡½º´Â ºäŬ·¡½º¸¦ ¾Ë°í ÀÖ¾î¾ßÇÑ´Ù.
ºäŬ·¡½º ==> °¨½ÃÀÚ (½ºÅ¸Å©·¡ÇÁÆ®ÀÇ ¿ÉÀú¹ö¿Í µ¿ÀÏÇÑ ¿ªÇÒ)
-. ¹°·Ð SetParent() ÈÄ¿¡ GetParent()·Î Çصµ µÇÁö¸¸ ´ÙÀ̾ó·Î±×Ŭ·¡½º ==> Á¤º¸ÀǺ¯È
À§¿Í °°Àº µðÀÚÀÎÆÐÅÏÀ» °í·ÁÇÏ¸é ´ÙÀ½°ú °°´Ù.(¿ÉÀú¹öÆÐÅÏ)
1) ´ÙÀ̾ó·Î±×Ŭ·¡½º¿¡¼ ºäŬ·¡½ºÀÇ Æ÷ÀÎÅ͸¦ ÀúÀåÇÒ¼ö ÀÖ´Â ¸â¹öº¯¼ö¸¦¸¸µé°í 2) ºäŬ·¡½º ÃʱâÈÇÔ¼öºÎºÐ¿¡¼ ´ÙÀ̾ó·Î±×Ŭ·¡½º¿¡ Æ÷ÀÎÅ͸¦ ³Ñ°ÜÁÖ¸é µË´Ï´Ù. 3) ±×¸®°í ¸Þ½ÃÁö¸¦ Á¤ÀÇÇÕ´Ï´Ù.
afx_msg long OnMyMsg(WPARAM) wparam,LPARAM lparam);
ON_MESSAGE ( WM_USER+1,OnMyMsg)
4.7 PreTranslateMessage(MSG *pMsg); #@ 2010-03-17 @4.7.1 Á¤ÀÇ #virtual BOOL PreTranslateMessage(MSG *pMsg);
pMsg : ó¸®ÇÏ´Â ¸Þ¼¼Áö¸¦ Æ÷ÇÔÇÑ MSG ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ
MSG±¸Á¶Ã¼ÀÌ Æ÷ÀÎÅÍ¿¡´Â ¸Þ¼¼Áö¸¦ º¸³»ÂÊÀÇ À©µµ¿ì ÇÚµé°ú º¸³»¿Â ¸Þ¼¼ÁöµîÀÇ Á¤º¸°¡ ÀúÀåµÈ´Ù. typedef struct tagMSG {
HWND hwnd; // ¸Þ¼¼Áö¸¦ °Ç³»¹Þ´Â À©µµ¿ìÀÇ ÇÚµé
} MSG;UINT message; // ¸Þ¼¼Áö ¹øÈ£(WM_RBUTTONDOWNµî) WPARAM wParam; // ¸Þ¼¼ÁöÀÇ ºÎ°¡ Á¤º¸ LPARAM lParam; // ¸Þ¼¼ÁöÀÇ ºÎ°¡ Á¤º¸ DWORD time; // ¸Þ¼¼Áö°¡ Æ÷½ºÆ®µÈ ½Ã°£ POINT pt; // ¸Þ¼¼Áö°¡ Æ÷½ºÆ®µÇ¾úÀ» ¶§ÀÇ Ä¿¼À§Ä¡(½ºÅ©¸° ÁÂÇ¥)
-. PreTranslateMessage´Â À©µµ¿ì ¸Þ¼¼Áö°¡ TranslateMessage³ª DispatchMessage¿¡ ÀüÇØÁö±â Àü¿¡ ó¸®ÇÒ ÇÊ¿ä°¡ ÀÖÀ»¶§ »ç¿ëµÇ¸ç, À©µµ¿ì ¸Þ¼¼Áö°¡ ¹ß»ýµÇ¸é TranslateMessage³ª DispatchMessage¿¡ °¡±âÀü¿¡ PreTranslateMessage¸¦ °ÅÄ¡°Ô µÈ´Ù.
-. PreTranslateMessage´Â ¸Þ¼¼Áö ¸ÊÀ» »ç¿ëÇÒ ¼ö ÀÖ°í, À©µµ¿ì ¸Þ¼¼Áö°¡ °¢ ÄÁÆ®·Ñ¿¡ ÀüÇØÁö±â Àü¿¡ ±× ¸Þ¼¼Áö¸¦ ¾òÀ» ¼ö ÀÖ´Ù.
4.7.2 (MFC) ´ÙÀ̾ó·Î±×¿¡¼ Enter³ª ESC Å° ¸·±â #-. MFC¿¡¼ ´ëÈ »óÀÚ ±â¹ÝÀ¸·Î ÇÁ·ÎÁ§Æ®¸¦ ¸¸µé¾î¼ ½ÇÇà½ÃÅ°¸é, ±× ´ÙÀ̾ó·Î±×¿¡¼ Enter³ª ESC Å°¸¦ ´©¸£¸é ´ÙÀ̾ó·Î±×°¡ Á¾·áÇϴµ¥, ÀÌ°ÍÀ» ¸·±â À§ÇØ PreTranslateMessage¸¦ È°¿ëÇÑ´Ù.¢¹ ***Dlg.h¿¡¼ class CTestDlg : public CDialog { // »ý¼º public:
CTestDlg (CWnd* pParent = NULL); // Ç¥ÁØ »ý¼ºÀÚ
// ±¸Çövirtual BOOL PreTranslateMessage (MSG* pMsg); // ´ëÈ »óÀÚ µ¥ÀÌÅÍ enum {IDD = IDD_TEST_DIALOG }; Protected: virtuala void DoDataExchange(CDataExchange* pDX); // DDX/ DDV Áö¿ø protected:
HICON m_hIcon;
public:// »ý¼ºµÈ ¸Þ½ÃÁö ¸Ê ÇÔ¼ö virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP();
afx_msg void OnBnClickedOk();
};
¢¹ ***Dlg.cppÆÄÀÏ¿¡¼
BOOL CTestDlg ::PreTranslateMessage(MSG* pMsg) {
switch(pMsg->message)
}{ // Å°°¡ ´·ÈÀ»¶§ case WM_KEYDOWN:
switch(pMsg->wParam)
}{ // ¸®ÅÏÅ°\tab case VK_RETURN:
return TRUE;
// ESCÅ°case VK_ESCAPE:
return TRUE;
}return CDialog::PreTranslateMessage(pMsg); 5 API ÇÔ¼ö #5.1 AllocConsole(); API ¿¡¼ Console âÀ¸·Î º¯¼ö Ãâ·Â ÇÏ´Â ¹æ¹ý #@ 2010-12-27 @Visual Studio ToolÀ» »ç¿ëÇؼ Windows ÇÁ·Î±×·¥À» ÇÏ´Ùº¸¸é µð¹ö±ë ÇÒ ¶§ ¾î·Á¿òÀ» ´À³¢°ï ÇÑ´Ù. Message󸮷Πµ¿ÀÛ Çϱ⠶§¹®¿¡ ÇÔ¼öÀÇ Æ¯Á¤ ºÎºÐÀÇ º¯¼öÀÇ °ªµîÀ» ÀбⰡ ¿©°£ ºÒÆíÇÑ ÀÏÀÌ ¾Æ´Ï´Ù. ÀÌ·²¶§ ´ÙÀ½°ú °°Àº ¹æ¹ýÀ» »ç¿ëÇϸé ÄܼÖâ°ú À©µµ¿ìÁî âÀÌ ÇÔ²² ¶ß±â ¶§¹®¿¡ ¿©·¯ º¯¼ö ¸íÀ» ¹Ù·Î¹Ù·Î Á÷Á¢ ÀÐ¾î º¼¼ö°¡ ÀÖ´Ù.
Çì´õ¿¡ ´ÙÀ½À» Ãß°¡ ÇÏ°í
#include <stdio.h>
WinMain ù° ÁÙ¿¡ ¾Æ·¡¿Í °°ÀÌ Ãß°¡±×·¯¸é printf() ÇÔ¼ö¸¦ ÄÚµå ³»¿¡¼ »ç¿ë °¡´ÉÇÏ´Ù. 5.2 CreateEvent() #@ 2010-04-12 @ À̸§ÀÌ Á¤ÇØÁø ¶Ç´Â À̸§ÀÌ ¾ø´Â À̺¥Æ® °´Ã¼¸¦ ¿°Å³ª »ý¼ºÇÏ´Â ÇÔ¼ö API_CreateEvent()5.3 GetLastError() #@ 2010-04-09 @ Ãâó ; http://infoki.net/586GetLastError È£ÃâÃø ½º·¿µå°¡ °¡Áö´Â ÃÖ½ÅÀÇ ¿¡·¯ Äڵ带 ÃëµæÇÕ´Ï´Ù.¿¡·¯ ÄÚµå´Â ½º·¿µå ¸¶´Ù º¸°ü À¯ÁöµÇ±â À§ÇØ, º¹¼öÀÇ ½º·¿µå°¡ ¼·ÎÀÇ ¿¡·¯ Äڵ带 µ¡¾²±âÇÒ °ÍÀº ¾ø½À´Ï´Ù. Àμö ; Àμö´Â ¾ø½À´Ï´Ù.
¹Ýȯ°ª ; È£ÃâÃø ½º·¿µå°¡ °¡Áö´Â ÃÖ½ÅÀÇ ¿¡·¯ Äڵ带 µ¹·ÁÁÝ´Ï´Ù.
Çؼ³ ; FormatMessageÇÔ¼ö·ÎFORMAT_MESSAGE_FROM_SYSTEMÇ÷¡±×¸¦ ÁöÁ¤ÇÏ´Â °ÍÀ¸·Î, ¿¡·¯ Äڵ忡 ´ëÀÀÇÏ´Â ¿¡·¯ ¹®ÀÚ¿À» ÃëµæÇÒ ¼ö ÀÖ½À´Ï´Ù.
¿¡·¯ ÄÚµå´Â32ºñƮġÀÔ´Ï´Ù(ºñÆ®31ÇÏÁö¸¸ ÃÖ»óÀ§ºñÆ®).ºñÆ®29(Àº)´Â ¾îÇø®ÄÉÀÌ¼Ç Á¤ÀÇÀÇ ¿¡·¯ ÄÚµå¿ëÀ¸·Î ¿¹¾àµÇ°í ÀÖ½À´Ï´Ù.¾îÇø®ÄÉÀÌ¼Ç µ¶ÀÚÀûÀÎ ¿¡·¯ Äڵ带 Á¤ÀÇÇÏ´Â °æ¿ì´Â, ÀÌ ºñÆ®¸¦ ¼¼Æ® ÇÏ°í, ½Ã½ºÅÛ Á¤ÀÇÀÇ ¿¡·¯ ÄÚµå¿Í Ãæµ¹ÇÏÁö ¾Ê°Ô ÇØ ÁÖ¼¼¿ä.
´ëÀÀ Á¤º¸ ; Windows 95 ÀÌÈÄ / Windows NT 3.1 ÀÌÈÄ
5.4 ShellExecuteEx(A) #@ 2010-04-09 @ Ãâó ; http://infoki.net/586ShellExecuteEx(A) »õ·Î¿î ÇÁ·Î¼¼½º¸¦ ±âµ¿ÇÕ´Ï´Ù.Æú´õ¸¦ ÀͽºÇ÷η¯·Î ¿¸®°Å³ª ¹®¼ ÆÄÀÏÀ» °ü·ÃÁöÀ» ¼ö ÀÖ¾ú´ø ¾îÇø®ÄÉÀ̼ÇÀ¸·Î ¿¸®°Å³ª ÇÒ ¼öµµ ÀÖ½À´Ï´Ù. Àμö ; pExecInfo ½ÇÇàµÇ´Â ¾îÇø®ÄÉÀ̼ǿ¡ ´ëÇÑ Á¤º¸¸¦ °Ý³³Çß´Ù SHELLEXECUTEINFO ±¸Á¶Ã¼ÀÇ ÁÖ¼Ò¸¦ ÁöÁ¤ÇÕ´Ï´Ù.
¹Ýȯ°ª ; ¼º°øÇϸé 0 ÀÌ¿ÜÀÇ °ªÀÌ µ¹¾Æ°©´Ï´Ù.
½ÇÆÐÇϸé 0 ÇÏÁö¸¸ µ¹¾Æ°©´Ï´Ù.È®Àå ¿¡·¯ Á¤º¸¸¦ ÃëµæÇÏ·Á¸é , GetLastError ÇÔ¼ö¸¦ »ç¿ëÇÕ´Ï´Ù.
Çؼ³ ; ÇÔ¼öÀÇ È£ÃâÀÌ ¼º°øÇϸé, SHELLEXECUTEINFO ±¸Á¶Ã¼ÀÇ hInstApp ¸â¹ö´Â ½ÇÇàµÈ ¾îÇø®ÄÉÀ̼ÇÀÇ ÀνºÅϽº ÇÚµéÀÌ µË´Ï´Ù.ÇÔ¼ö°¡ ½ÇÆÐÇßÀ» °æ¿ì´Â 32 ÀÌÇÏÀÇ SE_ERR_ ¿¡·¯Ä¡°¡ µË´Ï´Ù.ÀÌ ¿¡·¯Ä¡´Â ShellExecute ÇÔ¼ö¿Í ȣȯÀÇ °ÍÀÔ´Ï´Ù. ShellExecuteEx ÇÔ¼ö·Î ¿¡·¯Ä¡¸¦ ¾ò±â À§Çؼ´Â GetLastError ÇÔ¼ö¸¦ »ç¿ëÇϵµ·Ï ÇØ ÁÖ¼¼¿ä.
GetLastError ÇÔ¼ö´Â ÀÌÇÏÀÇ ¸î°³ÀÇ °ªÀ» µ¹·ÁÁÝ´Ï´Ù.ÀÌ·¯ÇÑ °ªÀº SE_ERR_ °ª¿¡ ´ëÀÀÇÏ°í ÀÖ½À´Ï´Ù.
Windows 95 ÀÌÈÄ / Windows NT 4.0 ÀÌÈÄ 6 MFCÀÇ ±¸¼º #* Application Frameworks(AFS)
ÇÁ·Î±×·¥À» »õ·Î ¸¸µé ¶§´Â AppWizard¸¦ »ç¿ëÇϴµ¥, AppWizardÀÇ ¿ªÇÒÀº MFCÀÇ AFXŬ·¡½º¿¡¼ »ó¼ÓÀ» ¹Þ¾Æ, ¾Æ·¡ ±×¸²¿¡¼¿Í °°Àº ³× °³ÀÇ Å¬·¡½º¸¦ »ý¼º½ÃÄÑ ÁÖ´Â °ÍÀÌ´Ù.
* AFX Ŭ·¡½ºµé °£ÀÇ »óÈ£ÂüÁ¶ °ü°è- µµÅ¥¸ÕÆ® Ŭ·¡½º¿¡¼ ºä/ ÇÁ·¹ÀÓ À©µµ¿ì ÂüÁ¶ ¸Þ¸ðÀåÀ¸·Î °¡±â |
ÇÒ ¼ö ÀÖ´Ù°í ¹Ï´Â »ç¶÷ÀÌ ¼º°øÇÑ´Ù(¿ùÅÍ D.À©Æ²) edu2014_Unity3D¸¦_ÀÌ¿ëÇÑ_°ÔÀÓ_¸¸µé±â Ã¥°¥ÇÇ_Nidec ¸Þ¸ðÀå_MFC WikiSandBox |