002
11.03.2008, 16:54 Uhr
dorfkind
|
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { MSG msg; HWND hWnd; WNDCLASS wc; const char szAppName[] = "Windows Buttons"; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = szAppName; wc.lpszMenuName = NULL; wc.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); hWnd = CreateWindow( szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
static HWND Button1; switch (message) { case WM_CREATE: {
Button1 = CreateWindow( "button", "Schrittmotor", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, NULL, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); return 0; } case WM_SIZE: {
MoveWindow(Button1, LOWORD(lParam) / 2 - 80, HIWORD(lParam) - 30, 160, 22, TRUE); return 0; }
case WM_COMMAND: { if (lParam == (LPARAM)Button1) { if (HIWORD(wParam) == BN_CLICKED) system("cls"); gotoxy(30,5); printf("Schrittmotor-Steuerung"); b[1]=9;b[2]=5;b[3]=6;b[4]=10; i=0; while(1) { gotoxy(15,7); printf("Gewünschte Drehrichtung:r(echts),(l)inks eingeben:"); char Richtig; gotoxy(25,8); printf("Gewünschte Drehzahl: "); scanf("%i",&Drehz); if(Richtig=='r') for (j=1;j<=48*Drehz;j++) { i++; if(i==5) i=1; _outp(Par_Sst, b[i]); sleep(10); } if(Richtig=='l') for (j=1;j<=48*Drehz;j++) { i--; if(i<=0) i=4; _outp(Par_Sst,b[i]); sleep(10); } return 0; } case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, message, wParam, lParam); }
Fehlermeldungen: CDev-Cpp\Templates\schrittmotor.c In function `WndProc': 94 CDev-Cpp\Templates\schrittmotor.c `b' undeclared (first use in this function) (Each undeclared identifier is reported only once for each function it appears in.) 95 CDev-Cpp\Templates\schrittmotor.c `i' undeclared (first use in this function) 103 CDev-Cpp\Templates\schrittmotor.c `Drehz' undeclared (first use in this function) 105 CDev-Cpp\Templates\schrittmotor.c `j' undeclared (first use in this function) 110 CDev-Cpp\Templates\schrittmotor.c `Par_Sst' undeclared (first use in this function) 132 CDev-Cpp\Templates\schrittmotor.c syntax error at end of input
-------
Beim LCD wäre ich fürn denkanstoß dankbar. Habe keine Ahnung wie ich anfangen soll |