요즘 다 Win32 API와 MSVC C Runtime Library만 불러다쓰니 어느게 표준 함수인지 모르겠다.
그래서, 표준함수를 찾아 보았다.
표준 함수 목록
------------------------------------------------------------------------------------ C89 ------------------------------------------------------------------------------------ assert.h assert() ctype.h isalnum() isalpha() iscntrl() isdigit() isgraph() islower() isprint() ispunct() isspace() isupper() isxdigit() tolower() toupper() locale.h localeconv() setlocale() math.h acos() asin() atan() atan2() ceil() cos() cosh() exp() fabs() floor() fmod() frexp() ldexp() log() log10() modf() pow() sin() sinh() sqrt() tan() setjmp.h longjmp() setjmp() signal.h raise() signal() stdarg.h va_arg() va_end() va_start() stddef.h offsetof() stdio.h clearerr() fclose() feof() ferror() fflush() fgetc() fgetpos() fgets() fopen() fprintf() fputc() fputs() fread() freopen() fscanf() fseek() fsetpos() fwrite() getc() getchar() gets() main() perror() printf() putc() putchar() puts() remove() rename() rewind() scanf() setbuf() setvbuf() sprintf() sscanf() tmpfile() tmpnam() ungetc() vfprintf() vprintf() vsprintf() stdlib.h abort() abs() atexit() atof() atoi() atol() bsearch() calloc() div() exit() free() ftell() getenv() labs() ldiv() malloc() mblen() mbstowcs() mbtowc() qsort() rand() realloc() sizeof() srand() strtod() strtol() strtoul() system() wctomb() wcstombs() string.h memchr() memcmp() memcpy() memmove() memset() strcat() strchr() strcmp() strcoll() strcpy() strcspn() strerror() strlen() strncat() strncmp() strncpy() strpbrk() strrchr() strspn() strstr() strtok() strxfrm() time.h asctime() clock() ctime() difftime() gmtime() localtime() mktime() strftime() ------------------------------------------------------------------------------------ C99 ------------------------------------------------------------------------------------ complex.h cabs() cabsf() cabsl() cacos() cacosf() cacosl() cacosh() cacoshf() cacoshl() carg() cargf() cargl() casin() casinf() casinl() casinh() casinhf() casinhl() catan() catanf() catanl() catanh() catanhf() catanhl() conj() conjf() conjl() ccos() ccosf() ccosl() ccosh() ccoshf() ccoshl() cproj() cprojf() cprojl() cexp() cexpf() cexpl() cimag() cimagf() cimagl() clog() clogf() clogl() cpow() cpowf() cpowl() creal() crealf() creall() csin() csinf() csinl() csinh() csinhf() csinhl() csqrt() csqrtf() csqrtl() ctan() ctanf() ctanl() ctanh() ctanhf() ctanhl() ctype.h isblank() fenv.h feclearexcept() feholdexcept() fegetenv() fegetexceptflag() fegetround() feraiseexcept() fesetenv() fesetexceptflag() fesetround() fetestexcept() feupdateenv() inttypes.h imaxabs() imaxdiv() strtoimax() strtoumax() wcstoimax() wcstoumax() math.h acosf() acosl() acosh() acoshf() acoshl() asinf() asinl() asinh() asinhf() asinhl() atanf() atanl() atanh() atanhf() atanhl() atan2f() atan2l() cbrt() cbrtf() cbrtl() ceilf() ceill() cosf() cosl() coshf() coshl() copysign() copysignf() copysignl() erf() erff() erfl() erfc() erfcf() erfcl() expf() expl() exp2() exp2f() exp2l() expm1() expm1f() expm1l() fabsf() fabsl() floorf() floorl() fdim() fdimf() fdiml() fma() fmaf() fmal() fmax() fmaxf() fmaxl() fmin() fminf() fminl() fmodf() fmodl() frexpf() frexpl() hypot() hypotf() hypotl() ilogb() ilogbf() ilogbl() ldexpf() ldexpl() lgamma() lgammaf() lgammal() llrint() llrintf() llrintl() llround() llroundf() llroundl() logf() logl() logb() logbf() logbl() log10f() log10l() logp1() logp1f() logp1l() log2() log2f() log2l() lrint() lrintf() lrintl() lround() lroundf() lroundl() modff() modfl() nan() nanf() nanl() nearbyint() nearbyintf() nearbyintl() nextafter() nextafterf() nextafterl() nexttoward() nexttowardf() nexttowardl() powf() powl() remainder() remainderf() remainderl() remquo() remquof() remquol() rint() rintf() rintl() round() roundf() roundl() scalbln() scalblnf() scalblnl() scalbn() scalbnf() scalbnl() sinf() sinl() sinhf() sinhl() sqrtf() sqrtl() tanf() tanl() tanhf() tanhl() tgamma() tgammaf() tgammal() trunc() truncf() truncl() stdarg.h va_copy() stdio.h fgetpos() fgets() fopen() fprintf() fputs() fread() freopen() fscanf() fwrite() printf() scanf() setbuf() setvbuf() snprintf() sprintf() sscanf() vfprintf() vfscanf() vprintf() vscanf() vsnprintf() vsprintf() vsscanf() stdlib.h atoll() _Exit() llabs() lldiv() mbstowcs() mbtowc() strtod() strtof() strtol() strtold() strtoll() strtoul() strtoull() wcstombs() string.h memcpy() strcat() strcpy() strncat() strncpy() strtok() strxfrm() time.h mkxtime() strftime() strfxtime() zonetime() wchar.h btowc() fgetwc() fgetws() fputwc()fputws() fwide() fwprintf() fwscanf() getwc() getwchar() mbrlen() mbrtowc() mbsinit() mbsrtowcs() putwc() putwchar() swprintf() swscanf() ungetwc() vfwprintf() vfwscanf() vswprintf() vswscanf() vwprintf() vwscanf() wcrtomb() wcsftime() wcsrtombs() wcstod() wcstof() wcstol() wcstold() wcstoll() wcstoul() wcstoull() wcscat() wcschr() wcscmp() wcscoll() wcscpy() wcscspn() wcslen() wcsncat() wcsncmp() wcsncpy() wcspbrk() wcsrchr() wcsspn() wcsstr() wcstok() wcsxfrm() wctob() wmemchr() wmemcmp() wmemcpy() wmemmove() wmemset() wprintf() wscanf() wctype.h iswalnum() iswalpha() iswblank() iswcntrl() iswctype() iswdigit() iswgraph() iswlower() iswprint() iswpunct() iswspace() iswupper() iswxdigit() towctrans() towlower() towupper() wctrans() wctype()
참고자료:
http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html
http://www.esnips.com/doc/46e78cce-ef6e-47c4-b828-82fa1f88ea81/A-Dictionary-of-ANSI-Standard-C-Function-Definitions
Child Window 순회 함수...
그런데... MS가 만든게 있었네 =_=;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
CWindow wnd (hwnd);
wnd.SetFont ((HFONT)lParam);
return TRUE;
}
BOOL myEnumChildWindows (HWND hParent, WNDENUMPROC lpEnumProc, LPARAM lParam)
{
HWND hEnum;
BOOL bContinue = TRUE;
TCHAR szCaption[256];
hEnum = ::GetWindow (hParent, GW_CHILD);
while (NULL!=hEnum && TRUE==bContinue)
{
::GetWindowText (hEnum, szCaption, 256);
ATLTRACE (_T("Child=%08x,%s \r\n"), hEnum, szCaption);
bContinue = lpEnumProc (hEnum, lParam);
if (NULL!=::GetWindow (hEnum, GW_CHILD))
{
if (TRUE==bContinue)
bContinue=EnumChildWindows (hEnum, lpEnumProc, lParam);
}
hEnum = ::GetNextWindow (hEnum, GW_HWNDNEXT);
}
return bContinue;
}
wince에서는 CreateRoundRectRgn()함수가 지원이 안되서 구글 힘을 빌려 만들어 봤습니다. 원본소스는
http://www.ocera.org/archive/upvlc/public/components/sa-rtl/sa-rtl-2.2-pre2/mw/mwin/winrgn.c
에 있는 일부분을 참고해서 만들었습니다.
// TestCEGraphView.h : interface of the CTestCEGraphView class
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <vector>
HRGN CreateRoundRectRgn (int left, int top, int right, int bottom, int ellipse_width, int ellipse_height )
{
HRGN hrgn = 0;
int asq, bsq, d, xd, yd;
RECT rect;
std::vector<RECT> rects;
if (ellipse_width == 0 || ellipse_height == 0)
return CreateRectRgn( left, top, right, bottom );
/* Make the dimensions sensible */
if (left > right ) { int tmp = left; left = right; right = tmp; }
if (top > bottom) { int tmp = top; top = bottom; bottom = tmp; }
ellipse_width = abs(ellipse_width);
ellipse_height = abs(ellipse_height);
/* Check parameters */
if (ellipse_width > right-left) ellipse_width = right-left;
if (ellipse_height > bottom-top) ellipse_height = bottom-top;
/* Ellipse algorithm, based on an article by K. Porter */
/* in DDJ Graphics Programming Column, 8/89 */
asq = ellipse_width * ellipse_width / 4; /* a^2 */
bsq = ellipse_height * ellipse_height / 4; /* b^2 */
if (asq == 0) asq = 1;
if (bsq == 0) bsq = 1;
d = bsq - asq * ellipse_height / 2 + asq / 4; /* b^2 - a^2b + a^2/4 */
xd = 0;
yd = asq * ellipse_height; /* 2a^2b */
rect.left = left + ellipse_width / 2;
rect.right = right - ellipse_width / 2;
rects.reserve (ellipse_height);
/* Loop to draw first half of quadrant */
while (xd < yd)
{
/* if nearest pixel is toward the center */
if (d > 0)
{
/* move toward center */
rect.top = top++;
rect.bottom = rect.top + 1;
rects.push_back (rect);
rect.top = --bottom;
rect.bottom = rect.top + 1;
rects.push_back (rect);
yd -= 2*asq;
d -= yd;
}
/* next horiz point */
rect.left --;
rect.right++;
xd += 2*bsq;
d += bsq + xd;
}
/* Loop to draw second half of quadrant */
d += (3 * (asq-bsq) / 2 - (xd+yd)) / 2;
while (yd >= 0)
{
/* next vertical point */
rect.top = top++;
rect.bottom = rect.top + 1;
rects.push_back (rect);
rect.top = --bottom;
rect.bottom = rect.top + 1;
rects.push_back (rect);
/* if nearest pixel is outside ellipse */
if (d < 0)
{
/* move away from center */
rect.left --;
rect.right++;
xd += 2*bsq;
d += xd;
}
yd -= 2*asq;
d += asq - yd;
}
/* Add the inside rectangle */
if (top <= bottom)
{
rect.top = top;
rect.bottom = bottom;
//rects.push_back (rect);
rects.insert (rects.begin(), rect);
}
static int count=0;
std::vector<RECT>::iterator i;
for (i=rects.begin(); i!=rects.end(); i++)
{
ATLTRACE (_T("[%d]%3d,%3d:%3d,%3d \r\n"), ++count,
(*i).top,
(*i).bottom,
(*i).left,
(*i).right
);
}
if (rects.empty())
return NULL;
RGNDATAHEADER* pRgnData;
UINT RgnDataSize;
UINT RgnRectCount;
LPRECT pRect;
RgnRectCount = rects.size();
RgnDataSize = sizeof(RGNDATAHEADER) + sizeof(RECT)*RgnRectCount;
pRgnData = (RGNDATAHEADER*)new BYTE[ RgnDataSize ];
if (pRgnData==NULL)
return NULL;
pRgnData->dwSize = sizeof(RGNDATAHEADER);
pRgnData->iType = RDH_RECTANGLES;
pRgnData->nCount = RgnRectCount;
pRgnData->rcBound.left = 0;
pRgnData->rcBound.top = 0;
pRgnData->rcBound.right = 0;
pRgnData->rcBound.bottom = 0;
pRect = (LPRECT) ( (LPBYTE) pRgnData + sizeof(RGNDATAHEADER) );
memcpy (pRect, &*rects.begin(), RgnRectCount*sizeof(RECT));
hrgn = ExtCreateRegion(NULL, RgnDataSize, (LPRGNDATA)pRgnData);
delete pRgnData;
return hrgn;
}
class CTestCEGraphView : public CWindowImpl<CTestCEGraphView>
{
public:
DECLARE_WND_CLASS(NULL)
BOOL PreTranslateMessage(MSG* pMsg)
{
pMsg;
return FALSE;
}
BEGIN_MSG_MAP(CTestCEGraphView)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
END_MSG_MAP()
// Handler prototypes (uncomment arguments if needed):
// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CPaintDC dc(m_hWnd);
CBrush brush[3];
brush[0].CreateSolidBrush (RGB(0xff,0x00,0x00));
brush[1].CreateSolidBrush (RGB(0x00,0xff,0x00));
brush[2].CreateSolidBrush (RGB(0x00,0x00,0xff));
HRGN hrgn;
hrgn = CreateRoundRectRgn (10,10,200,100,200,200);
dc.FillRgn (hrgn , brush[0]);
DeleteObject (hrgn);
hrgn = CreateRoundRectRgn (10,150,200,250,20,50);
dc.FillRgn (hrgn , brush[1]);
DeleteObject (hrgn);
hrgn = CreateRoundRectRgn (10,300,200,400,20,20);
dc.FillRgn (hrgn , brush[2]);
DeleteObject (hrgn);
return 0;
}
};
에 있는걸 참고해서 문제가 있었던 object1.prop = object2.prop의 문제를 수정하였으나
그 이외에도 문제가 많다.
#include <stdio.h> #include <atlbase.h> #include <iostream> ///////////////////////////////////////////////////////////////////////////// // // Interface of the CProperty<TContainer,TValue> class // Ref=http://www.codeproject.com/KB/cpp/cppproperties.aspx // ///////////////////////////////////////////////////////////////////////////// template<typename TContainer, typename TValue> class CProperty { public: typedef TValue (TContainer::*SETPROC)(TValue value); typedef TValue (TContainer::*GETPROC)(void) const; private: TValue m_Value; SETPROC m_pSetProc; GETPROC m_pGetProc; TContainer* m_pContainer; public: CProperty() : m_pSetProc (NULL), m_pGetProc (NULL), m_pContainer(NULL) { } CProperty(const CProperty& o) { m_Value = o.Get(); } public: void Bind (TContainer* container, GETPROC getproc, SETPROC setproc) { m_pContainer = container; m_pGetProc = getproc; m_pSetProc = setproc; } CProperty<TContainer,TValue> operator = (const CProperty& rhs) { Set(rhs.Get()); return *this; } TValue Get (void) const { ATLASSERT(m_pContainer != NULL); ATLASSERT(m_pGetProc != NULL); return (m_pContainer->*m_pGetProc)(); } TValue Set (const TValue& value) { ATLASSERT(m_pContainer != NULL); ATLASSERT(m_pSetProc != NULL); return (m_pContainer->*m_pSetProc)(value); } operator TValue (void) const { return Get (); } TValue operator = (const TValue& value) { return Set (value); } }; ///////////////////////////////////////////////////////////////////////////// // // Interface of the CProperties class // ///////////////////////////////////////////////////////////////////////////// class CProperties { private: int m_Count; public: CProperty<CProperties,int> Count; public: CProperties () : m_Count(0) { Count.Bind (this, &CProperties::get_Count, &CProperties::set_Count); } public: int get_Count (void) const { printf ("\t\t%08x::get_Count()=%d\r\n", this, m_Count); return m_Count; } int set_Count (int n) { m_Count = n; printf ("\t\t%08x::set_Count(%d)\r\n", this, m_Count); return m_Count; } }; ///////////////////////////////////////////////////////////////////////////// // // Test // ///////////////////////////////////////////////////////////////////////////// static int Test (void) { CProperties prop; prop.Count = 100; return prop.Count; } ///////////////////////////////////////////////////////////////////////////// // // Startup // ///////////////////////////////////////////////////////////////////////////// int _tmain(int argc, _TCHAR* argv[]) { CProperties Properties1, Properties2; printf ("\t\tProperties1=%08x\r\n", &Properties1); printf ("\t\tProperties2=%08x\r\n", &Properties2); printf ("-------------------------------------------------------------\r\n"); printf ("Test()=%d\r\n", Test()); printf ("-------------------------------------------------------------\r\n"); Properties1.Count = 200; Properties2.Count = Properties1.Count; Properties1.Count = 100; std::cout << "Properties1.Count=" <<Properties1.Count << std::endl; std::cout << "Properties2.Count=" <<Properties2.Count << std::endl; printf ("-------------------------------------------------------------\r\n"); int n=Properties2.Count; printf ("printf() n =%d\r\n",n); printf ("printf() cast =%d\r\n",(int)Properties2.Count); printf ("printf() nocast=%d\r\n",Properties2.Count); // 방법없음 return 0; }