Hallo,
wenn ich meine Api starte, dann erscheint dorten: "Titel|||!@", wobei da nur "Titel" stehen sollte. Ich habe keinen Fehler gefunden.
wenn ich meine Api starte, dann erscheint dorten: "Titel|||!@", wobei da nur "Titel" stehen sollte. Ich habe keinen Fehler gefunden.
Code:
#include <windows.h>
#include <string.h>
#include <commctrl.h>
#include "resource.h"
#include "dialogs.h"
#define WEISS RGB(255,255,255)
#define DARKBLUE RGB(0,0,100)
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
//Deklaration der Windows-Nachrichten-Prozedur
HWND hwnd;
COLORREF backcolor = WEISS,
textcolor = SCHWARZ,
currentcolor = SCHWARZ;
static LOGBRUSH logbrush;
static COLORREF customcolors[16];
CHOOSECOLOR choosecolor;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrI, PSTR szCmdLine, int nCmdShow)
{
const char g_szClassName[] = "Fensterklasse";
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
wc.lpszClassName = g_szClassName;
wc.hIconSm = NULL;
if(!RegisterClassEx(&wc))
{
MessageBox(NULL,"Fenster konnte nicht erstellt werden.","Fehler",MB_ICONERROR|MB_OK);
return 0;
}
hwnd = CreateWindowEx(0, g_szClassName, "Editor", WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
CW_USEDEFAULT,CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox( NULL, "Konnte kein Fenster erstellen!",
"Error!",MB_ICONEXCLAMATION | MB_OK );
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Nachrichten-Schleife
MSG msg;
while (GetMessage (&msg, NULL, 0, 0)>0)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
// Windows-Nachrichten-Prozedur
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
char string[255];
static HWND hEdit;
char a[33];
switch (message)
{
case WM_CREATE:
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD|WS_VISIBLE,0,20,80,20, hwnd, (HMENU)IDC_EDIT,
GetModuleHandle(NULL),NULL);
FontInitialize(hEdit);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd,&ps);
SetBkColor(hdc, RGB(130,130,130));
TextOut(hdc, 0,0,"Titel", 10);
EndPaint(hwnd,&ps);
return 0;
case WM_SETFOCUS:
SetFocus (hEdit);
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_NEW:
SetDlgItemText(hwnd, IDC_EDIT, "");
case ID_FILE_OPEN:
OpenFileBox(hwnd);
return 0;
case ID_FILE_SAVE:
SaveFileBox(hwnd);
return 0;
case ID_FILE_EXIT:
DestroyWindow(hwnd);
break;
case ID_FILE_FONT:
FontChooseFont(hEdit);
FontSetFont(hEdit);
return 0;
case ID_FILE_PRINT:
PrintFile(hInst,hwnd,hEdit,szFileName);
return 0;
}
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
case WM_DESTROY:
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}