In C++ hochzählen

Hallo, ich würde gerne wissen, wie man in C++ einfach hochzählen kann und jeweils die Nummern immer einzeln in ein Windowseingabefeld übertragen kann und dann nach jeder Eintragung das Enter ausgeführt werden soll und das man eventuell Startzahlen eingeben kann?
 
Ich denke mal mit einer Schleife, die am Ende eine Textausgabe besitzt und nach jedem Durchlauf den Zaehler inkrementiert, wird das ganz nett. Zum Thema "Enter" druecken - hmm villeicht ne "goto anfang" mit ner Bedingung, Enter zu druecken :) Was weiss ich, dafuer wirds schon nen Befehl geben...
 
Hab da mal eben schnell was in C zusammengekritzelt, in C++ sollte es ähnlich sein

Code:
#include <stdio.h>

int
main(void)
{
        int     count = 0, ende;

        printf("Bis wohin soll gezaehlt werden? ");
        scanf("%d",&ende);

        for(count = 0; count <= ende; count++)
        {
                if(count == 0)
                        getchar();
                printf("%d",count);
                getchar();
        }

        return 0;
}
 
Danke, aber das wäre nicht unbedingt das, was ich mir vorgestellt habe.
Er zählt zwar hoch, aber nach jeder erschienen Zahl muss man Enter drücken, damit er mit der nächsten weitermacht. Aber das alles geht nur in der Konsole, ich wollte es so das er in einen Windowseingabefenster die Zahlen eingibt und dann das Windowsfenster betätigt, was durch das "Enter" im C++-Programm realisieren sollte.
Aber meine C++ Kentnisse sind nicht so gut und ich weiß auch nicht wie man den Windowscoursor in ein Windowseingabefeld setzen kann und das das Programm dort die weiteren Befehle ausführt, wie die nächsten Zahlen eingeben und nach jeden eingeben Enter drückt, damit das Windowsfenster besätigt wird. Deswegen habe ich mich ja an euch gewandt.
 
Hallo Prometheus, bei einer GUI kann ich dir helfen, denkst du da an eine WIN32 API ?

Wie möchtest du den das die aussieht, ein Feld wo du die Startzahl eingibst und er dann immer um 1 erhöht ( beispielsweise du gibt 1 ein er gibt 2 aus ) , die Ausgabe möchtest du dann mit ENTER bestätigen und er erhöht wieder um 1 ?

Wen es das ist, kann ich dir den CODE hier posten...

( Entschuldige die Frage, bin ein Mensch der nicht alles beim ersten mal versteht :rolleyes: )

NACHTRAG:
---------------------------------------

Da die Nacht noch jung ist und eh nicht viel los ist, hab ich was für dich :

