Wie mache ich Bilder zu den Exe.Dateien ??



  • Also ich würde gerne wissen wie ich zu den Exen datein ein Bild einfuege.
    Also dass die Exe ein Bild hat wie z.b. Icq diese Blume
    Kumpel meinte man müsste das im Compiler einstellen aber wie genau wusste er auch net

    Ich benutze den Ide Codeblocks

    Kann mir einer erklaeren wies geht?



  • etwa so:

    #ifndef Canvas_h
    #define Canvas_h
    
    #include "WindowManager.h"
    #include "Component.h"
    #include "Size.h"
    #include "BitmapDIBUncompressed32Bit.h"
    #include <iostream>
    using namespace std;
    
    class Canvas : public Component
    {
    public:
    	Canvas() : Component(0, 0, 100, 20), Bitmap("BILD.bmp")
    	{
    		cout<<"Canvas Konstruktor: "<<endl;
    		m_Type = Component::CANVAS;
    	}
    
    	void  create(HWND hWnd, HINSTANCE hInstance)
    	{
    
    		WNDCLASS wndcls;
    		wndcls.style            = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    		wndcls.lpfnWndProc      = (WNDPROC)WindowsManager::windowEventsProcessor;
    		wndcls.cbClsExtra       = wndcls.cbWndExtra = 0;
    		wndcls.hInstance        = hInstance;
    		wndcls.hIcon            = NULL;
    		wndcls.hCursor          = LoadCursor(NULL, IDC_ARROW);
    		wndcls.hbrBackground    = (HBRUSH) (COLOR_3DFACE + 1);
    		wndcls.lpszMenuName     = NULL;
    		wndcls.lpszClassName    = "MeinSteuerelement";
    		RegisterClass(&wndcls);
    
    		m_hWnd = CreateWindowEx(NULL,"MeinSteuerelement", "Meine Komponente", WS_CHILD |
    		WS_VISIBLE, 20, 20, 100, 20, hWnd, NULL, hInstance,
    		NULL);
    
    		cout<<"sdalfkwseik"<<endl;
    	}
    
    	void setPixel(int x, int y)
    	{
    		Bitmap[x+y*Bitmap.getWidth()] = 0xFFFF0000;
    	}
    
    	void drawLine(int d1x, int d1y, int d2x, int d2y)
    	{
    		bool Z = true; // zur Bestimmung der Bewegunsrichtung
    		int *m; // Bewegungsrichtung/Vektoren
    		// delta a, delta b und Bewegungsrichtung bestimmen
    		int dx = d2x - d1x;
    		int dy = d2y - d1y;
    		int da = abs(dx), db = abs(dy);
    		if(da-db<0)
    		{
    			int tmp = da;
    			da = db;
    			db = tmp;
    			Z = false;
    		}
    		bool X = (dx >= 0);
    		bool Y = (dy >= 0);
    		int array[8][4] =
    		{
    			{ 0,-1,-1,-1 },
    			{ 0,-1,1,-1 },
    			{ 0,1,-1,1 },
    			{ 0,1,1,1 },
    			{ -1,0,-1,-1 },
    			{ 1,0,1,-1 },
    			{ -1,0,-1,1 },
    			{ 1,0,1,1 },
    		};
    		m = array[(X?1:0) + (Y?2:0) + (Z?4:0)];
    		int gradient = 2 * db - da;
    		int x = d1x;
    		int y = d1y;
    		setPixel(x, y);
    		for(int i = 0; i < da; i++)
    		{
    			if(gradient >= 0)
    			{
    			x = x + m[2];
    			y = y + m[3];
    			gradient = gradient + 2 * db - 2 * da;
    			}
    			else
    			{
    				x = x + m[0];
    				y = y + m[1];
    				gradient = gradient + 2 * db;
    			}
    			setPixel(x, y);
    		}
    	}
    
    	void paint()
    	{
    		PAINTSTRUCT ps;
    		HDC hdc = BeginPaint(m_hWnd, &ps);
    		HDC hdcWindow = GetWindowDC(m_hWnd);
    
    		BitBlt(hdcWindow, 0, 0, m_Size.getWidth(), m_Size.getHeight(), Bitmap.getHDC(), 0, 0, SRCCOPY);
    
    		ReleaseDC(m_hWnd, hdcWindow);
    		EndPaint(m_hWnd, &ps);
    	}
    
    private:
    	BitmapDIBUncompressed32Bit	Bitmap;
    };
    
    #endif
    


  • du meinst ein _Icon_ oder?



  • xindon schrieb:

    du meinst ein _Icon_ oder?

    aso...
    in diesem Fall musst du die Zeile:

    wndcls.hIcon            = NULL;
    

    ändern in .hIcon = LoadIcon(siehe google)



  • Mhh ok danke
    Aber ganz verstanden hab ichs net
    Also angenommen mal ich will das Programm "Hello World" mit nem Icon versehen
    Und der Path von dem Icon waere

    C:\Dokumente und Einstellungen\User\Eigene Dateien\bild.jpg

    Wie müsste dann der Quelltext dafuer aussehen?



  • Also als erstes musst du das Icon in dem Format *.ico vorliegen haben.
    Dann gehört das hier aber eher ins WinAPI Forum.

    Du solltest dich ein bischen mit WinAPI auskennen.
    Du erstellst eine *.rc Datei und bindest sie in das Programm ein.
    Dort schreibst du irgendwo hin:

    ICON_NAME_IM_PROGRAMM       ICON     "Pfad/Dateiname"
    

    Zusätzlich fügst du, wie schon in einem anderen Beitrag beschrieben bei

    wndcls.hIcon            = NULL;
    

    stattdessen

    wndcls.hIcon = LoadIcon(hInstance, "ICON_NAME_IM_PROGRAMM");
    

    ein. compilen=> fertig



  • Hallo,
    ich glaube er will irgendwie ne einfache Lösung, um in seiner IDE anstatt von dem normalen Konsolenicon ein anderes zu setzen, also bei Dev-C++ geht das unter Projektoptionen direkt beim ersten Reiter "allgemein". Bei Code::Blocks kenn ich mich jetzt nicht so aus. Das ist auch eher ne Frage fürs Compilerforum.

    MfG



  • Dieser Thread wurde von Moderator/in HumeSikkins aus dem Forum C++ in das Forum Compiler-Forum verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.


Anmelden zum Antworten