Two things

Well, here's the full code:

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <windows.h>
#include "FreeImage/FreeImage.h"

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

HWND hwnd;
HDC hDC;
HINSTANCE g_hinst;
COLORREF g_color;


int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    MSG  msg ;
    WNDCLASS wc = {0};
    wc.lpszClassName = TEXT("App");
    wc.hInstance     = hInstance ;
    wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
    wc.lpfnWndProc   = WndProc ;
    wc.hCursor       = LoadCursor(0,IDC_ARROW);

    g_hinst = hInstance;

    RegisterClass(&wc);
    hwnd = CreateWindow(wc.lpszClassName, TEXT("FI App"), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 500, 650, 0, 0, hInstance, 0);

    while( GetMessage(&msg, NULL, 0, 0)) {
        DispatchMessage(&msg);
    }
    return (int) msg.wParam;
    hDC = GetDC(hwnd);
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    FreeImage_Initialise();
    LPCTSTR lpInfo[] = {"Hello", "World", "of", "scary", "deathlike", "illusions"};
    int sel = 0;
    int currentPic = 0;
    const char* files[] = {"five.jpg", "seven.jpg", "one.jpg", "three.jpg", "six.jpg", "nine.jpg"};
    LPCTSTR itemNames[] = {"five", "seven", "one", "three", "six", "nine"};

    HWND hwndListBox, hwndInfo;
    FIBITMAP *dib = FreeImage_Load(FIF_JPEG, files[sel], JPEG_DEFAULT);

    switch(msg) {
        case WM_CREATE: {
            hwndListBox = CreateWindowEx(NULL, "LISTBOX", NULL, WS_CHILD | WS_VISIBLE | LBS_STANDARD, 5, 5, 450, 100, hwnd, (HMENU)100, NULL, NULL);
            hwndInfo = CreateWindowEx(NULL, "STATIC", NULL, WS_CHILD | WS_VISIBLE | SS_CENTER, 5, 110, 450, 90, hwnd, (HMENU)102, NULL, NULL);

            for(int i = 0; i < 6; i++) {
                SendMessage(hwndListBox, LB_ADDSTRING, 0, (LPARAM)itemNames[i]);
            }

            SendMessage(hwndListBox, WM_SETFONT, (WPARAM)CreateFont(17,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Courier New")), TRUE);
            SendMessage(hwndInfo, WM_SETFONT, (WPARAM)CreateFont(17,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,TEXT("Courier New")), TRUE);
            SetFocus(hwndListBox);
        } break;

        case WM_PAINT: {
            FreeImage_Unload(dib);
            dib = FreeImage_Load(FIF_JPEG, files[currentPic], JPEG_DEFAULT);
            StretchDIBits(hDC, 460, 205, 160, 160, 0, 0, 160, 160, FreeImage_GetBits(dib), FreeImage_GetInfo(dib), DIB_RGB_COLORS, SRCCOPY);
            UpdateWindow(hwnd);
            ShowWindow(hwnd, 5);
        } break;

        case WM_COMMAND: {
            if(HIWORD(wParam) == LBN_SELCHANGE) {
                sel = SendMessage(hwndListBox, LB_GETCURSEL, 0, 0);
                FreeImage_Unload(dib);
                dib = FreeImage_Load(FIF_JPEG, files[sel], JPEG_DEFAULT);
                SetWindowText(hwndInfo, lpInfo[sel]);
            }
        } break;

        case WM_DESTROY: {
            FreeImage_Unload(dib);
            FreeImage_DeInitialise();
            PostQuitMessage(0);
        } break;
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}


And here's the two main problems:

1. The text in the static control doesn't seem to update even after I update "hwnd".
2. The image in the rectangle doesn't show at all when loaded. Is this an issue with my code, or with the file?

What exactly is wrong with this? Everything runs fine except for those two things.
Topic archived. No new replies allowed.