Bild ohne DLL laden
-
Also ich habe ein Proramm in dem ich ein Bild einbinden möchte.
Dafür habe ich mir nun Informationen in Google gesucht und dem entsprechend einen Quellcode erstellt den ich ganz am ende mal poste.Jedenfalls wird dort eine Konstante IDB_BALL verwendet.
Diese konste muss einen INT wert haben.
Dieser wert ist irgendwo in einer DLL gespeichert, im zusammenhang mit der quelle steht da. Ich möchte das jetzt aber ohne die dll machen... Leider weiß ich nicht wo ich die quelle hinterlegen muss.Vllt kann mir da ja wer weiter helfen.
Hier mal der meiner meinung nach wictige codeabschnitt:
case WM_PAINT: { BITMAP bm; PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, g_hbmball); GetObject(g_hbmball, sizeof(bm), &bm); BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); EndPaint(hWnd, &ps); } break;MFG Sqwan
Und dann noch mal den ganzen code, falls das helfen sollte...
#include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { MSG msg; HWND hWnd; WNDCLASS wc; char szAppName[] = "Tastaturabfragen"; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = szAppName; wc.lpszMenuName = NULL; wc.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); hWnd = CreateWindow( szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static RECT rect; static bool ArrowKeys[4]; HBITMAP g_hbmball = NULL; const IDB_BALL=0; switch (message) { case WM_CREATE: { g_hbmball=LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_BALL)); if(g_hbmball==NULL) MessageBox(hWnd, "Could not load IDB_Ball!", "ERROR", MB_OK | MB_ICONEXCLAMATION); break; } case WM_SIZE: { rect.right = LOWORD(lParam); rect.bottom = HIWORD(lParam); return 0; } case WM_KEYDOWN: { switch (wParam) { case VK_LEFT: ArrowKeys[0] = true; break; case VK_UP: ArrowKeys[1] = true; break; case VK_RIGHT: ArrowKeys[2] = true; break; case VK_DOWN: ArrowKeys[3] = true; break; default: return 0; } InvalidateRect(hWnd, NULL, FALSE); return 0; } case WM_KEYUP: { switch (wParam) { case VK_LEFT: ArrowKeys[0] = false; break; case VK_UP: ArrowKeys[1] = false; break; case VK_RIGHT: ArrowKeys[2] = false; break; case VK_DOWN: ArrowKeys[3] = false; break; default: return 0; } InvalidateRect(hWnd, NULL, FALSE); return 0; } case WM_PAINT: { BITMAP bm; PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, g_hbmball); GetObject(g_hbmball, sizeof(bm), &bm); BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); EndPaint(hWnd, &ps); } break; case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, message, wParam, lParam); }
-
Ich hoffe mal du suchst sowas:
http://www.winprog.org/tutorial/resources.html