여자친구가 보면 좋아할 사랑해, I Love You와 같은 사랑 메시지를 화면에 막 뿌려주는 심플한 프로그램입니다. 아래 소스코드를 수정해서 사용하시면 됩니다. 자료는 하단에 첨부파일 클릭하시면 있습니다.
#include <windows.h>
#pragma comment(linker,"/subsystem:windows")
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
HWND hWndMain;
LPCTSTR lpszClass=TEXT("Class");
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst=hInstance;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClass;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd=CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,(HMENU)NULL,hInstance,NULL);
ShowWindow(hWnd,SW_HIDE);
while (GetMessage(&Message,NULL,0,0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return (int)Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
// HWND hWin;
HFONT hFontEdit;
HFONT oldFont;
static char *szName[5]={"사랑해~","I LOVE YOU","그대가 있어 행복합니다","♡","Loving you"};
static int i=0;
int name;
int Wx;
int Wy;
switch (iMessage) {
case WM_CREATE:
hWndMain=hWnd;
SetTimer(hWnd,1,50,NULL);
return 0;
case WM_TIMER:
if (i==0)
{
i++;
MessageBox(hWnd,"그만할까?","끝내기",MB_OK);
PostQuitMessage(0);
}
Wx=GetSystemMetrics(SM_CXSCREEN);
Wy=GetSystemMetrics(SM_CYSCREEN);
hWnd = GetDesktopWindow();//바탕화면의 윈도우
hdc = GetWindowDC(hWnd);//바탕화면에 그릴 준비
hFontEdit=CreateFont(rand()%50,0,rand()%1800,0,0,0,0,0,DEFAULT_CHARSET,0,0,0,0,TEXT("고딕"));
oldFont=(HFONT)SelectObject(hdc,hFontEdit);
SetTextColor(hdc,RGB(rand()%250+50,rand()%250+50,rand()%250+50));
SetBkMode(hdc,TRANSPARENT);
name=rand()%5;
TextOut(hdc,rand()%Wx,rand()%Wy,szName[name],strlen(szName[name]));
SelectObject(hdc,oldFont);
DeleteObject(hFontEdit);
ReleaseDC(hWnd, hdc);
DeleteObject(hdc);
return 0;
case WM_PAINT:
hdc=BeginPaint(hWnd, &ps);
// TextOut(hdc,rand()%100,rand()%100,"11",2);
EndPaint(hWnd, &ps);
return 0;
case WM_DESTROY:
KillTimer(hWnd,1);
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
'IT 자격증 > 코딩능력마스터 및 C언어' 카테고리의 다른 글
C로 배우는 쉬운 자료구조 9장 연습문제 (0) | 2015.05.18 |
---|---|
제1501회 컴퓨터프로그래머 2급 기출문제 (0) | 2015.03.09 |
C로 배우는 쉬운 자료구조 1장~8장 연습문제 (0) | 2012.04.08 |
코딩 잘하는 10가지 방법 (0) | 2011.04.18 |
Microsoft Visual Studio 2010 단축키 포스터 4종 (0) | 2011.02.27 |