1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <windows.h>
#include <stdio.h>
#include "functions.h"
//Neues Produkt Dialog
LRESULT CALLBACK neuesProduktProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
CHAR *lpszName[16];
WORD anzChar;
FILE *fp;
switch(msg)
{
case WM_CREATE:
CreateWindow(TEXT("Edit"), TEXT(""),
WS_VISIBLE | WS_CHILD | WS_BORDER,
50, 50, 80, 25,
hwnd, (HMENU) ID_EDITNAME, NULL, NULL);
CreateWindow(TEXT("Button"), TEXT("Hinzu"),
WS_VISIBLE | WS_CHILD | WS_BORDER,
100, 50, 80, 25,
hwnd, (HMENU) ID_EDITHINZU, NULL, NULL);
break;
case WM_COMMAND:
if(LOWORD(wParam) == ID_EDITHINZU) {
anzChar = (WORD) SendDlgItemMessage(hwnd,
ID_EDITNAME,
EM_LINELENGTH,
(WPARAM) 0,
(LPARAM) 0);
*((LPWORD)lpszName) = anzChar;
SendDlgItemMessage(hwnd,
ID_EDITNAME,
EM_GETLINE,
(WPARAM) 0, // line 0
(LPARAM) lpszName);
lpszName[anzChar] = '\0';
fp = fopen("test.txt","a");
if(fp == NULL) {
MessageBox(hwnd,TEXT("Datei konnte nicht geöffnet werden"),TEXT("Fehler beim Öffnen der Datei"),MB_OK);
}
else {
fprintf(fp,"%i%s",anzChar,lpszName);
fclose(fp);
}
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
}
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
|