Resource Problem
-
moin,
hier die rc.h:
#define BITMAP_0 110und die main.rc:
#include "windows.h" #include "rc.h" BITMAP_0 BITMAP bg.bmpund noch die main.cpp
#include <windows.h> #include <Richedit.h> #include "rc.h" .... //========== BITMAP LADEN ===========// hBG = (HBITMAP)LoadImage(0,MAKEINTRESOURCE(BITMAP_0),IMAGE_BITMAP, 0, 0,LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION); if (!hBG) { int ms; ms =MessageBox(hwnd, "Konnte das Hintergrund-Bild nicht laden!", "FEHLER!", MB_OK); if (ms == IDOK) SendMessage(hwnd, WM_CLOSE, 0, 0); }jedoch will er das Bitmap nicht laden
alles wird kompiliert, aber dann kommt die MessageBox "Konnte das Hintergrund-Bild nicht laden!"woran liegt das?
ich will doch nur ein bitmap aus resource laden
-
GetLastError();

[vermutung]
kann LR_LOADFROMFILE beim resourcen laden dabei sein?
-
öhm, ich weiß nicht wie ich den error aussgeben soll

-
Arbeite halt statt mit LoadImage() mit LoadBitmap() ich glaub des is in dem fall leichter.
#include <windows.h> #include <Richedit.h> #include "rc.h" HBITMAP bild; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { bild = LoadBitmap(hThisInstance, MAKEINTRESOURCE(BITMAP_0)); }
-
danke!
-
codeBlocks schrieb:
öhm, ich weiß nicht wie ich den error aussgeben soll

void ErrorDescription(LPTSTR lpszFunction) { LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); lpDisplayBuf = (LPVOID)LocalAlloc( LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR)); wsprintf( (LPTSTR)lpDisplayBuf, TEXT("%s failed with error %d: %s"), lpszFunction, dw, lpMsgBuf); MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); } // ... hBG = (HBITMAP)LoadImage(0,MAKEINTRESOURCE(BITMAP_0),IMAGE_BITMAP, 0, 0,LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION); if (!hBG) { ErrorDescription("LoadImage");[edit] tags
