Komische Zeichen im Text

Hallo,

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);
}
 
Probier mal aus statt "Titel", L"Titel" in der CreateWindowEx Funktion zu schreiben.
 
Code:
TextOut(hdc, 0,0,"[COLOR=black]Titel[/COLOR]", 10);
http://msdn.microsoft.com/en-us/library/dd145133(VS.85).aspx
Code:
[B]Parameters[/B]

 [I]hdc[/I] [in]   A handle to the device context.
 ...
[I]lpString[/I] [in]   A pointer to the string to be drawn. The string does not need to be zero-terminated, because [I]cbString[/I] specifies the length of the string.
 [I]cbString[/I] [in]   The [URL="http://msdn.microsoft.com/en-us/library/dd145112%28VS.85%29.aspx"]length of the string[/URL] pointed to by [I]lpString[/I].
also eigentlich macht TextOut Funktion genau das, was Du ihr sagst: nämlich 10 Zeichen ausgeben ;). Wenn nur "Titel" = 5 Zeichen erwünscht sind, so solltest Du
TextOut(hdc, 0,0,"Titel",5)
schreiben ;)
 
Zurück
Oben