zdar chalani ak mate niekto cas mrknite sa mi prosim na to. programujem Win32 v Dev-C++ a zacinam chapat ze mi nestaci tak prechadzam na visual studio. program som okopcil a studio mi vyhadzuje chyby a neviem ich odstranit. mohli by ste mi povedat co znamenaju?? diki
tu su errory:
Kód:
2 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 48
3 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 48
4 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 49
5 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 85
6 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 94
7 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 100
8 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 108
9 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 115
10 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 117
11 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 123
12 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 129
13 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 177
14 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 178
15 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 179
16 IntelliSense: a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 214
17 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 216
18 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 216
19 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 218
20 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 229
21 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 229
Error 1 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source? c:\users\milos\documents\visual studio 2010\projects\test\test\test.cpp 242
no a kod je tento
Kód:
#include <windows.h>
WNDCLASS WndClass;
HWND hwnd;
MSG msg;
static HBRUSH background;
unsigned int cxChar, cxCaps, cyChar, cxClient, cyClient, color[3], save[3];
CHAR *szName[] = {"CERVENA", "ZELENA", "MODRA"};
COLORREF colors[] = {RGB(255,0,0), RGB(0,255,0), RGB(0,0,255)};
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
HDC hdc;
PAINTSTRUCT ps;
static RECT rect;
TEXTMETRIC tm;
static HWND hwndScroll[2], hwndRight, hwndText[2], hwndEdit[2], hwndReset, hwndGetColor, hwndSave;
HINSTANCE hInstance;
char ch[5];
switch(message){
case WM_VSCROLL:
{
int i = GetWindowLong(HWND(lParam), GWL_ID);
switch(LOWORD(wParam)){
case SB_PAGEUP:
case SB_LINEUP:if(color[i]>0){color[i]--;}break;
case SB_PAGEDOWN:
case SB_LINEDOWN:if(color[i]<255){color[i]++;}break;
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
color[i] = HIWORD(wParam);break;
default:break; }
SetScrollPos(hwndScroll[i], SB_CTL, color[i], TRUE);
background = CreateSolidBrush(RGB(color[0], color[1], color[2]));
SetClassLong(hwnd, GCL_HBRBACKGROUND, (LONG) background);
InvalidateRect(hwnd, &rect, TRUE);
UpdateWindow(hwnd);
if(wParam!=10){
wsprintf(ch, "%d", color[i]);
SetWindowText(hwndEdit[i], ch); }
}
return 0;
case WM_CTLCOLORSCROLLBAR:{
int i = GetWindowLong((HWND) lParam, GWL_ID);
background = CreateSolidBrush(colors[i]);
return (LRESULT) background;}
case WM_CTLCOLORSTATIC:{
int i = GetWindowLong((HWND) lParam, GWL_ID);
if((HWND)lParam == hwndSave){background = CreateSolidBrush(RGB(save[0], save[1], save[2]));return (LRESULT) background;}
if(i>=3){
SetTextColor((HDC) wParam, colors[i%3]);
SetBkColor((HDC) wParam, GetSysColor(COLOR_BTNHIGHLIGHT));
background = CreateSolidBrush(GetSysColor(COLOR_BTNHIGHLIGHT));
return (LRESULT) background;}
}
case WM_CREATE:
hdc = GetDC(hwnd);
GetTextMetrics(hdc, &tm);
ReleaseDC(hwnd, hdc);
cxChar = tm.tmAveCharWidth;
cyChar = tm.tmHeight + tm.tmExternalLeading;
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar/2;
hInstance = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE);
hwndRight = CreateWindow(
"static",NULL,
WS_CHILD | WS_VISIBLE | SS_WHITERECT,
0, 0, 0, 0,
hwnd, (HMENU) 9, hInstance, NULL
);
for(int i = 0; i<3; i++){
hwndEdit[i] = CreateWindow(
"edit",NULL,
WS_CHILD | WS_VISIBLE | ES_CENTER | WS_BORDER ,
0, 0, 0, 0,
hwnd, (HMENU) i+13, ((LPCREATESTRUCT) lParam) -> hInstance, NULL
);
hwndText[i] = CreateWindow(
"static",szName[i],
WS_CHILD | WS_VISIBLE | SS_CENTER,
0, 0, 0, 0,
hwnd, (HMENU) i+3, hInstance, NULL
);
hwndScroll[i] = CreateWindow(
"scrollbar",szName[i],
WS_CHILD | WS_VISIBLE/* | WS_TABSTOP*/ | SBS_VERT,
0, 0, 0, 0,
hwnd, (HMENU) i, hInstance, NULL
);
SetScrollRange(hwndScroll[i], SB_CTL, 0, 255, FALSE);
SetWindowText(hwndEdit[i], "0");
}
hwndReset = CreateWindow(
"button","RESET",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0, 0, 0,
hwnd, (HMENU) 10, hInstance, NULL
);
hwndGetColor = CreateWindow(
"button","Uloz farbu",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0, 0, 0,
hwnd, (HMENU) 11, hInstance, NULL
);
hwndSave = CreateWindow(
"static",NULL,
WS_CHILD | WS_VISIBLE | SS_CENTER,
0, 0, 0, 0,
hwnd, (HMENU) 12, hInstance, NULL
);
return 0;
case WM_SIZE:
cxClient = LOWORD (lParam);
cyClient = HIWORD (lParam);
rect.left = cxClient/2;
rect.right = cxClient;
rect.bottom = cyClient;
rect.top = 0;
MoveWindow(hwndRight, 0, 0, cxClient/2, cyClient, TRUE);
for(int i = 0; i<3; i++){
MoveWindow(hwndScroll[i], (cxClient/14)*i+(i+1)*cxClient/14, (cyClient/4)/2, cxClient/10, (cyClient/4)*3, TRUE);
MoveWindow(hwndText[i], (cxClient/14)*i+(i+1)*cxClient/14, (cyClient/4)/3, cxClient/10, cyChar, TRUE);
MoveWindow(hwndEdit[i], (cxClient/14)*i+(i+1)*cxClient/14, (cyClient/10)*9, cxClient/10, cyChar, TRUE);
}
MoveWindow(hwndReset, cxClient/7, (cyClient/15)*14, cxClient/10, cyChar, TRUE);
MoveWindow(hwndGetColor, (cxClient/28)*8, (cyClient/15)*14, cxClient/10, cyChar, TRUE);
MoveWindow(hwndSave, (cxClient/28)*8, (cyClient/30)*29, cxClient/10, cyChar, TRUE);
return 0;
case WM_COMMAND:
switch(LOWORD(wParam)){
case 10:{ for(int i = 0; i < 3; i++){
color[i] = save[i];
SendMessage(hwnd, WM_VSCROLL, 9 , LPARAM(hwndScroll[i]));}break;}
case 11:
save[0] = color[0];
save[1] = color[1];
save[2] = color[2];
InvalidateRect(hwndSave, NULL, TRUE);
UpdateWindow(hwndSave);
break;
default:break;}
if((HWND) lParam == hwndEdit[0] && HIWORD(wParam)==EN_CHANGE){GetWindowText(hwndEdit[0], ch, 4);color[0]=atoi(ch);SendMessage(hwnd, WM_VSCROLL, 10 , LPARAM(hwndScroll[0]));}
else if((HWND) lParam == hwndEdit[1] && HIWORD(wParam)==EN_CHANGE){GetWindowText(hwndEdit[1], ch, 4);color[1]=atoi(ch);SendMessage(hwnd, WM_VSCROLL, 10 , LPARAM(hwndScroll[1]));}
else if((HWND) lParam == hwndEdit[2] && HIWORD(wParam)==EN_CHANGE){GetWindowText(hwndEdit[2], ch, 4);color[2]=atoi(ch);SendMessage(hwnd, WM_VSCROLL, 10 , LPARAM(hwndScroll[2]));}
return 0;
/* case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
backround = CreateSolidBrush(RGB(0, 255, 0));
SetClassLong(hwnd, GCL_HBRBACKGROUND, (long)backround);
EndPaint(hwnd, &ps);
return 0;*/
case WM_DESTROY:
DeleteObject(background);
PostQuitMessage(0);
return 0;
default:break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
background = CreateSolidBrush(0);
WndClass.style = CS_HREDRAW | CS_VREDRAW;
WndClass.lpfnWndProc = WndProc;
WndClass.hInstance = hInstance;
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hbrBackground = background;
WndClass.lpszClassName = "WndClass";
if(!RegisterClass(&WndClass)){
MessageBox(NULL,"Failed registering main Window Class","ERROR",MB_ICONERROR);}
hwnd = CreateWindow("WndClass",
"FARBY by Milos",
WS_OVERLAPPEDWINDOW,
50,
70,
1030,
1050,
NULL,
NULL,
hInstance,
NULL);
if(hwnd == 0){MessageBox(NULL,"Failed creating window","ERROR",MB_ICONERROR);}
ShowWindow(hwnd , nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}return msg.wParam;
}