네이버에 검색해보니 콘솔로 해서 그렇다길래 내가실수했나 하고 몇번다시해봤는데 ㅠㅠ
분명히 콘솔로 안열고 윈 32어플리케이션으로 새프로젝트생성하고 파일추가해서 열었는데 자꾸 에러가 떠요
링킹에서 에러가 뜨는데 에러 내용은
Ok.obj : error LNK2001: unresolved external symbol _Setpixel
Debug/Ok.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
후..뭐가 잘못된건지 ㅠㅠ 단순한 그래프 그리는 거구요.. 함수 내용은
#include <windows.h>
int Job(HWND hwnd); //my Job functio(금지어라 N뺌)
int cxChar,cyChar,cxCaps, cxClient,cyClient; //char size, client size.
char szMessage[256];
//====================================================================================================//
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); //Window procedure
/////////////////////////////////////////////////////////////////////////////////////////////////////////
char szAppName[] = "WinBasic";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass ;
if(!hPrevInstance) {
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); //GetStockObject(GRAY_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
RegisterClass (&wndclass) ;
}
hwnd = CreateWindow(szAppName, "--WinBasic--", //Make Window
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow); //Show Window frame
UpdateWindow(hwnd); //fill Window
SendMessage(hwnd, WM_COMMAND, 1, 0); //generate WM_COMMAND for start core routine.
while(GetMessage(&msg, NULL, 0, 0)) { //Message Loop
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
return msg.wParam ;
}//WinMain()
////////////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int i,j, x,y;
HDC hdc;
PAINTSTRUCT ps;
TEXTMETRIC tm;
switch(message) {
case WM_CREATE: //=generated by CreateWindow()
//----get system char font size(cxChar,cyChar)
hdc = GetDC (hwnd) ;
GetTextMetrics (hdc, &tm) ; //현재 설정되어 있는 문자폰트 정보 얻음.
cxChar = tm.tmAveCharWidth ;
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2)*cxChar/2 ; //char average width
cyChar = tm.tmHeight + tm.tmExternalLeading ;
ReleaseDC (hwnd, hdc) ;
return 0 ;
case WM_SIZE: //=generated when window size changed, or by ShowWindow()
cxClient = LOWORD(lParam) ; //get client size
cyClient = HIWORD(lParam) ;
return 0;
case WM_COMMAND: //=generated by above SendMessage()
switch(LOWORD(wParam)) {
case 1:
Job(hwnd); //call my Job Functio
}
break;
case WM_PAINT: //=occurred when occuring invalid area(window moved, window size changed..), or by UpdateWindow()
hdc=BeginPaint(hwnd, &ps); //for Validate and Button visible!
EndPaint(hwnd, &ps) ;
break;
case WM_DESTROY :
PostQuitMessage (0);
break;
default :
return DefWindowProc(hwnd, message, wParam, lParam);
}//switch
return 0;
}//WinProc()
int msgX = 50;
int MsgNo = 1;
//==============Job Functio================================================
int Job(HWND hwnd)
{
HDC hdc;
HBRUSH hBrush;
HPEN hPen;
int i, sx, sy, itv, x, h, w=20;
static float Kor[3]={80, 58, 95};
static float Eng[3]={90, 85, 56};
static float Math[3]={75, 70, 84};
//========start==========================================================
UpdateWindow(hwnd); //=generate WM_PAINT and send WM_PAINT immediately.(for validate window)
hdc = GetDC(hwnd) ; //=get hdc
//--
sx=100;
sy=250;
itv=100;
//----x,y좌표축그리기---
for(i=sx; i<sx+300; i++)
SetPixel(hdc, i, sy, RGB(0,0,0));
for(i=sy; i>sy-150; i--)
Setpixel(hdc, sx, i, RGB(0,0,0));
//---국영수 막대그래프 그리기---
for(i=0; i<3; i++){
//--국어그래프--
x=sx+(itv*i);
h=sy-Kor[i];
Rectangle(hdc,x,h,x+h+1,sy+1);
//--영어그래프--
x=sx+(itv*i)+w;
h=sy-Eng[i];
Rectangle(hdc,x,h,x+w+1,sy+1);
//--수학그래프--
x=sx+(itv*i)+(w*2);
h=sy-Math[i];
Rectangle(hdc,x,h,x+w+1,sy+1);
//--과목명 쓰기--
x=sx+(itv*i);
TextOut(hdc, x, sy+2, "국 영 수", 9);
}
//
ReleaseDC(hwnd, hdc); //=release hdc
}//Job()
제가 뭘 잘못한걸까요?? ㅠㅠ 펑션이 금지어라 n을 하나씩 다 뻇어요
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.