c++ codeblocks winapi build failed 0 errors 0 warnings



  • was geht ab!
    hab n kleines problem.
    erstelle grad ne trackbar mit burningcontrol aus nem tutorial.
    nach einigen fehlern die ich nach langer zeit endlich mal geloest hab zeigt der compiler an das der code keine fehler hat und zeigt auch keine warnungen an.trotzdem kommt kein resultat.nicht mal ein leeres fenster.
    kann mir einer helfen bitte.denn ohne das ich die headerfiles nicht nutzen kann macht das keinen sinn so richtig.

    hier der code:

    #if defined(UNICODE) && !defined(_UNICODE)
    #define _UNICODE
    #elif defined(_UNICODE) && !defined(UNICODE)
    #define UNICODE
    #endif
    #define _WIN32_IE 0x0400

    #include <iostream>
    #include <tchar.h>
    #include <windows.h>
    #include "commctrl.h"
    #include "commdlg.h"

    /* Declare Windows procedure */

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

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

    HINSTANCE g_hinst;
    LRESULT g_pos = 150;

    /* Make the class name into a global variable */

    int WINAPI WinMain (HINSTANCE hThisInstance,
    HINSTANCE hPrevInstance,
    LPCSTR lpszArgument,
    int nCmdShow)
    {
    HWND hwnd; /* This is the handle for our window /
    MSG messages; /
    Here messages to the application are saved /
    WNDCLASSEX wincl; /
    Data structure for the windowclass */

    /* The Window structure /
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure; /
    This function is called by windows /
    wincl.style = CS_DBLCLKS; /
    Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer /
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL; /
    No menu /
    wincl.cbClsExtra = 0; /
    No extra bytes after the window class */
    wincl.cbWndExtra = 0;

    /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
    return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
    0, /* Extended possibilites for variation /
    szClassName, /
    Classname /
    _T("Code::Blocks Template Windows App"), /
    Title Text /
    WS_OVERLAPPEDWINDOW, /
    default window /
    CW_USEDEFAULT, /
    Windows decides the position /
    CW_USEDEFAULT, /
    where the window ends up on the screen /
    544, /
    The programs width /
    375, /
    and height in pixels /
    HWND_DESKTOP, /
    The window is a child-window to desktop /
    NULL, /
    No menu /
    hThisInstance, /
    Program Instance handler /
    NULL /
    No Window Creation data */
    );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
    /* Translate virtual-key messages into character messages */
    TranslateMessage(&messages);
    /* Send message to WindowProcedure */
    DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
    }

    /* This function is called by the Windows function DispatchMessage() */

    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {

    static HWND hwndTrack, hwndBurn;
    WNDCLASSEX rwc = {0};

    INITCOMMONCONTROLSEX InitCtrlEx;

    InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    InitCtrlEx.dwICC = ICC_BAR_CLASSES;
    InitCommonControlsEx(&InitCtrlEx);

    switch (message) /* handle the messages */
    {

    case WM_CREATE:

    rwc.lpszClassName = "BurningControl";

    rwc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
    rwc.style = CS_HREDRAW;
    rwc.lpfnWndProc = PanelProc;
    rwc.hCursor = LoadCursor(0, IDC_ARROW);
    RegisterClassEx(&rwc);

    hwndBurn = CreateWindowEx(WS_EX_STATICEDGE , "BurningControl",

    NULL,
    WS_CHILD | WS_VISIBLE, 100, 330, 490, 30, hwnd, (HMENU)1, NULL,

    NULL);

    hwndTrack = CreateWindowExW(0, TRACKBAR_CLASSW, NULL,
    WS_CHILD | WS_VISIBLE | TBS_FIXEDLENGTH | TBS_NOTICKS,
    40, 25, 150, 25, hwnd, (HMENU) 2, g_hinst, NULL);

    SendMessage(hwndTrack, TBM_SETRANGE, TRUE, MAKELONG(0, 750));
    SendMessage(hwndTrack, TBM_SETPAGESIZE, 0, 20);
    SendMessage(hwndTrack, TBM_SETTICFREQ, 20, 0);
    SendMessage(hwndTrack, TBM_SETPOS, TRUE, 150);
    break;

    case WM_SIZE:

    SetWindowPos(hwndBurn, NULL, 0, HIWORD(lParam)-30,
    LOWORD(lParam), 30, SWP_NOZORDER);
    break;

    case WM_HSCROLL:

    g_pos = SendMessage(hwndTrack, TBM_GETPOS, 0, 0);
    InvalidateRect(hwndBurn, NULL, TRUE);
    break;

    case WM_DESTROY:
    PostQuitMessage (0); /* send a WM_QUIT to the message queue /
    break;
    default: /
    for messages that we don't deal with */
    return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
    }

    LRESULT CALLBACK PanelProc(HWND hwnd, UINT msg,
    WPARAM wParam, LPARAM lParam)
    {
    HBRUSH hBrushYellow, hBrushRed, holdBrush;
    HPEN hPen, holdPen;
    HFONT hFont, holdFont;
    PAINTSTRUCT ps;
    RECT rect, rect2;

    wchar_t *cap[] = { L"75", L"150", L"225", L"300", L"375", L"450",
    L"525", L"600", L"675"
    };

    HDC hdc;
    int till;
    int step, full;
    int i;

    switch(msg)
    {
    case WM_PAINT:

    hdc = BeginPaint(hwnd, &ps);

    GetClientRect(hwnd, &rect);

    till = (rect.right / 750.0) * g_pos;
    step = rect.right / 10.0;
    full = (rect.right / 750.0) * 700;

    hBrushYellow = CreateSolidBrush(RGB(255, 255, 184));
    hBrushRed = CreateSolidBrush(RGB(255, 110, 110));

    hPen = CreatePen(PS_NULL, 1, RGB(0, 0, 0));
    holdPen = (HPEN)SelectObject(ps.hdc, hPen);

    hFont = CreateFont(13, 0, 0, 0, FW_MEDIUM, 0, 0, 0, 0,
    0, 0, 0,0, "Tahoma");

    holdFont =(HFONT) SelectObject(ps.hdc, hFont);

    if(till > full)
    {

    SelectObject(hdc, hBrushYellow);
    Rectangle(hdc, 20, 40, full, 30);
    holdBrush = (HBRUSH)SelectObject(ps.hdc, hBrushRed);
    Rectangle(hdc, full, 0, till, 30);

    }
    else
    {

    holdBrush = (HBRUSH)SelectObject(ps.hdc, hBrushYellow);
    Rectangle(hdc, 0, 0, till, 30);
    }

    SelectObject(hdc, holdPen);

    for ( i = 1; i < 10; i++)
    {

    MoveToEx(hdc, istep, 0, NULL);
    LineTo(hdc, i
    step, 7);

    rect2.bottom = 28;
    rect2.top = 8;
    rect2.left = istep-10;
    rect2.right = i
    step+10;

    SetBkMode(hdc, TRANSPARENT) ;
    DrawTextW(hdc, cap[i-1], wcslen(cap[i-1]), &rect2, DT_CENTER);
    }

    SelectObject(hdc, holdBrush);
    DeleteObject(hBrushYellow);
    DeleteObject(hBrushRed);

    DeleteObject(hPen);

    SelectObject(hdc, holdFont);
    DeleteObject(hFont);

    EndPaint(hwnd, &ps);
    break;
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    und hier die compiler meldung:

    build failed 0 errors 0 warnings

    😮 😮 😮



  • in devcpp hat man n menu wo die headerfile verlinkung schon aktiv ist.da brauchst du als anfaenger nicht so lange suchen


Anmelden zum Antworten