bitmap
-
loadbitmap lädt von einer resource
was du brauchst ist
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcefunctions/loadimage.asp
-
soweit ich weiß nicht nur, oder?
"The MAKEINTRESOURCE macro can be used to create this value."
EDIT:
Habs mit resource versucht und des geht auch net... immernoch der selbe errorcode
-
-[NULL]- schrieb:
Habs mit resource versucht und des geht auch net... immernoch der selbe errorcode
Wie sieht denn jetzt dein LoadBitmap bzw. LoadImage-Aufruf aus und ist im ersten Fall hInst auch ein gültiges Instanz-Handle?
-
LoadBitmap() funktioniert nur mit Resourcen. Auch der Satz mit MAKEINTRESOURCE bezieht sich auf Bitmaps in Resourcen...
Mit LoadImage() sieht es so aus:
HBITMAP bmp; bmp=(HBITMAP)LoadImage(NULL,"c:\\blupp.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
-
Ha, thx... mit LoadImage funktionierts jetzt endlich...
hier nochmal der ganze quellcode... :
#include <windows.h> #include <stdio.h> #include <stdlib.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); HINSTANCE hInst; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { HWND hWnd; MSG msg; WNDCLASS wc; const char szAppName[] = "bitmapT"; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szAppName; RegisterClass(&wc); hWnd = CreateWindow( szAppName, "bitmapT", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); hInst = hInstance; 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 HBITMAP hBmp; HDC DC; HDC MemDC; PAINTSTRUCT ps; switch(message) { case WM_CREATE: { hBmp = (HBITMAP) LoadImage(hInst, "D:\\Programme\\Microsoft Visual Studio\\MyProjects\\bitmapT\\test.bmp", IMAGE_BITMAP,0,0,LR_LOADFROMFILE); return 0; } case WM_PAINT: { DC = BeginPaint(hWnd, &ps); MemDC = CreateCompatibleDC(DC); SelectObject(MemDC, hBmp); BitBlt(DC, 0, 0, 32, 37, MemDC, 0, 0, SRCCOPY); EndPaint(hWnd, &ps); return 0; } case WM_CLOSE: { PostQuitMessage(0); return 0; } case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, message, wParam, lParam); }
-
ehem... trotzdem merke ich gerade das das Bitmap sofort verschwindet
wenn ich das fenster mal minimiere oder maximiere...
obwohl BitBlt doch in WM_PAINT steht...
-
Evtl. liegt es daran, dass du MemDC in WM_PAINT nicht wieder frei gibst.
-
also, ich hab jetzt mal ReleaseDC(hWnd, MemDC); eingefügt und verändert hat sich leider nichts...
-
When you no longer need the memory DC, call the DeleteDC function.
Also DeleteDC(MemDC);

-
Danke, ich hab mich halt noch net extrem mit der winapi beschäftigt...
werd mir jetzt mal n buch kaufen...
PS.:
Es geht