MoniWiki¸Þ¸ðÀå_C
Login:
Password:
´ë¹®|ã±â|¹Ù²ï±Û|¸ñ·Ï|¸Þ¸ðÀå|Ã¥°¥ÇÇ|¿¬²É|¸µÅ©
Edit Diff Reload Search Print Info Mail Help RSS


££. ¸ÅÅ©·Î¸¦ È°¿ëÇÑ (goto) Error; ó¸®

//Error handling macro for join failures
#define JOIN_ERROR(x) {eLoginError = (x); goto Error;} 

//¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ
static BOOL sPlayerJoinGame(
  GAME * game, APPCLIENTID idAppClient, MSG_CCMD_PLAYERNEW * msg)
{
...
  LOGINERROR eLoginError = LOGINERROR_UNKNOWN;

  JOIN_ERROR(LOGINERROR_UNKNOWN);
...
  return TRUE;

Error:
  SendError(idAppClient, eLoginError);

  return FALSE;
}
££. fatal error C1083: ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ ÆÄÀÏÀ» ¿­ ¼ö ¾ø½À´Ï´Ù.
1. ÇÁ·ÎÁ§Æ® ¼Ó¼º -> ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ: »ç¿ë(/Yu)
2. ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ·Î ÁöÁ¤µÈ ÆÄÀÏÀÌ StdAfx.h¶ó¸é
StdAfx.cpp ¼Ó¼º -> ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ: ¸¸µé±â(Yc)

* °æ·Î ¾Ë¾Æº¸±â
char path 255;
char drive _MAX_DRIVE, dir _MAX_DIR, char fname _MAX_FNAME, ext _MAX_EXT;
GetModuleFileName(NULL, path, 512);
_splitpath(path, drive, dir, fname, ext);

//----------------------------------------------------------------------------
* ¸±¸®Áî ¸ðµå¿¡¼­ Ãâ·Ââ¿¡ ¹®ÀÚ¿­ Ç¥½Ã
char str256;
wsprintf(str,">> Language set to '%s'\n", LanguageGetCurrentName() );
OutputDebugString(str);

* º°°³ÀÇ window¿¡ printf()¸¦ »ç¿ëÇؼ­ Ãâ·ÂÇÏ´Â ¹æ¹ý
-.µî·Ï; #pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console" )
-.»ç¿ë; ÀϹÝÀûÀÎ printf()¸¦ »ç¿ë - printf("%f %f %f\n",vNodePos.x,vNodePos.y,vNodePos.z);

//----------------------------------------------------------------------------
* COM+/DCOM ½ÃÀÛÀ» À§ÇÑ ¼±ÇàÁ¶°Ç (ÀÎÅͳݿ¡¼­ ÆÛ¿Â ±Û)
1.C++À» ÀÌ¿ëÇÑ °´Ã¼ÁöÇâ(Class°³³ä) °³³äÀÇ ÀÌÇØ.
-> ½ÃÁß¿¡ ³ª¿ÍÀÖ´Â c++¿¡ °ü·ÃµÈ ÀÔ¹®¼­¸¦ Çѹø º¸½Ã±æ ¹Ù¶ø´Ï´Ù. ±×Áßoverriding/overloading ¿¡ ´ëÇÑ ÀÌÇرîÁö¸¸ ¸¶Ä¡¸é Áغñ ³¡(teach youself C++ Á¤º¸¹®È­»ç ±ÇÀå)
2.Window ÇÁ·Î±×·¡¹Ö¿¡ ´ëÇÑ ÀÌÇØ.
-> Visual C++À» »ç¿ëÇÑ ¾îÇø®ÄÉÀÌ¼Ç °³¹ß¹æ¹ý¿¡ ´ëÇÑ ±âº»ÀûÀÎ ÀÌÇØ. ¸¹Àº °É ÇÒ ÇÊ¿ä´Â ¾ø½À´Ï´Ù.
1) MFCÀÇ ±âº»ÀûÀÎ ¶óÀ̺귯¸® »ç¿ë¹ý
2) SDI ¹× ´ÙÀ̾ó·Î±× ÀÎÅÍÆäÀ̽º
3) Æ®¸®ÄÁÆ®·Ñ, ¸®½ºÆ® ÄÁÆ®·Ñ, ODBC TRANSECTION
ÀÌ»ó µü ¼¼°¡Áö ÇÒ Á¤µµ¸¸ ÇÊ¿äÇÕ´Ï´Ù.
µÎ²¨¿î Bible óÀ½ºÎÅÍ ³¡±îÁö ÇÏÁö ¸¶½Ã°í ÇÊ¿äºÎºÐ¸¸ °ñ¶ó¼­ ÇϽñæ...

//----------------------------------------------------------------------------
* Font ¼³Á¤
char str100;

SetTextColor(hdc,RGB(255,0,255)); // Font »ö»ó
SetBkColor(hdc,RGB(0,0,255));
SetBkMode(hdc,TRANSPARENT); // ±ÛÀÚ µÞ¹è°æ ¹ÙÅÁ»ö°ú °°ÀÌ Ã³¸®

wsprintf(str," Total_Point = %d ",TotalPoint);
TextOut(hdc,10,10,str,22);

SetTextAlign(hdc,TA_LEFT); Á¤·Ä¹æ½Ä
SetTextColor(hdc,RGB(0,0,0)); ¹®ÀÚ¿­ »ö»ó Á¶Á¤

