#include "resource.h" ????
-
Hi leute , ich bin neu hier und wolte fragen was hat dieses zu bedeuten?
#include "resource.h" ????
woher bekomm ich diese daitei oder wie mache ich sie??
ich arbeite mit dev_cpp V: 4.9.9.9 gerade mit ein tutorial zusammen
auch von dieser seite: wie man bilder im fenster macht
-
Die Datei mußt du dir notfalls selber zusammenbauen (viele IDEs bringen einen Ressourcen-Editor mit, in dem du z.B. Dialogfenster zusammenbauen kannst - die legen dann auch die darauf abgestimmte "ressource.h" an).
-
kann ich die datei auch dowloaden , weil ich ein c++ anfänger bin und nochnicht genug kentnisse hab

oder gibt es irgentwo ein tutorial wie man sowas macht
-
Nein, kannst du nicht, weil die bei jedem Projekt anders aussehen wird. In die Datei packt der Ressourcen-Editor die IDs der Dialoge, Dialogelemente, Menü-Einträge etc., die du grafisch zusammengebastelt hast.
(wenn du wissen willst, wie das mit deinem System geht, solltest du warten, bis ein Mod diesen Thread ins richtige Board verfrachtet hat)
-
nun ja ich hoffe ihr könnt mir doch helfen , weil ich diesen code kopiert habe aber ich bekomm das noch nicht hin
-
also der komplette halt:
#include <windows.h>
#include "resource.h"const char g_szClassName[] = "myWindowClass";
HBITMAP g_hbmBall = NULL;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
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_CLOSE:
DestroyWindow(hwnd);
break;
case WM_PAINT:
{
// Just a note, never use a MessageBox from inside WM_PAINT
// The box will cause more WM_PAINT messages and you'll probably end up
// stuck in a loopBITMAP bm;
PAINTSTRUCT ps;HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = 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:
DeleteObject(g_hbmBall);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
-
Hallo !
Bei deinem Programm fehlen noch ganz wichtige Teile.
Du könntest das hier benutzen, das Funktioniert ohne Ressourcen:#include <windows.h> char* pcBmp = "C:\\Bilder\\xyz.bmp"; HINSTANCE hInst; LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX WndCls; static char szAppName[] = "Proggingmanias Simple Bitmap Window"; MSG Msg; hInst = hInstance; WndCls.cbSize = sizeof(WndCls); WndCls.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW; WndCls.lpfnWndProc = WindProcedure; WndCls.cbClsExtra = 0; WndCls.cbWndExtra = 0; WndCls.hInstance = hInst; WndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndCls.hCursor = LoadCursor(NULL, IDC_ARROW); WndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); WndCls.lpszMenuName = NULL; WndCls.lpszClassName = szAppName; WndCls.hIconSm = LoadIcon(hInstance, IDI_APPLICATION); RegisterClassEx(&WndCls); CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, szAppName, "Proggingmanias Simple Bitmap Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); while( GetMessage(&Msg, NULL, 0, 0) ) { TranslateMessage(&Msg); DispatchMessage( &Msg); } return (Msg.wParam); } LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { HDC hDC, MemDC; PAINTSTRUCT Ps; HBITMAP hbmp; char buf[256]; RECT r; GetWindowRect( hWnd, &r ); switch(Msg) { case WM_DESTROY: PostQuitMessage(WM_QUIT); break; case WM_PAINT: hDC = BeginPaint(hWnd, &Ps); hbmp = (HBITMAP)LoadImage(NULL, pcBmp, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); if ( !hbmp ) { sprintf( buf, "%s not found.", pcBmp ); MessageBox( hWnd, buf, "Picture not found", MB_OK ); ExitProcess(1); } // Create a memory device compatible with the above DC variable MemDC = CreateCompatibleDC(hDC); // Select the new bitmap SelectObject(MemDC, hbmp); // Copy the bits from the memory DC into the current dc BitBlt(hDC, 0, 0, r.right, r.bottom, MemDC, 0, 0, SRCCOPY); // Restore the old bitmap DeleteDC(MemDC); DeleteObject(hbmp); EndPaint(hWnd, &Ps); break; default: return DefWindowProc(hWnd, Msg, wParam, lParam); } return 0; }
-
error in:
hbmp = LoadBitmap(hInst, IDB_MEINBILD );
-
FETTEN *THUMPS UP* jetzt funtz der code sogar sofort: - code kopieren und run!!!
///////CODE NOCHMAL ABER OHNE FEHLER !!!!!/////////
#include <windows.h>
char* pcBmp = "C:\\Bilder\\xyz.bmp";
HINSTANCE hInst;LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndCls;
static char szAppName[] = "Proggingmanias Simple Bitmap Window";
MSG Msg;hInst = hInstance;
WndCls.cbSize = sizeof(WndCls);
WndCls.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
WndCls.lpfnWndProc = WindProcedure;
WndCls.cbClsExtra = 0;
WndCls.cbWndExtra = 0;
WndCls.hInstance = hInst;
WndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
WndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndCls.lpszMenuName = NULL;
WndCls.lpszClassName = szAppName;
WndCls.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
RegisterClassEx(&WndCls);CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
szAppName,
"Proggingmanias Simple Bitmap Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage( &Msg);
}return (Msg.wParam);
}LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
HDC hDC, MemDC;
PAINTSTRUCT Ps;
HBITMAP hbmp;
char buf[256];RECT r;
GetWindowRect( hWnd, &r );switch(Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
case WM_PAINT:
hDC = BeginPaint(hWnd, &Ps);hbmp = (HBITMAP)LoadImage(NULL, pcBmp, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);if ( !hbmp )
{MessageBox( hWnd, buf, "Picture not found", MB_OK );
ExitProcess(1);
}// Create a memory device compatible with the above DC variable
MemDC = CreateCompatibleDC(hDC);
// Select the new bitmap
SelectObject(MemDC, hbmp);// Copy the bits from the memory DC into the current dc
BitBlt(hDC, 0, 0, r.right, r.bottom, MemDC, 0, 0, SRCCOPY);// Restore the old bitmap
DeleteDC(MemDC);
DeleteObject(hbmp);
EndPaint(hWnd, &Ps);
break;default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
-
pokêmon schrieb:
error in:
hbmp = LoadBitmap(hInst, IDB_MEINBILD );Ja, die Zeile ist zuviel
, die muss raus.
Habs mal geändert.
-
^^Hehe
... gibt es irgentwo so codes mit fehler woran man lehrnen kann ??
so wie den den du mir geschickt hast : also so übungen?
