티스토리 뷰
//UTF-8 -> UNICODE -> CP949
void strcpy_UTF8(char *buf,char *s)//max=1024
{
if(buf)if(s)
{
wchar_t bufw[1024];
MultiByteToWideChar(CP_UTF8,0,s, -1,bufw,1024);
WideCharToMultiByte(CP_ACP,0,bufw, -1,buf,1024,NULL,NULL);
}
}
void myprintf(char *fmt,...)
{
char buf[4096]; // 버퍼 크기는 필요에 따라 조절 가능
va_list args;
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
OutputDebugString(buf);
Sleep(10);
}
void strcpy(wchar_t *buf,char *s)
{
int nLen = MultiByteToWideChar(CP_ACP,
0,
s, -1,
NULL,
NULL);
MultiByteToWideChar(CP_ACP,
0,
s, -1,
buf,
nLen);
}
void strcpy(char *buf,wchar_t *s)//max=1024
{
if(buf)if(s)
{
WideCharToMultiByte(CP_ACP,
0,
s, -1,
buf,1024,
NULL,
NULL);
}
}
void strcat(wchar_t *buf,char *s)
{
if(buf)if(s)
{
while(*buf)buf++;
int nLen = MultiByteToWideChar(CP_ACP,
0,
s, -1,
NULL,
NULL);
MultiByteToWideChar(CP_ACP,
0,
s, -1,
buf,
nLen);
}
}
void strcat(char *buf,wchar_t *s)//max=1024
{
if(buf)if(s)
{
WideCharToMultiByte(CP_ACP,
0,
s, -1,
buf,1024,
NULL,
NULL);
}
}
void GUID_to_str(GUID *a, char *buf)
{
sprintf(buf, "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
a->Data1, a->Data2, a->Data3,
a->Data4[0], a->Data4[1], a->Data4[2], a->Data4[3],
a->Data4[4], a->Data4[5], a->Data4[6], a->Data4[7]);
}
//컨트롤의 위치는 이동하지 않고 너비와 높이만 부모 윈도우의 클라이언트 크기에 맞춘다.
BOOL ControlWindow_FitSize_to_ParentWindow_DoseNotMove(HWND hWnd_Control,HWND hWnd_Parent)
{
RECT r;
WINDOWPLACEMENT wp;
if(hWnd_Control)
{
if(::GetClientRect(hWnd_Parent,&r))
{
wp.length=sizeof(wp);
if(::GetWindowPlacement(hWnd_Control,&wp))
{
return ::MoveWindow(hWnd_Control,wp.rcNormalPosition.left,wp.rcNormalPosition.top,
r.right-wp.rcNormalPosition.left,r.bottom-wp.rcNormalPosition.top,TRUE);
}
}
}
return FALSE;
}
char Log_buf[1024*4];
void Log_puts(char *s)
{
if(strcmp(Log_buf,s))
{
::SetWindowText(hwnd_IDC_EDIT1,s);
strcpy(Log_buf,s);
myprintf(s);
Beep(1000,100);
}
}
'C언어' 카테고리의 다른 글
애플은 왜 Objective-C를 버리는가? Objective-C 장점, 단점, 앞으로 전망 (0) | 2024.03.17 |
---|---|
16bit FFT (2) | 2024.03.16 |
uSD, USB 쓰기 속도 (0) | 2024.03.02 |
우분투에서 open()함수와 fopen()함수의 성능차이, 메모리 사용량은 얼마나 차이가 있나? (1) | 2024.02.24 |
c코드에서 문자열과 함수명에 숫자가 들어 있는데, 이 숫자만 바꾸어서 여러개의 코드를 작성하는 매크로, C언어 매크로 장단점 (0) | 2024.02.18 |