Code:
#include <windows.h>

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT ("Dawen for Prometheus") ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

     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 = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL;
     wndclass.lpszClassName = szAppName ;

     if (!RegisterClass (&wndclass))
	 {
          MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode und setzt Windows NT voraus!"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

     hwnd = CreateWindow (szAppName, TEXT ("Dawen for Prometheus"),
                          WS_OVERLAPPEDWINDOW | DS_3DLOOK ,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          400, 300,
                          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)
{
	HDC         hdc;
	PAINTSTRUCT ps;
	static HWND        HButton;
	static HWND        HStart;
	static HWND        HEnd;
	static HWND        HJumper;
	static HWND        HList;
	
	// Falls du Kommazahlen willst, musst du natürlich double nehmen
	static int   start;
	static int   end;
	static int   jumper = 1;
	static int   i;

	       char  cStart[18];
		   char  cEnd[18];
		   char  cJumper[18];
	       char  buffer[18];

	switch(message)
	{
	case WM_CREATE :

		HButton  = CreateWindow("button","Start",
			                  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
							  70,150,
							  80,20,
							  hwnd,(HMENU) 1,
							  ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		HStart  = CreateWindow("edit","0",
			                   WS_CHILD | WS_VISIBLE | WS_BORDER,
							   90,30,
							   80,15,
							   hwnd,(HMENU) 2,
							   ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		HJumper = CreateWindow("edit","1",
			                   WS_CHILD | WS_VISIBLE | WS_BORDER,
							   90,60,
							   80,15,
							   hwnd,(HMENU) 3,
							   ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		HEnd    = CreateWindow("edit","1",
			                   WS_CHILD | WS_VISIBLE | WS_BORDER,
							   90,90,
							   80,15,
							   hwnd,(HMENU) 3,
							   ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		HList   = CreateWindow("listbox",NULL,
			                   WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL,
							   200,30,
							   170,200,
							   hwnd,(HMENU) 4,
							   ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		return 0;

	case WM_PAINT:
		hdc = BeginPaint(hwnd,&ps);

		TextOut(hdc,10,30,"Startwert",lstrlen("Startwert"));
		TextOut(hdc,10,60,"Sprungwert",lstrlen("Sprungwert"));
		TextOut(hdc,10,90,"Endwert",lstrlen("Endwert"));

		EndPaint(hwnd,&ps);
		return 0;

	case WM_COMMAND:
		if(LOWORD(wParam) == 1)
		{
			if(HIWORD(wParam) == BN_CLICKED)
			{
				SendMessage(HList,LB_RESETCONTENT,0,0);
				GetWindowText(HStart,cStart,lstrlen(cStart));
				GetWindowText(HEnd,cEnd,lstrlen(cEnd));
				GetWindowText(HJumper,cJumper,lstrlen(cJumper));
				
				start  = atoi(cStart);
				end    = atoi(cEnd);
				jumper = atoi(cJumper);
			}

		}
		while(start <= end)
		{
			wsprintf(buffer,"%i ",start);
			SendMessage(HList,LB_ADDSTRING,0,(LONG) buffer);
			start = start + jumper;
			
		}

		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd,message,wParam,lParam);
}

Diese Version ist mit einer Liste, die mit Enter bekommst du morgen.
Das Programm ist auch nicht das beste, weil da einige Fehlerroutinen fehlen, ich hab es auf die schnelle gemacht, aber so kannst du ja mal sagen, ob es das ist was du suchst.
 
@Dawen
Danke, das du meinetwegen dir soviel Mühe gegeben hast.
Startwert, Sprungwert und Endwert sind schon ok, aber das was in den rechten Fenster ausgegeben wird, möchte ich in einen andere Windowsfenster ausgegeben haben und das Enter sollte dafür gedacht sein, das es nach jeder Eingabe der Zahl das Windowsfenster bestätigt.
Also, hier mal ein Beispiel. Ich rufe das besagte Windowsfenster auf und starte dann dein Programm. Ich gebe in deinen Programm die Werte(Startwert, Sprungwert und Endwert, z.B.: 1;1;20) ein, dann setze ich den Cursor in das Eingabefeld des besagten Windowsfenster, starte dein Programm und es schreibt eine 1 in das Eingabefeld des besagten Windowsfenster. Danch kommt das Enter und betätigt das ok auf den Windowsfenster. Dann macht Windows etwas und öffnet daselbe Windowsfenster nochmal. Der Wert 1 steht immernoch im Eingabefeld des besagten Windowsfenster und dein Programm setzt den Cursor in das Eingabefeld in der die 1 steht, dann wird die 1 durch die 2 ersetzt, dann wieder Enter usw.
 
Soviel Mühe war das nun auch wieder nicht !

Ich hab leider schon länger nichts mehr mit GUIS unter C++ gemacht, da ich viel mit JAVA machen musste, vor allem JAVA lernen. Ich hatte heute wieder so ein Familiensonntag, daher nur wenig Zeit, ich muss mal schauen wie man das mit 2 Fenster machen könnte, da man da 2 Window Prozeduren für benötigt. Das ganze könnte man per MDI machen, ein anderer Vorschlag wäre das du eine MessageBox nimmst, was aber kein echtes Windowfenster wäre. Dialoge wären auch eine Möglichkeit. Ich schau mal die Tage wie man das macht, mich interessiert sowas ja auch.

Solltest du schon eine Lösung haben, weisst bescheid her damit....

------------------------------------------------------------------------------------

Also, etwas rumprobiert und kurz nachgefrage und hier hast du es :

Eine Version mit Dialog :

Code:
main.cpp

#include <windows.h>
#include <stdlib.h>
#include "resource.h"

LRESULT CALLBACK WndProc      (HWND, UINT, WPARAM, LPARAM) ;
BOOL    CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ;

#define b_start 1
#define e_start 2
#define e_sprng 3
#define e_enwrt 4

static int start;
static int end;
static int sprung;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT ("Dawen for Prometheus") ;
     MSG          msg ;
     HWND         hwnd ;
     WNDCLASS     wndclass ;
     
     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (hInstance, szAppName) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = "NULL" ;
     wndclass.lpszClassName = szAppName ;
     
     if (!RegisterClass (&wndclass))
     {   
          MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode !"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
     
     hwnd = CreateWindow (szAppName, TEXT ("Dawen for Prometheus"),
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          300, 300,
                          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 HINSTANCE hInstance ;
	 static HWND Hbutton;
	 static HWND HStart;
	 static HWND HSprung;
	 static HWND HEnd;

	 HDC hdc;
	 PAINTSTRUCT ps;

	 char v1[30];
	 char v2[30];
	 char v3[30];

     switch (message)
     {
     case WM_CREATE :
          hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;

		  HStart = CreateWindow("edit","0",
			                      WS_CHILD | WS_VISIBLE | WS_BORDER,
								  85,30,
								  80,20,
								  hwnd,(HMENU) e_start,
								  ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		  HSprung = CreateWindow("edit","0",
			                     WS_CHILD | WS_VISIBLE| WS_BORDER,
								 85,60,
								 80,20,
								 hwnd,(HMENU) e_sprng,
								 ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		  HEnd    = CreateWindow("edit","0",
			                     WS_CHILD | WS_VISIBLE| WS_BORDER,
								 85,90,
								 80,20,
								 hwnd,(HMENU) e_enwrt,
								 ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		  Hbutton = CreateWindow("button","start",
			                     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
								 85,120,
								 80,25,
								 hwnd,(HMENU) b_start,
								 ((LPCREATESTRUCT) lParam)->hInstance,NULL);


          return 0 ;  

	 case WM_COMMAND:
		if(lParam == (LPARAM) Hbutton)
		{
			if(HIWORD(wParam) == BN_CLICKED)
			  GetWindowText(HStart,v1,lstrlen(v1));
			  GetWindowText(HSprung,v2,lstrlen(v2));
			  GetWindowText(HEnd,v3,lstrlen(v3));

			  start  = atoi(v1);
			  sprung = atoi(v2);
			  end    = atoi(v3);
			  while(start <= end)
			  {
		      DialogBox(hInstance,"Dialog",hwnd,AboutDlgProc);
              start = start + sprung;
			  }
		}
	 	 return 0;
	case WM_PAINT:
		hdc = BeginPaint(hwnd,&ps);
		TextOut(hdc,10,30,"Startwert",lstrlen("Startwert"));
		TextOut(hdc,10,60,"Sprungwert",lstrlen("Sprungwert"));
		TextOut(hdc,10,90,"EndWert",lstrlen("Endwert"));
		EndPaint(hwnd,&ps);
		return 0;
     case WM_DESTROY :
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}

BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message, 
                            WPARAM wParam, LPARAM lParam)
{
	 TCHAR buffer[21];
     switch (message)
     {
     case WM_INITDIALOG :
		 wsprintf(buffer,"Wert : %i",start);
		 SetWindowText(GetDlgItem(hDlg,IDC_EDIT1),buffer);
          return TRUE ;       
     case WM_COMMAND :
          switch (LOWORD (wParam))
          {
          case IDOK :
			   EndDialog (hDlg, 0) ;
			  return TRUE;
          case IDCANCEL :
			   start = end;
               EndDialog (hDlg, 0) ;
               return TRUE;
          }
          break ;
     }
     return FALSE ;
}

Code:
resource.h

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by dialog.rc
//
#define IDC_EDIT1                       1000

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1002
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

Code:
dialog.rc

//Microsoft Developer Studio generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Deutsch (Deutschland) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
#ifdef _WIN32
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

DIALOG DIALOG DISCARDABLE  36, 36, 186, 81
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Ergebnis"
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,34,53,50,14
    EDITTEXT        IDC_EDIT1,24,27,135,12,ES_AUTOHSCROLL | NOT WS_TABSTOP
    PUSHBUTTON      "Abbrechen",IDCANCEL,98,52,51,15
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE 
BEGIN
    "DIALOG", DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 179
        TOPMARGIN, 7
        BOTTOMMARGIN, 74
    END
END
#endif    // APSTUDIO_INVOKED


#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED

#endif    // Deutsch (Deutschland) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

Eine Version mit 2 Fenster, was du ja auch wolltest, eventuelle Modifikationen kannst du ja noch machen :

Code:
#include <windows.h>

LRESULT CALLBACK WndProc      (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK CldProc      (HWND, UINT, WPARAM, LPARAM) ;


#define b_start 1
#define e_start 2
#define e_sprng 3
#define e_enwrt 4
#define b_ok 5
#define WM_SENDWINDOWHANDLE WM_USER+0
#define WM_SHOWSTRING WM_USER+1

static int start  = 0;
static int end    = 0;
static int sprung = 0;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT ("Dawen for Prometheus") ;
     MSG          msg ;
     HWND         hwnd ;
	 HWND         child;
     WNDCLASS     wndclass ;
	 WNDCLASS     wndclass2;
     
     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (hInstance, NULL) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = "NULL" ;
     wndclass.lpszClassName = szAppName ;
     
     if (!RegisterClass (&wndclass))
     {   
          MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode !"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
     
     hwnd = CreateWindow (szAppName, TEXT ("Dawen for Prometheus"),
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT,
                          300, 300,
                          NULL, NULL, hInstance, NULL) ;

	 wndclass2.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass2.lpfnWndProc   = CldProc ;
     wndclass2.cbClsExtra    = 0 ;
     wndclass2.cbWndExtra    = 0 ;
     wndclass2.hInstance     = hInstance ;
     wndclass2.hIcon         = LoadIcon (hInstance, NULL) ;
     wndclass2.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass2.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass2.lpszMenuName  = "NULL" ;
     wndclass2.lpszClassName = "Child" ;
     
     if (!RegisterClass (&wndclass2))
     {   
          MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode !"), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
     
     child = CreateWindow ("Child", TEXT ("Dawen for Prometheus"),
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT , CW_USEDEFAULT,
                          300, 300,
                          NULL, NULL, hInstance, NULL);

     SendMessage(hwnd,WM_SENDWINDOWHANDLE,(WPARAM)child,0);

     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 HINSTANCE hInstance ;
	 static HWND Hbutton;
	 static HWND HStart;
	 static HWND HSprung;
	 static HWND HEnd;
	 static HWND child = NULL;

	 char v1[30];
	 char v2[30];
	 char v3[30];

	 HDC hdc;
	 PAINTSTRUCT ps;

     switch (message)
     {
     case WM_CREATE :
          hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;

		  HStart = CreateWindow("edit","0",
			                      WS_CHILD | WS_VISIBLE | WS_BORDER,
								  85,30,
								  80,20,
								  hwnd,(HMENU) e_start,
								  ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		  HSprung = CreateWindow("edit","0",
			                     WS_CHILD | WS_VISIBLE| WS_BORDER,
								 85,60,
								 80,20,
								 hwnd,(HMENU) e_sprng,
								 ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		  HEnd    = CreateWindow("edit","0",
			                     WS_CHILD | WS_VISIBLE| WS_BORDER,
								 85,90,
								 80,20,
								 hwnd,(HMENU) e_enwrt,
								 ((LPCREATESTRUCT) lParam)->hInstance,NULL);

		  Hbutton = CreateWindow("button","Start",
			                     WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
								 85,120,
								 80,25,
								 hwnd,(HMENU) b_start,
								 ((LPCREATESTRUCT) lParam)->hInstance,NULL);


          return 0 ;
	 case WM_COMMAND:
		 if(lParam == (LPARAM) Hbutton)
		 {
			if(HIWORD(wParam) == BN_CLICKED)
			 {
				GetWindowText(HStart,v1,lstrlen(v1));
				GetWindowText(HSprung,v2,lstrlen(v2));
				GetWindowText(HEnd,v3,lstrlen(v3));

				start  = atoi(v1);
				sprung = atoi(v2);
				end    = atoi(v3);

			
					wsprintf(v1,"%i",start);
					ShowWindow(child,SW_SHOWNORMAL);
					SendMessage(child,WM_SHOWSTRING,(WPARAM)v1,0);
					start = start + sprung;
								
			 }
		 }
		 return 0;
	 case WM_KEYDOWN:
		 switch(wParam)
		 {
		 case VK_RETURN:
			 if(start<=end)
			 {
				 wsprintf(v1,"%i",start);
				 ShowWindow(child,SW_SHOWNORMAL);
				 SendMessage(child,WM_SHOWSTRING,(WPARAM)v1,0);
				 start = start + sprung;
			 }
			 else
			 {
				 MessageBox(NULL,"Start und Endwert sind identisch","INFO !!!",MB_OK | MB_ICONSTOP);
			 }
			 break;
		 }
		 return 0;
	 case WM_SENDWINDOWHANDLE:
		 child = (HWND)wParam;
		 return 0;
	case WM_PAINT:
		hdc = BeginPaint(hwnd,&ps);
		TextOut(hdc,10,30,"Startwert",lstrlen("Startwert"));
		TextOut(hdc,10,60,"Sprungwert",lstrlen("Sprungwert"));
		TextOut(hdc,10,90,"EndWert",lstrlen("Endwert"));
		EndPaint(hwnd,&ps);
		return 0;
     case WM_DESTROY :
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}

LRESULT CALLBACK CldProc (HWND child, UINT message, WPARAM wParam, LPARAM lParam)
{
     static HINSTANCE hInstance ;
	 static HWND HStart;
	 HDC hdc;
	 PAINTSTRUCT ps;

     switch (message)
     {
	 case WM_KEYDOWN:
	   switch(wParam)
	   {
	   case VK_RETURN :
		 ShowWindow(child,SW_HIDE);
		 break;
	   }
	   return 0;
     case WM_CREATE :
          hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;

		  HStart = CreateWindow("edit","0",
			                      WS_CHILD | WS_VISIBLE | WS_BORDER,
								  85,30,
								  80,20,
								  child,(HMENU) e_start,
								  ((LPCREATESTRUCT) lParam)->hInstance,NULL);


          return 0 ;  
	 case WM_SHOWSTRING:
		 SetWindowText(HStart,(TCHAR*)wParam);
		 return 0;
	case WM_PAINT:
		hdc = BeginPaint(child,&ps);
		TextOut(hdc,10,30,"Startwert",lstrlen("Startwert"));
		EndPaint(child,&ps);
		return 0;
     case WM_DESTROY :
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (child, message, wParam, lParam) ;
}
 
Zurück
Oben