( (CMainFrame *)(this->GetParentFrame())Mytab->m_Page3.CheckNormal(g->m_togDisplayNormal);
( (CDirect9MFCView *)(((CMainFrame *)m_pMainWnd)->GetActiveView()) )->OpenFileMD2Data();


    ¡Ý º¯¼ö...
#.Printf Format Specification
• %l64d : signed 64-bit integer
• %l64u : unsigned 64-bit integer

# Á¤¼öÇü µ¥ÀÌŸ ŸÀÔ(°ªÀÇ ¹üÀ§¿¡ µû¶ó short, int, longÀ¸·Î ºÐ·ù)
• short - char¸¦ Á¦¿ÜÇÑ ÃÖ¼ÒÀÇ Á¤¼öÇüÀ̸ç, 16ºñÆ® ÀÌ»óÀÇ È¯°æ¿¡¼­ 2¹ÙÀÌÆ®(16ºñÆ®)·Î ó¸®
hortÇüÀÌ °¡Áú ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â -32,768 ~ 32,767À̸ç,
16ºñÆ® ȯ°æ(DOS, win95ȯ°æ)À̳ª 32ºñÆ® ȯ°æ(win2000ȯ°æ)¿¡¼­ °ªÀÇ ¹üÀ§´Â µ¿ÀÏ.
• int - ½Ã½ºÅÛÀÇ ±âº»ÀûÀÎ Á¤¼öÇü º¯¼öÀ̸ç,
16ºñÆ® ȯ°æ¿¡¼­´Â 2¹ÙÀÌÆ®, 32ºñÆ® ȯ°æ¿¡¼­´Â 4¹ÙÀÌÆ®(32ºñÆ®)·Î ó¸®
intÇüÀÌ °¡Áú ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â 16ºñÆ®, 32ºñÆ®¿¡ µû¶ó °¢°¢ ´Ù¸¨´Ï´Ù.
16ºñÆ® ȯ°æ¿¡¼­´Â shortÇü°ú °ªÀÇ ¹üÀ§(-32,768 ~ 32,767)°¡ µ¿ÀÏÇϸç
32ºñÆ® ȯ°æ¿¡¼­´Â -2,147,483,648 ~ 2,147,438,647.
• long - Á¤¼öÇü Áß °¡Àå Å« »çÀÌÁ Ç¥ÇöÇÒ ¼ö ÀÖÀ¸¸ç,
16ºñÆ® ȯ°æ°ú 32ºñÆ® ȯ°æ¿¡¼­ Å©±â°¡ µ¿ÀÏÇÏ°Ô 4¹ÙÀÌÆ®(32ºñÆ®)·Î ó¸®
longÇüÀÇ °ªÀÇ ¹üÀ§´Â -2,147,483,648 ~ 2,147,438,647.
• unsigned short - unsigned Áï, 0°ú ¾ç¼ö¸¸À» °¡Áú ¼ö ÀÖ´Ù´Â °ÍÀ» Á¦¿ÜÇÏ°í´Â shortÇü°ú µ¿ÀÏ
´Ü, À½¼ö¸¦ °¡ÁöÁö ¾ÊÀ¸¹Ç·Î ºÎÈ£ºñÆ®°¡ ÇÊ¿ä¾ø±â ¶§¹®¿¡ Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§°¡ ´õ ³Ð½À´Ï´Ù.
unsigned shortÇüÀÇ °ªÀÇ ¹üÀ§´Â 0 ~ 65,535.
• unsigned int - unsigned Áï, 0°ú ¾ç¼ö¸¸À» °¡Áú ¼ö ÀÖ´Ù´Â °ÍÀ» Á¦¿ÜÇÏ°í´Â intÇü°ú µ¿ÀÏ
ºÎÈ£ºñÆ®°¡ ÇÊ¿ä¾ø±â ¶§¹®¿¡, Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â 0 ~ 4,294,967,295.
• unsigned long - unsigned Áï, 0°ú ¾ç¼ö¸¸À» °¡Áú ¼ö ÀÖ´Ù´Â °ÍÀ» Á¦¿ÜÇÏ°í´Â longÇü°ú µ¿ÀÏ.
ºÎÈ£ºñÆ®°¡ ÇÊ¿ä¾ø±â ¶§¹®¿¡, Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â 0 ~ 4,294,967,295.

Visual C++ ±âÁØ Ç¥±â¹ý À©µµ¿ì¿¡ Á¤ÀÇµÈ µ¥ÀÌÅÍÇü
Name Description Name Description
CS Ŭ·¡½º ½ºÅ¸ÀÏ ¿É¼Ç BOOL ³í¸®Çü TRUE ¶Ç´Â FALSE °ª¸¸ °¡Áú ¼ö ÀÖ´Ù
CW À©µµ¿ì »ý¼º ¿É¼Ç BYTE unsigned char (8 bit)
DT ¹®ÀÚ¿­ ±×¸®±â ¿É¼Ç DWORD unsigned long (32 bit)
IDI ¾ÆÀÌÄÜ¿¡ ´ëÇÑ ID DWORDLONG unsigned double (64 bit)
IDC Ä¿¼­¿¡ ´ëÇÑ ID ¼ýÀÚ FLOAT float
MB ¸Þ½ÃÁö ¹Ú½º LONG signed long (32 bit)
SND »ç¿îµå ¿É¼Ç LONGLONG signed double (64 bit)
WM À©µµ¿ì ¸Þ½ÃÁö LPARAM 32 bit ¸Þ¼¼Áö ÆĶó¹ÌÅÍ
WS À©µµ¿ì ½ºÅ¸ÀÏ LPCSTR ³Î ¹®ÀÚ·Î ³¡³ª´Â À©µµ¿ì ¹®ÀÚ¿­ »ó¼öÀÇ Æ÷ÀÎÅÍ
MSG ¸Þ½ÃÁö ±¸Á¶Ã¼ LPCTSTR ³Î ¹®ÀÚ·Î ³¡³ª´Â À¯´ÏÄÚµå ¶Ç´Â À©µµ¿ì ¹®ÀÚ¿­ »ó¼öÀÇ Æ÷ÀÎÅÍ
WNDCLASS À©µµ¿ì Ŭ·¡½º ±¸Á¶Ã¼ LPSTR ³Î ¹®ÀÚ·Î ³¡³ª´Â À©µµ¿ì ¹®ÀÚ¿­ÀÇ Æ÷ÀÎÅÍ
PAINTSTRUCT Paint ±¸Á¶Ã¼ LPTSTR ³Î ¹®ÀÚ·Î ³¡³ª´Â À¯´ÏÄÚµå ¶Ç´Â À©µµ¿ì ¹®ÀÚ¿­ÀÇ Æ÷ÀÎÅÍ
RECT »ç°¢Çü ±¸Á¶Ã¼ TCHAR À¯´ÏÄÚµå ¶Ç´Â À©µµ¿ì ¹®ÀÚ
HINSTANCE ÇÁ·Î±×·¥ ÀνºÅϽº¿¡ ´ëÇÑ ÇÚµé UINT unsigned int (32 bit)
HWND À©µµ¿ì¿¡ ´ëÇÑ ÇÚµé WORD unsigned short (16 bit)
HDC DeviceContext(ÀåÄ¡ ÄÁÅؽºÆ®)¿¡ ´ëÇÑ ÇÚµé WPARAM 16 bit ¸Þ¼¼Áö ÆĶó¹ÌÅÍ
* 32ºñÆ® ¿î¿µÃ¼Á¦¿¡¼­ ÀÛµ¿µÇ´Â ÄÄÇ»Å͵éÀº ¸ðµÎ ÁÖ¼Ò°ªÀÇ Å©±â°¡ 32 ºñÆ® (Áï, 4 ¹ÙÀÌÆ®)·Î ³ªÅ¸³¿.
Áï ÁÖ¼Ò°ªÀÌ 0x00000000 ~ 0xFFFFFFFF ±îÁöÀÇ °ªÀ» °¡Áø´Ù.
ÁÖ¼Ò°ªÀÇ °¡Áö¼ö´Â 2 ÀÇ 32 ½Â ¹ÙÀÌÆ®, Áï RAM Àº ÃÖ´ë 4 GB ±îÁö ¹Û¿¡ »ç¿ëÇÒ ¼ö ¾ø´Ù. ÀÌ ¶§¹®¿¡ 32 ºñÆ® ¿î¿µÃ¼Á¦¿¡¼­´Â RAMÀÇ ÃÖ´ë Å©±â°¡ 4 GB ·Î Á¦ÇѵȴÙ.


    ¡Ý ¿¬»êÀÚ...

Bit¿¬»ê #

¿¬»êÀÚ ¿¬»ê ¼³¸í
& AND µÑ ´Ù 1À̸é 1
| OR Çϳª¸¸ 1À̸é 1
^ XOR ´Ù¸£¸é 1
~ NOT 1À̸é 0, 0À̸é 1
<< LEFT SHIFT ¿ÞÂÊÀ¸·Î ºñÆ® À̵¿
>> RIGHT SHIFT ¿À¸¥ÂÊÀ¸·Î ºñÆ® À̵¿

#. & (AND) ¿¬»êÀÚ ; ¿øÇÏ´Â ºñÆ®¸¸ º¯°æ
-. °øÅëºÎºÐ ±¸Çѱâ
¾à°£ Á¦ÇÑµÈ °æ¿ìÁö¸¸ ¿¡¶óÅ佺Å׳׽ºÀÇ Ã¼¸¦ ÀÌ¿ëÇÏ¿© ¼Ò¼ö¸¦ ±¸ÇÒ ¶§ ó·³ ¹è¿­¿¡ 1°ú 0¸¸ ³Ö¾î, Âü, °ÅÁþÀ» ±¸º°ÇÒ ¶§ if¹®À» »ç¿ëÇÏ´Â °Í º¸´Ù ºü¸£°Ô ÀÛµ¿

void samesame(int *a, *b, int *c)  // a, b, c Èĺ¸¼ýÀÚ ¹è¿­ÀÇ ±³ÁýÇպκÐÀ» ±¸ÇÔ
{  // cf.ÀÌ ÇÔ¼ö´Â C¾ð¾î ½ºµµÄí ÀÚµ¿Ç®ÀÌ ÇÁ·Î±×·¥¿¡ »ç¿ë
  int i;
  for( i=1; i<=9; i++ )
    a[i]=a[i]&b[i]&c[i];    // ¼Â ´Ù 1À̸é 1ÀúÀå, Çϳª¶óµµ 0À̸é 0ÀúÀå
} 

#. | (OR) ¿¬»êÀÚ ; ¿øÇÏ´Â ºñÆ®¸¦ 1·Î ¹Ù²Ù°í ½ÍÀ» ¶§, & ¿¬»êó·³ »ç¿ë

#. ^ (XOR) ¿¬»êÀÚ ; °ª ±³È¯ (µ¿ÀÛ ´À¸²)

void swap(int *a, *b)
{
  *a^=*b;
  *b^=*a;
  *a^=*b;  // ÀÌ ¼¼¹øÀÇ µ¿ÀÛÀ¸·Î a¿Í bÀÇ °ªÀ» ±³È¯
} 
cf.0À¸·Î ÃʱâÈ­ ÇÒ ¶§, a^=a¸¦ Çϸé a°¡ 0À¸·Î ÃʱâÈ­

#. ~ (NOT) ¿¬»êÀÚ : Á¤¼öÇü º¯¼öÀÇ ÃÖ´ñ°ªÀ» ±¸ÇÒ ¶§

#include <stio.h>

int main()
{
  int a=1;
  char b=1;
  __int64 c=1;
  a<<=31;
  b<<=7;
  printf("%d %d, ~a, ~b);
  // °¡Àå ¿À¸¥ÂÊÀÇ ºñÆ®¸¦ °¡Àå ¿ÞÂÊÀ¸·Î À̵¿½ÃÅ°°í ~¿¬»êÀ¸·Î °¡Àå ¿ÞÂʺñÆ®¸¸ »©°í ÀüºÎ 1·Î ¸¸µé¾î ÃÖ´ë°ªÀ» Ãâ·Â
  // (ºÎÈ£ÀÖ´Â º¯¼ö´Â °¡Àå ¿ÞÂÊÀÇ ºñÆ®´Â À½¼ö¸¦ ³ªÅ¸³¾ ¶§ »ç¿ë)
} 

ÇØ´ç ºñÆ®¸¸ Á¢±Ù/º¯°æ ÇÏ´Â ¹æ¹ý #

µ¥ÀÌÅÍÀÇ ÇÑ ºñÆ®¸¸ Á¶ÀÛÇÏ´Â ¹æ¹ýÀ¸·Î AND(&) ¶Ç´Â OR(|) ¿¬»êÀÚ¸¦ ÀÌ¿ëÇÑ´Ù. ¿¹¸¦ µé¸é,
unsigned char a = 0; ·Î ¼±¾ð/Á¤ÀǵǾúÀ» ¶§
(f_ln) '1'·Î ¼¼Æ®ÇÏ´Â ¹æ¹ý : a |= 0x08; // ºñÆ® 3¹ø ¼¼Æ®
(f_ln) '0'À¸·Î Ŭ¸®¾î ÇÏ´Â ¹æ¹ý : a &= ~0x08; // ºñÆ® 3¹ø Ŭ¸®¾î

Shift ¿¬»êÀÚ (ºü¸§) #

1. ¿ÞÂÊshift (<<)
¿ÞÂÊÀ¸·Î 1Ä­ À̵¿½Ã¸¶´Ù *2¾¿ Ä¿Áø´Ù(ºó°ø°£Àº 0À¸·Î ä¿ò)
2. ¿À¸¥ÂÊshift (>>)
¿À¸¥ÂÊÀ¸·Î 1Ä­ À̵¿½Ã¸¶´Ù /2¾¿ ÀÛ¾ÆÁø´Ù.
¦£ JAVA¿¡¼­´Â signed right shift operator¶ó ÇÑ´Ù.
¦¦ ºó°ø°£Àº ºÎÈ£ºñÆ®À¸·Î ä¿î´Ù(¾ç¼ö¿Í À½¼öÀÇ Ã³¸®°¡ ´Ù¸§)
3. ¿À¸¥ÂÊshift (>>>)(¾ç¼öÈ­ ½ÃÅ´)
¦£ JAVA¿¡¼­´Â unsigned right shift operator¶ó ÇÑ´Ù.
¦¦ ºó°ø°£Àº 0À¸·Î ä¿î´Ù.

a << 1; 2 ¹è
a << 2; 4 ¹è
a << 3; 8 ¹è
a << 4; 16 ¹è
a << 4 - a; 15 ¹è
a << 4 + a; 17 ¹è
a << 5; 32 ¹è
a << 6; 64 ¹è
a << 6 - a << 2; 60¹è

#.Shift ¿¬»ê
// cf. enum...
Inline DWORD SETBIT(DWORD & dwBitSet, int bit)
{
Return dwBitSet |= (1<<bit);
}

¿¬»êÀÚ ¿À¹ö·Îµù(operator overloading) È°¿ë¿¹ #


class cGroup
{ 
public:
	// Group Types
	const static enum EGROUP_TYPES
	{
		KGROUP_TYPE_1,
		KGROUP_TYPE_2,
		KGROUP_TYPE_3,
		KGROUP_TYPE_4,
		KGROUP_TYPE_COUNT
	};
	int 	m_GroupTypeValues[ KGROUP_TYPE_COUNT ];

public:
	cGroup( void );
	~cGroup();

    	void operator/= ( int nValue );
	void operator*= ( int nValue );
    	void operator/= ( float fValue );
	void operator*= ( float fValue );
    	void operator+= ( cGroup group );
	void operator-= ( cGroup group );
    	BOOL operator== ( cGroup group );
	BOOL operator!= ( cGroup group );
    	BOOL operator>= ( cGroup group );
	BOOL operator<= ( cGroup group );
    	BOOL operator> ( cGroup group );
	BOOL operator< ( cGroup group );
	cGroup operator+ ( cGroup group );
	cGroup operator- ( cGroup group );
};

void cGroup::operator/= (int nValue)
{
	m_GroupTypeValues[ KGROUP_TYPE_1 ] /= nValue;
	m_GroupTypeValues[ KGROUP_TYPE_2 ] /= nValue;
	m_GroupTypeValues[ KGROUP_TYPE_3 ] /= nValue;
	m_GroupTypeValues[ KGROUP_TYPE_4 ] /= nValue;
}

HIWORD(I)ÀÇ ¸ÅÅ©·ÎÇÔ¼ö Á¤ÀÇ #

((WORD)(((DWORD)(l) >> 16) & 0xFFFF))

HIWORD(I)ÀÇ ¸ÅÅ©·ÎÇÔ¼ö Á¤ÀÇÀ̱º¿ä.
32ºñÆ® Á¤¼öÀÇ »óÀ§ 16ºñÆ®¸¦ ±¸ÇÏ´Â µ¥ ¾µ ¼ö ÀÖ½À´Ï´Ù.

1. (I) : ¸ÅÅ©·Î Á¤ÀÇÀ̹ǷΠI¸¦ °ýÈ£·Î ½Î¼­ ¸ÅÅ©·Î°¡ Àü°³µÉ ¶§ ¿À·ù°¡ µÇ´Â °ÍÀ» ¹æÁöÇÔ
2. (DWORD)(I) : I ÀÚ¸®¿¡ ġȯµÇ´Â ¼ö¸¦, ŸÀÔ¿¡ »ó°ü¾øÀÌ ¹«Á¶°Ç ºÎÈ£¾ø´Â 32ºñÆ® Á¤¼ö·Î º¯È¯
3. (DWORD)(I) >> 16 : ¿À¸¥ÂÊÀ¸·Î 16ºñÆ® ½¬ÇÁÆ®. ÇÏÀ§ 16ºñÆ®¸¦ ¹ö¸®°í »óÀ§ 16ºñÆ®¸¦ ÇÏÀ§·Î ÀÚ¸® ¿Å±è
4. ((DWORD)(I) >> 16) & 0xFFFF : »ç½Ç ÇÊ¿ä¾ø´Â °ÍÀÌÁö¸¸ »óÀ§ 16ºñÆ® ºÎºÐÀ» ¸ðµÎ 0À¸·Î ä¿ò
5. (WORD)(((DWORD)(I) >> 16) & 0xFFFF) : ºÎÈ£¾ø´Â 16ºñÆ® Á¤¼öÇüÀ¸·Î º¯È¯
6. ((WORD)(((DWORD)(I) >> 16) & 0xFFFF)) : ¸ÅÅ©·Î ÇÔ¼öÀ̹ǷΠÁ¿쿡 °ýÈ£¸¦ ½Ó



    ¡Ý ¹®ÀÚ¿­...
* char* ÇüÀ» STL string ÇüÀ¸·Î ¹Ù²Ù´Â ¹æ¹ý
#include <iostream>
#include <string>
using namespace std;

void main(){
char *s = "123";
string s1 = (string)s;
string s2 = string(s);

cout << s1 << endl;
cout << s2 << endl;
}

* ±âÁ¸ÀÇ C API¿¡ stringÀ» ³Ñ±â´Â ¹æ¹ý
void doSomething(const char * pString){...};

string s;
doSomething( s.c_str() );

#.ANSI Äڵ忡¼­ UTF-8·Î °¡±â À§Çؼ­´Â ´ÙÀ½°ú °°Àº º¯È¯°úÁ¤À» °ÅÃÄ¾ß ÇÕ´Ï´Ù.
ANSI( MutiByte ) -> UCS-2( WideByte ) -> UTF-8( MultiByte )

void foo( const char *in, char *out, int nOut )
{
    USES_CONVERSION;
    wchar_t *wc = A2W( in ); // ANSI to UCS-2
    WideCharToMultiByte( CP_UTF8, 0, wc, -1, out, nOut, 0, 0 ); // UCS-2 to UTF-8
}
À©µµ¿ì¿¡¼­´Â MultiByteToWideChar()¸¦ Á¦°øÇÕ´Ï´Ù.
À¯»ç Æ÷¸ËÀ¸·Î´Â mbstowcs()°¡ ÀÖÁö¸¸ ÀÌ ÇÔ¼ö´Â UTF-8Àº Á¦°øÇÏÁö ¾Ê½À´Ï´Ù.

Âü°í·Î A2W³ª USES_CONVERSIONÀº ATL °ü·Ã ÇÔ¼öÀÔ´Ï´Ù.
¹Ý´ë·Î º¯È¯ÇÒ 떄´Â MultiByteToWideChar()¿Í W2A()¸¦ ÀÌ¿ëÇÏ½Ã¸é µË´Ï´Ù.
À§¿¡µµ Àû¾î³ùÁö¸¸ ANSI³ª UTF-8À̳ª ´Ù MultiByteÀÔ´Ï´Ù.
A2W()´Â ³»ºÎÀûÀ¸·Î MultiByteToWideChar()¸¦,
W2A()´Â ³»ºÎÀûÀ¸·Î WideCharToMultiByte()¸¦ È£ÃâÇÕ´Ï´Ù.

* char --> wchar·Î º¯È¯

   char szSource[] = "Text to convert";
  wchar szDest[100];
  MultiByteToWideChar( GetACP(), 0, szSource, -1, szDest, sizeof(szDest)/sizeof(szDest[0]) );
 

* #include <atlbase.h>
T2A <-- tchar¸¦ ¸ÖƼ¹ÙÀÌÆ® ½ºÆ®¸µÀ¸·Î..
T2W <-- tchar¸¦ À¯´ÏÄÚµå ½ºÆ®¸µÀ¸·Î...
W2A <-- À¯´ÏÄڵ带 ¸ÖƼ¹ÙÀÌÆ®·Î
A2W <-- ¸ÖƼ¹ÙÀÌÆ®¸¦ À¯´ÏÄÚµå·Î
W2T
A2T

* ¹®ÀÚ¿­ ºñ±³
if (strcmp(szJin,"jin")==0) {
// ÇÏ°í½ÍÀº ÀÏ
}
´ë¼Ò¹®ÀÚ ±¸ºÐ¾øÀÌ ºñ±³ÇÏ·Á¸é stricmp ÇÔ¼ö¸¦, À¯´ÏÄڵ带 »ç¿ëÇϽ÷Á¸é lstrcmp ÇÔ¼ö¸¦ ¾´´Ù.


    ¡Ý ÇÁ·Î±×·¥ ³»¿¡¼­ ÇÑ¿µ Àüȯ...
#pragma comment(lib, "imm32.lib")
#include <imm.h>

// ÇÑ¿µ Àüȯ
void CChattingDlg::SetIMEMode( HWND hWnd, BOOL bHanMode )
{
HIMC hIMC = ImmGetContext( hWnd );
DWORD dwConv, dwSent;
DWORD dwTemp;

ImmGetConversionStatus(hIMC,&dwConv,&dwSent);
dwTemp = dwConv & ~IME_CMODE_LANGUAGE;

// »óŸ¦ ¹Ù²ß´Ï´Ù.
if( bHanMode )
dwTemp |= IME_CMODE_NATIVE; // ÇѱÛ
else
dwTemp |= IME_CMODE_ALPHANUMERIC; // ¿µ¹®

dwConv = dwTemp;

ImmSetConversionStatus(hIMC,dwConv,dwSent);
ImmReleaseContext(hWnd,hIMC);
}


    ¡Ý ÇÔ¼ö...
¢Â Á¤¼öÈ­ ÇÔ¼ö
• Á¤¼öÈ­ ÇÔ¼ö´Â ½Ç¼öÇü µ¥ÀÌÅÍ¿¡¼­ Á¤¼öºÎ¸¸À» ÃëÇÏ´Â, Áï ¼Ò¼öÁ¡ ÀÌÇÏÀÇ ¼Ò¼öºÎ¸¦ À߶ó ¹ö¸®´Â ÇÔ¼öÀÌ´Ù. ¼Ò¼öºÎ¸¦ À߶ó ¹ö¸°´Ù°í Çؼ­ °è»ê °á°ú°¡ Á¤¼ö°¡ µÇ´Â °ÍÀº ¾Æ´Ï¸ç ¸®ÅÏ°ªÀº ¿©ÀüÈ÷ ½Ç¼öÀÌ´Ù. ½Ç¼ö°ªÀÇ ¼Ò¼öºÎ¸¸À» 0À¸·Î ¸¸µç´Ù°í »ý°¢ÇÏ¸é µÈ´Ù. Á¤¼öÈ­ ÇÔ¼ö¿¡´Â ´ÙÀ½ µÎ °¡Áö°¡ ÀÖ´Ù

¢¹ double floor( double x ); // ÁÖ¾îÁø Àμöº¸´Ù Å©Áö ¾ÊÀº ÃÖ´ë Á¤¼ö
¼Ò¼öÁ¡ ÀÌÇϸ¦ ÀÚ¸£´Â ¹æ½ÄÀ¸·Î ¼Ò¼öÁ¡ ÀÌÇϸ¦ ¹ö¸®°í Á¤¼öºÎ¸¸À» ÃëÇÔ

floor(3.14); // °á°ú´Â 3.0
floor(-3.14); // °á°ú´Â -4.0

¢¹ double ceil( double x ); // ÁÖ¾îÁø Àμöº¸´Ù ÀÛÁö ¾ÊÀº ÃÖ¼Ò Á¤¼ö
¼Ò¼öÁ¡ ÀÌÇϸ¦ ¿Ã¸²Çؼ­ Á¤¼öºÎ¸¦ 1Áõ°¡

ceil(3.14); // °á°ú´Â 4.0
ceil(-3.14) // °á°ú´Â -3.0

• C ¾ð¾î´Â ¹Ý¿Ã¸² ÇÔ¼ö¸¦ µû·Î Á¦°øÇÏÁö ¾Ê°í, ±âÁ¸ ÇÔ¼ö¸¦ ÀÀ¿ëÇÑ´Ù.
1.½Ç¼ö x¸¦ ¹Ý¿Ã¸²ÇÑ °ª = floor(x+0.5); // 0.5 ÀÌ»óÀÇ °ªÀ» ¹Ý¿Ã¸²
cf.ceil(x-0.5); // 0.5 ÃÊ°ú °ªÀ» ¹Ý¿Ã¸²
2.¼Ò¼öÁ¡ µÑ °ÀÚ¸®¿¡¼­ ¹Ý¿Ã¸² = floor(x*10+0.5)/10;
3.¼Ò¼öÁ¡ n¹ø° ÀÚ¸®¿¡¼­ ¹Ý¿Ã¸²µÇ´Â ÇÔ¼ö¸¦ ¸¸µé ¼ö Àִµ¥ ¾ÆÁÖ °£´ÜÇϹǷΠ¸ÅÅ©·Î ÇÔ¼ö·Î Á¤ÀÇ
#define banollim(x,dig) (floor((x)*pow(10,dig)+0.5)/pow(10,dig))
4.double round(double x); // ¹Ý¿Ã¸² ÇÔ¼ö, À½¼öÀÏ °æ¿ì ¹Ý³»¸²À» ÇÑ´Ù.
#include <math.h>

double round( double x)
{
return ( (x>0> ? floor(x+0.5) : ceil(x-0.5);
}

¢Â È£Ãâ°üÇà
_cdecl - ¸¶Áö¸· ÀÎÀÚºÎÅÍ ½ºÅÿ¡ ÀúÀåÇϸç, ÇÔ¼ö¸¦ È£ÃâÇÑ ÂÊ¿¡¼­ ½ºÅÃÀ» Á¤¸®ÇÑ´Ù.
_stdcall - ¸¶Áö¸· ÀÎÀÚºÎÅÍ ½ºÅÿ¡ ÀúÀåÇϸç, È£ÃâµÈ ÇÔ¼ö°¡ ½ºÅÃÀ» Á¤¸®ÇÑ´Ù.
_fastcall - ·¹Áö½ºÅÍ¿¡ ÀÎÀÚ µÎ °³¸¦ ³Ö°í, ¸¶Áö¸· ÀÎÀÚºÎÅÍ ½ºÅÿ¡ ÀúÀåÇϸç È£ÃâµÈ ÇÔ¼ö°¡ ½ºÅÃÀ» Á¤¸®ÇÑ´Ù.
_stdcall Àº º¸Åë APIµéÀÌ »ç¿ëÇÏ°í ÀÖ´Ù. ±× ÀÌÀ¯´Â ½ºÅÃÀ» Á¤¸®ÇÏ´Â Äڵ尡 API ÂÊ¿¡ ÀÖ°Ô µÇ¸é ±× ¸¸Å­ ¸Þ¸ð¸®¸¦ Àý¾àÇÒ ¼ö Àֱ⠶§¹®ÀÌ´Ù. API´Â ¿©·¯ ´Ù¸¥ Ŭ¶óÀ̾ðÆ®¿¡ ÀÇÇؼ­ È£ÃâµÈ´Ù´Â °¡Á¤ ÇÏ¿¡ ±âµ¿ÇÑ´Ù.

¢Â void *realloc( void *memblock, size_t size );
Á¶Á¤ ´ë»óÀÌ µÇ´Â ¸Þ¸ð¸® ºí·°À» size¸¸Å­ ´Ù½Ã ÇÒ´çÇÑ´Ù.(À̶§, ¸Þ¸ð¸®·®À» ¹ÙÀÌÆ® ´ÜÀ§·Î Ç¥Çö)
¸Þ¸ð¸®°¡ ºÎÁ·ÇÏ¿© ÇÒ´çÇÏÁö ¸øÇßÀ» °æ¿ì NULLÀ» ¸®ÅÏÇϸç, ¸Þ¸ð¸®´Â Á¦ÇÑÀûÀ̱⠶§¹®¿¡ µ¿Àû ÇÒ´ç½Ã Ç×»ó ¿¡·¯¸¦ °Ë»ç ÇؾßÇÑ´Ù.

¢Â ½Ã½ºÅÛ ÇØ»óµµ ±¸Çϱâ
HDC hDC = ::GetDC(NULL);
// HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
int width = GetDeviceCaps(hDC, HORZRES);
int height = GetDeviceCaps(hDC, VERTRES);
-.GetDeviceCaps()ÇÔ¼ö´Â Get device capabilities·Î½á DC¿Í ¿¬°üµÈ deviceÀÇ ¼º´ÉÀ» ±¸ÇÏ°íÀÚ ÇÒ ¶§ »ç¿ë
ÀÎÀÚ·Î ¿É¼ÇÀ» ÁÖ¸é ±× ¿É¼Ç¿¡ ÇØ´çÇÏ´Â °ªÀÌ ³ª¿À´Âµ¥, (ÀÎÀÚ Á¾·ù ¸¹À½ ^^)
HORZRES, VERTRES¸¦ ÀÎÀÚ·Î ³ÖÀ¸¸é µð½ºÇ÷¹ÀÌÀÇ Æø°ú ³ôÀÌ°¡ Çȼ¿ ´ÜÀ§·Î ³ª¿Â´Ù.

¢Â Àüó¸® ÀÀ¿ë
void ConsoleCommandTableInit( void )
{
#define CONSOLE_DESC( desc ) sCommandTableAddCommandDescription(L##desc)
#define CONSOLE_CMD( cmd, cheat, appType, gameType, func, valParam )\
STATIC_CHECK( (cheat) != NOT_CHEATS ||
(gameType) != COMMAND_SERVER, SERVER_SIDE_COMMANDS_NOT_ALLOWED_IN_RELEASE );\
sCommandTableRegisterCommand( NULL, L##cmd, cheat, appType, gameType, func, valParam)
...
ConsoleCommandTableFree();
...
ÄÜ¼Ö ¸í·É Á¤ÀÇ(ÇÔ¼ö È£Ãâ)

#undef CONSOLE_CMD
#undef CONSOLE_DESC
...
ConsoleAddEmotes(); // À̸ð¼Ç °ü·Ã Äָܼí·É Ãß°¡
}



    ¡Ý ½Ã°£´Ù·ç±â
¡á ½Ã°£´Ù·ç±â ; http://www.gpgstudy.com/gpgiki/%BD%C3%B0%A3%20%B4%D9%B7%E7%B1%E2#heading15
timeGetTime()
#pragma comment(lib, "winmm.lib")
#include <mmsystem.h>
GetTickCount()
#include <Windows.h>
QueryPerformanceFrequency()
QueryPerformanceCounter()- ¸î¸î CPU¿¡¼± Ŭ·°ÀÌ °Ç³Ê¶Ú´Ù´Â º¸°í°¡ ÀÖÀ½...
{_-} CPU Ŭ·°¿¡ »ó°üÀÌ ¾ø´Â timeGetTime()ÇÔ¼ö¸¦ »ç¿ë

¡á Win32API/ GetLocalTime(...); {_-} ¸Þ¸ðÀå_C_Time @ 1202_06_16 @




    ¡Ý (error) Messgae
* WM_MOUSEWHEEL ¸Þ½ÃÁö°¡ Undeclared identifier·Î ³ª¿Ã ¶§
1.VC6ÀÇ include Æú´õ¿¡ ÀÖ´Â WINUSER.H ¶Ç´Â zmouse.h »ç¿ë
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
#define WM_MOUSEWHEEL 0x020A
#define WM_MOUSELAST 0x020A
#else
#define WM_MOUSELAST 0x0209
#endif /* if (_WIN32_WINNT < 0x0400) */
2.#define WM_MOUSEWHEEL 0x020A Ãß°¡

* error LNK2001: unresolved external symbol _main ÀÌ ¿¡·¯°¡ ¹ß»ýÇÏ´Â µÎ°¡Áö ¿øÀÎ

1.Visual C++¿¡¼­ ÇÁ·ÎÁ§Æ® ¼ÂÆÃÀÇ ¹®Á¦
ÇÁ·ÎÁ§Æ®¸¦ ¸¸µé ¶§ Win32 Application : WinMain ÇÔ¼ö¿¡¼­ ½ÃÀÛÇÏ°Ô µÇ´Â GUI ÇÁ·Î±×·¥
Win32 Console Application : main ÇÔ¼ö¿¡¼­ ½ÃÀÛÇÏ´Â console ÇÁ·Î±×·¥À¸·Î Å©°Ô ±¸ºÐÀÌ µÈ´Ù.

À§ÀÇ ¿¡·¯´Â ´ëºÎºÐ GUI ÇÁ·Î±×·¥À» ¸¸µå·Á°í WinMain·Î ½ÃÀÛÇߴµ¥
ÇÁ·ÎÁ§Æ®¸¦ ¸¸µé ¶§ console applicationÀ» ¼±ÅÃÇÑ °æ¿ì·Î, ¹Ý´ë·Î WinMainÀÌ ¾ø´Ù°í ¿¡·¯°¡ ³ª¿À¸é GUI ÇÁ·ÎÁ§Æ®¸¦ ¼±ÅÃÇÏ°í¼­ main ÇÔ¼ö¸¦ ÀÛ¼ºÇÑ °æ¿ìÀÌ´Ù.

ÇØ°áÀº ¼³Á¤À» ¹Ù²ãÁÖ¸é µÇ´Âµ¥, LinkÅÇ¿¡¼­ /subsystem:consoleÀ» /subsystem:windows·Î ¹Ù²ãÁØ´Ù(¶Ç´Â »óȲ¿¡ µû¶ó¼­ ±× ¹Ý´ë·Î ¼³Á¤)
ÀÌ ¿É¼ÇÀÇ ¿ªÇÒÀº ¸µÄ¿¿¡°Ô À־ ÀÌ ÇÁ·Î±×·¥ÀÌ ¾î¶² ÇÔ¼ö·ÎºÎÅÍ ½ÃÀÛÇØ¾ß ÇÏ´ÂÁö¸¦ ¾Ë·ÁÁÖ´Â ¿ªÇÒÀ» ÇÑ´Ù. consoleÀ̶ó¸é mainÀ», windows¶ó¸é WinMainÀ» ã¾Æ¼­ ±× ÇÔ¼ö¿¡¼­ºÎÅÍ ÇÁ·Î±×·¥ÀÌ ½ÃÀÛÇÑ´Ù.
(cf. Jeffrey RitcherÀú Programming Applications for Windows 4th.)

2. ATL¿¡¼­ ÄÁÆ®·ÑÀ» ¸¸µé ¶§ ¹ß»ý
µð¹ö±×¿¡¼­´Â Àß ÄÄÆÄÀÏÀÌ µÇ´ø°Ô ¸±¸®Áî·Î ºôµåÇϸé Àú ¿¡·¯°¡ ³¯ ¼ö ÀÖ´Ù. ATL¿¡¼­´Â »ý¼ºµÇ´Â ÄÚµåÀÇ Å©±â¸¦ ÃÖ¼ÒÈ­ Çϱâ À§Çؼ­ CRT (C RunTime) ÇÔ¼öÀÇ ÀϺθ¦ Á¦ÇÑÇÏ°í Àֱ⠶§¹®ÀÌ´Ù(Á¤È®È÷ ¸»ÇÏÀÚ¸é start up Äڵ带 ³ÖÁö ¾Ê´Â´Ù). ±×·±µ¥ ÇÁ·ÎÁ§Æ®¿¡¼­ ƯÁ¤ C ÇÔ¼ö¸¦ »ç¿ëÇϸé ATL¿¡¼­ Á¦ÇÑÇÑ CRTÀÇ ±â´ÉÀÌ ÇÊ¿äÇØÁö°í µû¶ó¼­ ¿¡·¯°¡ ¹ß»ýÇÑ´Ù.

ÇØ°áÀº a. ÇÁ·ÎÁ§Æ® ¼¼Æÿ¡¼­ predefined keyword¸¦ ã¾Æ¼­ _ATL_MIN_CRT¸¦ Áö¿ì°í,
b. ÃʱâÈ­°¡ ÇÊ¿äÇÑ CRT ÇÔ¼ö¸¦ »ç¿ëÇÏÁö ¾Ê´Â´Ù(MSDN¿¡ µû¸£¸é strcmp´ë½Å lstrcmp¸¦ »ç¿ëÇÏ´Â ½ÄÀ¸·Î ÇÇÇØ°¥ ¼ö ÀÖ´Ù°í ÇÔ)
(cf.MSDN¿¡¼­ _ATL_MIN_CRT·Î »öÀο¡¼­ °Ë»ö)


    ¡Ý Å°º¸µå ÀÔ·Â
1.GetAsyncKeyState() ; ÇÔ¼ö°¡ È£ÃâµÈ ½ÃÁ¡ÀÇ Å° »óŸ¦ Á¶»çÇؼ­ ¸®ÅÏ
(GetAsyncKeyState( VK_LEFT )) ? (St_run=TRUE, St_rundir=2, Move_x -= 4 ) : NULL;
(GetAsyncKeyState( VK_RIGHT ))? (St_run=TRUE, St_rundir=3, Move_x += 4 ) : NULL;
cf.GetKeyState() ; ¸¶Áö¸·À¸·Î Å°¸Þ½ÃÁö ¹ß»ý ÈÄÀÇ »óÅ º¯È­¸¦ ¸®ÅÏÇÕ´Ï´Ù.
µû¶ó¼­ GetKeyStateÇÔ¼ö´Â Å°º¸µå ¸Þ½ÃÁö ó¸® ·çƾ ³»¿¡¼­¸¸ À¯È¿ÇÑ °ªÀ» ¸®ÅÏÇÑ´Ù°í »ý°¢ÇÏ¸é µË´Ï´Ù.
2.GetKeyboardState() - Çѹø¿¡ 256°³ÀÇ Å°»óŸ¦ ´Ù ¹Þ¾Æ¿À´Â ÇÔ¼ö±¸¿ä
unsigned char keys£Û256£Ý;
GetKeyboardState( keys );
if( keys£ÛVK_UP£Ý & 0x80 ) St_run=TRUE;
3.WndProc()¿¡¼­ ó¸®
BYTE m_bKey£Û256£Ý; // Àü¿ªÀ¸·Î ¼³Á¤ ÇÑ´Ù¸é
memset (m_bKey, 0, sizeof (m_bKey)); // Å°º¸µå Á¦¾î¸¦ À§ÇÑ ÃʱâÄ¡
...
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_KEYUP: //mark a key up
m_bKey /wParam/ = FALSE;
break;
case WM_KEYDOWN: //mark a key down
m_bKey /wParam/ = TRUE;
break;
}
return DefWindowProc( hWnd, message, wParam, lParam );
}
...
if(m_bKey 'R' ) ResetPhysics(); // ó¸®ÇÏ°í ½ÍÀº °÷¿¡¼­ ó¸®
4.ShiftÅ°¿Í Á¶ÇÕ ¿©ºÎ È®ÀÎ
if(GetKeyState(VK_SHIFT) & 0x8000) // Shift +
if(GetKeyState(VK_SHIFT) < 0) // ShiftÅ°°¡ ´­·ÁÁö¸é À½¼ö°ªÀ» ¸®ÅÏ

BOOL bControlKeyDown1 = GetAsyncKeyState (VK_SHIFT) >> ((sizeof(SHORT) * 8) - 1);
if( bControlKeyDown1 ) return TRUE;

case WM_SYSKEYDOWN: Àº Alt Å°°¡ ´­·ÁÁ³À» ¶§ À̺¥Æ® ¹ß»ý


    ¡Ý ÈÞÅ·À» »ç¿ëÇÏÁö ¾Ê°í Å°º¸µå/ ¸¶¿ì½º À̺¥Æ® ¾ò¾î¿À´Â ¹æ¹ý
ÈÄÅ·À» Å°·Î°Å ¿Í °°Àº ¾Ç¼ºÄÚµå/½ºÆÄÀÌ¿þ¾î·Î ¾Ç¿ë µÇ°í Àֱ⠶§¹®¿¡, MS¿¡¼­ À©µµ¿ì Æ÷Ä¿½º°¡ ÀÒ°Ô µÇµµ ¸¶¿ì½º/Å°º¸µå À̺¥Æ®¸¦ ¾ò¾î¿Ã¼ö ÀÖ´Â ¹æ¹ýÀ» ¸¸µé¾ú´Ù.

RegisterRawInputDevicesÇÔ¼ö·Î ½Ã½ºÅÛ¿¡ Å°º¸µå, ¸¶¿ì½º À̺¥Æ®¸¦ µî·Ï,
½Ã½ºÅÛÀº ÇØ´ç À©µµ¿ì¿¡ WM_INPUT¸Þ¼¼Áö¸¦ ´øÁ® »ç¿ëÀÚ·Î ºÎÅÍ Input À̺¥Æ®°¡ µé¾î¿Ô´ÂÁö¸¦ ¾Ë ¼ö ÀÖ´Ù.
RAWINPUTDEVICE rawInputDev[2];   
ZeroMemory(rawInputDev, sizeof(RAWINPUTDEVICE)*2);   
  
// Å°º¸µå RAWINPUTDEVICE ±¸Á¶Ã¼ ¼³Á¤   
rawInputDev[0].usUsagePage = 0x01;   
rawInputDev[0].usUsage = 0x06;   
rawInputDev[0].dwFlags = RIDEV_INPUTSINK;   
rawInputDev[0].hwndTarget = GetSafeHwnd();   
  
//¸¶¿ì½º RAWINPUTDEVICE ±¸Á¶Ã¼ ¼³Á¤   
rawInputDev[1].usUsagePage = 0x01;   
rawInputDev[1].usUsage = 0x02;   
rawInputDev[1].dwFlags = RIDEV_INPUTSINK;   
rawInputDev[1].hwndTarget = GetSafeHwnd();     
  
if(FALSE == RegisterRawInputDevices(rawInputDev, 2, sizeof(RAWINPUTDEVICE)))   
{   
        CString str;   
        str.Format(_T("RegisterRawInputDevices Error %d"), GetLastError());   
        MessageBox(str);   
}    
  
 LRESULT CRegisterRawInputDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)   
{   
     // TODO: Add your specialized code here and/or call the base class   
     if(message == WM_INPUT)   
     {   
           //¿©±â¼­ ¸¶¿ì½º/Å°º¸µå ÀÔ·Â ¸Þ½ÃÁö¸¦ È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.   
           // GetRawInputDevices ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ÀÔ·ÂµÈ Á¤º¸¸¦ ¾Ë ¼ö ÀÖ½À´Ï´Ù.   
     }   
     return CDialog::WindowProc(message, wParam, lParam);   
}  


    ¡Ý DEBUG ¸ðµå¿¡¼­¸¸ ½ÇÇà
#if defined( _DEBUG ) || defined( DEBUG )
sprintf(str,"x: %f, y: %f, z: %f",vPos.x,vPos.y,vPos.z);
MessageBox(NULL, str ,"Pick OK",MB_OK);
#endif

¢¹ VOID OutputDebugString( LPCTSTR lpOutputString ); // string to be displayed
WIn32 API Áß¿¡ MFCÀÇ TRACE¿Í °°Àº ±â´ÉÀ» ÇÏ´Â Debug ÇÔ¼ö·Î½á,
ÀÌÇÔ¼ö¸¦ »ç¿ëÇϽøé Debugâ¿¡ ¸ÞÁö½Ã¸¦ º¸³¾ ¼ö ÀÖ°í
±×¸®°í DebugView¶ó´Â À¯Æ¿¸®Æ¼¿¡¼­µµ È®ÀÎÇÒ ¼ö ÀÖ´Ù.(SysinternalÁ¦Ç°)
if (InitScene())
{
OutputDebugString(" Scene initialisation failed\n");
exit(5);
}

¢¹ cf.DXUTmisc.h
//--------------------------------------------------------------------------------------
// Debug printing support
// See dxerr.h for more debug printing support
//--------------------------------------------------------------------------------------
void DXUTOutputDebugStringW( LPCWSTR strMsg, ... );
void DXUTOutputDebugStringA( LPCSTR strMsg, ... );

¢¹ trace ¹üÀ§ ¼³Á¤
//--------------------------------------------------------------------------------------
// debug constants & macros
//--------------------------------------------------------------------------------------
#define TRACE_LEVEL 2 // 0 = no tracing, 1 = errors, 2 = major ops, 3 = minor operations

#if DEBUG && ISVERSION(DEVELOPMENT) && !ISVERSION(SERVER_VERSION)
# if( TRACE_LEVEL >= 1 )
# define TRACE1(fmt, ...) Trace(fmt, __VA_ARGS__)
# endif
# if( TRACE_LEVEL >= 2 )
# define TRACE2(fmt, ...) Trace(fmt, __VA_ARGS__)
# endif
# if( TRACE_LEVEL >= 3 )
# define TRACE3(fmt, ...) Trace(fmt, __VA_ARGS__)
# endif
#endif

#ifndef TRACE1
#define TRACE1(fmt, ...)
#endif

#ifndef TRACE2
#define TRACE2(fmt, ...)
#endif

#ifndef TRACE3
#define TRACE3(fmt, ...)
#endif



    ¡Ý Ŭ·¡½º »ó¼Ó½Ã Á¤Àû¿¬°á°ú µ¿Àû¿¬°á
Ŭ·¡½º »ó¼Ó½Ã ºÎ¸ð Ŭ·¡½º ÇÔ¼ö¿Í ÀÚ½Ä Å¬·¡½º ÇÔ¼öÀÇ »çÀÌÀÇ °ü°è¿¡¼­ ºÎ¸ð Ŭ·¡½º ÇÔ¼ö°¡ °¡»óÇÔ¼öÀÎÁö, ÀÏ¹Ý ÇÔ¼ö ÀÎÁö¿¡ µû¶ó
ÀÚ½Ä Å¬·¡½º¿¡¼­ ÇÔ¼ö¸¦ È£Ãâ ÇßÀ» ¶§ µ¿ÀÛ ¹æ½ÄÀÌ ´Þ¶óÁø´Ù.
1.Á¤Àû¿¬°á;
Ç×»ó ºÎ¸ðÀÇ Æ÷ÀÎÅÍ·Î ÇÔ¼ö¸¦ È£ÃâÇϸç,
¸¸ÀÏ ÀÚ½Ä Å¬·¡½º¿¡ Á¸ÀçÇÏ´Â ÇÔ¼ö¸¦ È£ÃâÇϱâ À§Çؼ­´Â (ÀÚ½ÄŬ·¡¼­*) ij½ºÆà ÇÑ´Ù.
2.µ¿Àû¿¬°á; virtual »ç¿ë
°¡»óÅ×À̺íÀÌ »ý¼ºµÇ¾î ºÎ¸ð°¡ ¾Æ´Ñ ÀÚ½ÄÀÇ Æ÷ÀÎÅÍ°¡ ¾ò¾îÁø´Ù.
¸¸ÀÏ ÀÚ½ÄÀÌ ¾Æ´Ñ ºÎ¸ð ÇÔ¼ö¸¦ È£ÃâÇϱâ À§Çؼ­´Â p2->ºÎ¸ðŬ·¡½º::ÇÔ¼ö(); ½ÄÀ¸·Î »ç¿ëÇÑ´Ù.

class person {
(virtual) void print(); // ---> ÇÔ¼öÀÇ ¿¬°á ¹æ½Ä °áÁ¤
};

class student : public person {
void print();
};

int main( ) {
person* p1 = new person();
p1->print();

person* p2 = new student();
((student*)p2)->print(); // ---> Á¤Àû¿¬°á¿¡¼­ ÀÚ½Ä Å¬·¡½ºÀÇ ÇÔ¼ö È£Ãâ
p2->person::print(); // ---> µ¿Àû¿¬°á¿¡¼­ ºÎ¸ð Ŭ·¡½ºÀÇ ÇÔ¼ö È£Ãâ
return 0;
}


    ¡Ý Ŭ·¡½º ¸â¹ö ÇÔ¼ö Æ÷ÀÎÅÍ
// ¹æ½Ä 1 ---------------------------------------------
class TestClass
{
public:
void TestFunc(int n)
{
printf("%d\n", n);
}
void RunFunction( void (TestClass::*Func)(int) )
{
(this->*Func)(6); //Ŭ·¡½º ¸â¹ö ÇÔ¼öÀÇ Æ÷ÀÎÅÍ´Â Ç×»ó ±× Ŭ·¡½ºÀÇ ÇÔ¼ö ¶ó´Â°ÍÀ» ÁöÁ¤ ÇØ¾ß ÇÑ´Ù.
}
};
// ¹æ½Ä 2 ---------------------------------------------
class Test
{
public:
static void (*p)(int);
public:
static void Print( int a )
{
printf("%d\n", a );
}
};
// void (Test::*p)(int) = &(Test::Print); // ¿¡·¯
void (*Test::p)(int) = Test::Print; // ½ÇÇà

int main(int argc, char* argv[])
{
printf("Hello World!\n");

TestClass ccc;
ccc.RunFunction(&TestClass::TestFunc);

Test a;
a.p(3);
Test::p(4);

return 0;
}
-1.Á¤È®È÷ (Test::*p)¿Í (*Test::p)´Â Â÷ÀÌ°¡ ÀÖ´Ù.
VC++¿¡¼­
(Test::*p)Çϸé ÄÄÆÄÀÏ·¯´Â ÀÌ°ÍÀ» __thiscall·Î ÀνÄÇÏÁö¸¸
(*Test::p)Çϸé __cdecl·Î ÀνÄÇؼ­ ¿À·ù°¡ ³ªÁö ¾Ê½À´Ï´Ù.
Á¤Àû ¸â¹öÇÔ¼ö´Â ±âº»ÀûÀ¸·Î __cdeclÀ̱⠶§¹®¿¡ ¹ß»ýÇÑ ¿À·ù´Â conversion context°¡ ¾ø´Ù´Â °É·Î ³ª¿Â´Ù.
±×¸®°í ¾îÂ÷ÇÇ Á¤Àû ¸â¹ö ÇÔ¼ö Æ÷ÀÎÅÍÀ̹ǷÎ
a.p(3)¸¦ Çϳª Test::p(3)¸¦ Çϳª ¾îÂ÷ÇÇ class-scopeÀ̱⠶§¹®¿¡ ³»ºÎ µ¿ÀÛÀº ¶È °°´Ù.
-2.¸â¹ö ÇÔ¼öÀÇ Æ÷ÀÎÅ͸¦ ÃëÇϱâ À§Çؼ± ÇØ´ç ¸â¹ö ÇÔ¼ö¸¦ static Å°¿öµå¸¦ »ç¿ëÇؼ­ ¼±¾ðÇÑ´Ù.
Ŭ·¡½º´Â ·±Å¸ÀÓÀ¸·Î »ý¼ºµÇ±â ¶§¹®¿¡, ÀÏ¹Ý ¸â¹ö ÇÔ¼öÀÇ Æ÷ÀÎÅÍ´Â Äڵ尡 ½ÇÇàµÇ±â À§ÇØ ½ºÅÿ¡ º¹»çµÈ ¼ø°£ À¯È¿ÇÑ Æ÷ÀÎÅÍ°¡ ¾Æ´Ï´Ù.


    ¡Ý Ŭ·¡½º - ÇÁ·»µå Ŭ·¡½º
µÎ Ŭ·¡½º°¡ ¾ÆÁÖ ¹ÐÁ¢ÇÑ °ü·ÃÀÌ ÀÖ°í ¼­·Î ¼û°ÜÁø ¸â¹ö¸¦ ÀÚÀ¯·Ó°Ô Àоî¾ß ÇÏ´Â »óȲÀ̶ó¸é
Ŭ·¡½º¸¦ Åë°·Î ÇÁ·»µå·Î ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. Ŭ·¡½º ¼±¾ð¹®³»¿¡ ÇÁ·»µå·Î ÁöÁ¤ÇÏ°í ½ÍÀº Ŭ·¡½ºÀÇ À̸§À» ¹àÈ÷¸é µÈ´Ù. ´ÙÀ½ ¿¹´Â Any Ŭ·¡½º¸¦ Some Ŭ·¡½ºÀÇ ÇÁ·»µå·Î ÁöÁ¤ÇÏ´Â °ÍÀÌ´Ù.
class Some {
friend class Any;
....
};
Any°¡ SomeÀÇ ÇÁ·»µå·Î ÁöÁ¤µÇ¾úÀ¸¹Ç·Î
AnyÀÇ ¸ðµç ¸â¹ö ÇÔ¼öµéÀº SomeÀÇ ¸ðµç ¸â¹ö¸¦ ¸¶À½´ë·Î ¾×¼¼½ºÇÒ ¼ö ÀÖ´Ù. µÎ Ŭ·¡½º°¡ ÇùÁ¶ÀûÀ¸·Î µ¿ÀÛÇØ¾ß ÇѴٰųª »óÈ£ Á¾¼ÓÀûÀÎ °ü°è¿¡ ÀÖÀ» ¶§ ÇÁ·»µå·Î ÁöÁ¤Çϸé Æí¸®ÇÏ´Ù.

¿¹)
#include <Turboc.h>
class Time {
friend class Date;
private:
int hour,min,sec;
public:
Time(int h,int m,int s) { hour=h;min=m;sec=s; }
};

class Date {
private:
int year,month,day;
public:
Date(int y,int m,int d) { year=y;month=m;day=d; }
void OutToday(Time &t) {
printf("¿À´ÃÀº %d³â %d¿ù %dÀÏÀ̸ç Áö±Ý ½Ã°£Àº %d:%d:%dÀÔ´Ï´Ù.\n",
year,month,day,t.hour,t.min,t.sec);
}
};

void main()
{
Date D(2005,01,02);
Time T(12,34,56);
D.OutToday(T);
}

OutToday ÇÔ¼ö´Â Date Ŭ·¡½ºÀÇ ¸â¹ö ÇÔ¼ö·Î ¼±¾ðµÇ¾úÁö¸¸ Date°¡ TimeÀÇ ÇÁ·»µå Ŭ·¡½º·Î ÁöÁ¤µÇ¾î ÀÖÀ¸¹Ç·Î
OutToday´Â Time °´Ã¼ÀÇ ¸ðµç ¸â¹ö¸¦ ÀÐÀ» ¼ö ÀÖ´Ù. ½ÇÇà °á°ú´Â ¾ÕÀÇ ¿¹Á¦¿Í µ¿ÀÏÇÏ´Ù. °³³äÀûÀ¸·Î ÀÌÇØÇϱ⠽¬¿î °£´ÜÇÑ ¿¹Á¦¸¦ º¸¿´´Âµ¥ ½ÇÁ¦·Î ÇÁ·»µå Ŭ·¡½º ÁöÁ¤ÀÌ ²À ÇÊ¿äÇÑ ¿¹´Â ´Ù¼Ò Å©°í º¹ÀâÇÏ´Ù. MFC ¶óÀ̺귯¸®ÀÇ °æ¿ì ´ÙÀ½°ú °°Àº ÇÁ·»µå Ŭ·¡½ºÀÇ ¿¹°¡ ¸¹ÀÌ Á¸ÀçÇÑ´Ù.
¢º CDocument°¡ CViewÀÇ ÇÁ·»µå
¢º CTimeÀÌ CTimeSpanÀÇ ÇÁ·»µå
¢º CToolBar°¡ CToolTipCtrlÀÇ ÇÁ·»µå
¢º CPropertySheet°¡ CPropertyPageÀÇ ÇÁ·»µå
¸ðµÎ ¾ÆÁÖ ¹ÐÁ¢ÇÑ °ü°è¿¡ Àִ Ŭ·¡½ºµéÀε¥ MFCÀÇ ±¸Á¶¸¦ °øºÎÇØ º¸¸é
ÀÌ Å¬·¡½ºµéÀÌ ¿Ö ÇÁ·»µå¿©¾ß ÇÏ´ÂÁö ¾Ë°Ô µÉ °ÍÀÌ´Ù. CView¿Í CDocument´Â ÇϳªÀÇ ½Çü¿¡ ´ëÇØ °¢°¢ ¿ÜºÎ¿Í ³»ºÎ¸¦ ´Ù·ç´Â °ü·ÃÀִ Ŭ·¡½ºÀÌ´Ù. CView´Â ÀÚ½ÅÀÌ È­¸é¿¡ Ãâ·ÂÇÒ µ¥ÀÌÅ͸¦ Àбâ À§ÇØ CDocumentÀÇ ¸â¹ö¸¦ ¸¶À½´ë·Î ÀÐÀ» ¼ö ÀÖ¾î¾ß Çϸç CToolTipCtrl Ŭ·¡½º´Â ÅøÆÁÀ» º¸¿©ÁÙ ¹öÆ°À̳ª ¿µ¿ªÀ» ±¸Çϱâ À§ÇØ CToolBarÀÇ ¸â¹ö¸¦ ¾×¼¼½ºÇØ¾ß ÇÑ´Ù.
(Ãâó; http://www.winapi.co.kr/clec/cpp3/27-2-2.htm - È¥ÀÚ ¿¬±¸ÇÏ´Â C-C++ by WinApi)


    ¡Ý C ¼ö¾÷³»¿ë

¼ö¾÷ ³»¿ë #

20030422
-.·ÎÁ÷»ó¿¡ Á÷Á¢ÀûÀÎ »ó¼öÀÇ ´ëÀÔÀº ÁöÇâ
-.break, continue ÀÇ »ç¿ë»ó Â÷ÀÌÁ¡
20030423 - ¹è¿­
-.char a = getch();
-.Type(Çü)¿¡ ´ëÇÑ Á¤ÀÇ
-.¹è¿­Àº 0ºÎÅÍ ½ÃÀÛ
char a10; ¹®ÀÚ ¹è¿­Àº »ó¼ö·Î Ãë±ÞµÇ±â ¶§¹®¿¡ 1:1·Î ´ëÀÀÇÔ
--> ¹®ÀÚ¿­À» ºñ±³ÇÒ ¶§´Â °¢°¢ÀÇ ¿ä¼Ò¸¦ ÀüºÎ È®ÀÎ
printf("%s", a); ¹®ÀÚ¿­ Ãâ·Â
-.Æ÷ÀÎÅÍ; ¸Þ¸ð¸®¿¡ ´ëÇÑ ±âº»ÀûÀÎ ÀÌÇØ ÇÊ¿ä(4¹ÙÀÌÆ®)

p=malloc(sizeof(char)*10); /* µ¿ÀûÀ¸·Î ¸Þ¸ð¸®¸¦ ÇÒ´ç */
memset(p,'&',sizeof(char)*10);
p[0]='a';
p[1]='b';
p[8]='q';
p[9]='\0';
printf("%s = %d \n",p,sizeof(p));
free(p);

20030424 - Æ÷ÀÎÅÍ
-.Æ÷ÀÎÅÍ´Â ¹øÁö¸¦ °¡¸£Ä¡´Â ¼ýÀÚ°³³äÀ̱⠶§¹®¿¡ ¿¬»êÀÌ °¡´É
cf. Àμö¸¦ °¡¸£Ä¥ ¶§´Â ¹Ýº¹ÀÚ °³³äÀÌ ÀÖ´Ù.
int *a;
int b=10;
a= &b; &Àº ÁÖ¼Ò ¿¬»êÀÚ
int *a;
20030425 - ÇÔ¼ö
-.°¢ ±â´ÉÀ» ÇÔ¼öÈ­½ÃÄѼ­ ºÐ»ê±¸Á¶·Î Á¤ÀÇ --> ÇÊ¿äÇÒ ¶§ ±â´Éº°·Î È£Ãâ
-.ÇÔ¼ö°¡ ³¡³ª¸é ÇÔ¼öÀÇ °¡Àμö(Áö¿ªº¯¼ö)´Â »ç¶óÁö°í,
Àü¿ªº¯¼ö´Â ÇÁ·Î±×·¥ Àüü¿¡ ¿µÇâÀ» ¹ÌÄ¡±â ¶§¹®¿¡ °¡´ÉÇÑ ÃÖ¼ÒÇѸ¸ »ç¿ë
-.scanf()·Î ¹®ÀÚ¸¦ ÀÔ·Â ¹ÞÀ» ¶§´Â ¹®ÀÚ°¡ Â÷ÁöÇÒ ¿µ¿ªÀÇ ¸Þ¸ð¸®¸¦ ¹Ì¸® Àâ´Â´Ù.
(¹è¿­À̳ª malloc µî)
20030428 - ±¸Á¶Ã¼; ±¸Á¶Ã¼ ³»¿¡ ´Ù¸¥ ±¸Á¶Ã¼ ¼±¾ðµµ °¡´É
-.µ¥ÀÌŸ 󸮸¦ À§ÇØ DBÀÇ Çʵå¿Í ·¹ÄÚµå °³³äÀ» »ç¿ë
-.±¸Á¶Ã¼ ¼±¾ð ºÎºÐ ³»¿¡¼­ ¹Ù·Î ÃʱâÈ­ÇÒ ¼ö ¾ø´Ù
-.structÀÇ pointer³»ÀÇ ±¸¼ºÀÎÀÚ(Çʵå)¸¦ ÁöÁ¤Çϱâ À§Çؼ± (->)Çʵå¸í Çü½Ä
-.ÇÑ °³ÀÇ ÆÄÀÏÀ» »ç¿ëÇÒ °æ¿ì,
¿­°í (ÆÄÀÏ ÀÔ·Â ¶Ç´Â ÀúÀå) ´Ý°í > ¿­°í (ÆÄÀÏ ÀÔ·Â ¶Ç´Â ÀúÀå) ´Ý°í ...
20030429
-.head ÆÄÀÏ·Î »ç¿ëÀÚ Á¤ÀÇ ºÎºÐ µû·Î ÀúÀå
-.#defineÀ¸·Î Á¤ÀÇµÈ »ó¼öÀ̸§Àº ÀϹÝÀûÀ¸·Î ¸ðµÎ ´ë¹®ÀÚ·Î »ç¿ë



{_r} ¸Þ¸ðÀåÀ¸·Î °¡±â

November, 2024
 12
3456789
10111213141516
17181920212223
24252627282930

"¹Ùº¸¾ß!"

Ã¥°¥ÇÇ_book_InTheMind'sEye
WikiSeed
HelpIndex
Ã¥°¥ÇÇ_3DGameProgramming
last modified 2014-07-10 14:45:19
°íÄ¡±â|ã±â|ÂÊ Áö¿ì±â|ºñ½ÁÇÑ ÂÊ Valid XHTML 1.0! Valid CSS! powerd by MoniWiki
0.4651 sec