<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Bitmap in der Dialogbox auswählen, anzeigen und wieder speichern]]></title><description><![CDATA[<p>Hi,</p>
<p>ich hoffe mir kann jemand helfen. Also mein Problem:</p>
<p>Ich will aus der &quot;öffnen&quot; Dialogbox eine .bmp Fileöffnen. Soweit so gut...<br />
Er zeigt mir auch die Bitmap an. Aber sobald er das Fenster neu zeichnen will habe ich ein Problem. Entweder er öffnet dann bei jedem Neuzeichnen wieder die Dialogbox oder aber er zeichnet gar nicht neu.Ich möchte aber einfach das nach dem Öffnen der Bitmap, diese permanent angezeigt wird. Aber leider finde ich den Fehler nicht.</p>
<p>Hier erstmal der Quellcode:</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;
#include &lt;commdlg.h&gt;
#include &quot;resource.h&quot;

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
#define FILTER &quot;Bitmap (*.bmp)\0*.bmp\0\0&quot;
static OPENFILENAME ofn = {0};

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	HWND         hwnd;
	MSG          msg;
	WNDCLASSEX   wndclassex = {0};

	wndclassex.cbSize        = sizeof(WNDCLASSEX);
	static char szAppName[]= &quot;Menü Erstellung&quot;;
	wndclassex.style         = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc   = WndProc;
    wndclassex.cbClsExtra    = 0;
    wndclassex.cbWndExtra    = 0;
    wndclassex.hInstance     = hInstance;
    wndclassex.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
    wndclassex.hCursor       = LoadCursor (NULL, IDC_ARROW);
    wndclassex.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
    wndclassex.lpszMenuName  = &quot;MENU&quot;;
    wndclassex.lpszClassName = szAppName;
    wndclassex.hIconSm       = wndclassex.hIcon;
    RegisterClassEx(&amp;wndclassex);

    hwnd = CreateWindowEx (WS_EX_CLIENTEDGE, szAppName, &quot;Graphische Datenverarbeitung 2&quot;, WS_OVERLAPPEDWINDOW,
						   0, 0, 1200, 768, NULL, NULL, hInstance, NULL); 

	ShowWindow (hwnd, iCmdShow);
	UpdateWindow (hwnd);

	while (GetMessage (&amp;msg, NULL, 0, 0)==TRUE)
	{
		TranslateMessage (&amp;msg);
		DispatchMessage (&amp;msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ 
	static	int zustand=0, zustand2=0;
	char DateiName[_MAX_PATH+1] = &quot;&quot;;	 
	static HBITMAP         hBitMap; 
	static BITMAP           bitmap ;
	HDC hdc, hdcMem;
	PAINTSTRUCT ps;

	switch (message)
	{
		case WM_CREATE: 

		return 0; 

		case WM_COMMAND:
		switch(LOWORD(wParam))
		{
			case IDM_APP_EXIT:

			MessageBox(NULL, &quot;Copyright 2004 by Christian Hofferer&quot;, &quot;Auf Wiedersehen&quot;, MB_OK);
			SendMessage(hwnd, WM_CLOSE, 0, 0);
			return 0;

			case IDM_APP_SPEICHERN:

			zustand = 2;
			InvalidateRect(hwnd,NULL,TRUE);
			return 0;

			case IDM_APP_OPEN:
			zustand = 1;	
			InvalidateRect(hwnd,NULL,TRUE);
			return 0;

			case IDM_APP_ABOUT:

			MessageBox(NULL, &quot;Christian Hofferer\n658733&quot;, &quot;GDV2-Praktikum&quot;, MB_OK);
			return 0;
		}
		return 0;

		case WM_PAINT:

		hdc = BeginPaint (hwnd, &amp;ps) ; 
 		if (zustand ==1 &amp;&amp; zustand2 ==0)
		{
			ofn.lStructSize       = sizeof (OPENFILENAME) ;
			ofn.hwndOwner         = NULL;
			ofn.nMaxFile          = _MAX_PATH;
			ofn.lpstrFile         = DateiName;
			ofn.lpstrDefExt		  = &quot;bmp&quot;;
			ofn.lpstrFilter       = FILTER;
			if (GetOpenFileName(&amp;ofn))
			{

				switch (ofn.nFilterIndex)
                {
					case 1:

					break;
                }
			}
		}
		if (zustand ==1)
		{
					hBitMap = (HBITMAP)LoadImage(0, DateiName ,IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);  
			        GetObject (hBitMap, sizeof (BITMAP), &amp;bitmap);			 
					hdcMem = CreateCompatibleDC (hdc) ; 
					SelectObject (hdcMem, hBitMap) ; 
					BitBlt (hdc, 50, 50, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY) ; 
					DeleteDC (hdcMem) ;
					MessageBox(NULL, &quot;Christian Hofferer\n658733&quot;, &quot;GDV2-Praktikum&quot;, MB_OK);
					zustand2 =1;
		}

		if (zustand ==2)
		{
			ofn.lStructSize       = sizeof (OPENFILENAME) ;
			ofn.hwndOwner         = NULL;
			ofn.nMaxFile          = _MAX_PATH;
			ofn.lpstrFile         = DateiName;
			ofn.lpstrDefExt		  = &quot;bmp&quot;;
			ofn.lpstrFilter       = FILTER;
			if (GetSaveFileName(&amp;ofn))
			{
                switch (ofn.nFilterIndex)
                {
					case 1:
                    zustand =0;
                    break; 
                }
			}
			EndPaint (hwnd, &amp;ps) ; 
			return 0 ; 

			case WM_DESTROY:
			PostQuitMessage (0);
			return (0);
		}
	}
	return DefWindowProc (hwnd, message, wParam, lParam);
}
</code></pre>
<p>Dann wäre ich noch dankbar für ein paar Hinweise wo ich etwas zu den Themen Bitmap invertieren oder Bitmap als Graustufenbild ausgeben finden könnte und wie ich dies dann speichere.</p>
<p>Vielen Dank schonmal für eure Hilfe, ich dreh nämlich langsam aber sicher durch.</p>
<p>Mfg Hoffyy</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/70554/bitmap-in-der-dialogbox-auswählen-anzeigen-und-wieder-speichern</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 11:23:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/70554.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Apr 2004 17:15:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap in der Dialogbox auswählen, anzeigen und wieder speichern on Thu, 08 Apr 2004 17:15:23 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich hoffe mir kann jemand helfen. Also mein Problem:</p>
<p>Ich will aus der &quot;öffnen&quot; Dialogbox eine .bmp Fileöffnen. Soweit so gut...<br />
Er zeigt mir auch die Bitmap an. Aber sobald er das Fenster neu zeichnen will habe ich ein Problem. Entweder er öffnet dann bei jedem Neuzeichnen wieder die Dialogbox oder aber er zeichnet gar nicht neu.Ich möchte aber einfach das nach dem Öffnen der Bitmap, diese permanent angezeigt wird. Aber leider finde ich den Fehler nicht.</p>
<p>Hier erstmal der Quellcode:</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;
#include &lt;commdlg.h&gt;
#include &quot;resource.h&quot;

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
#define FILTER &quot;Bitmap (*.bmp)\0*.bmp\0\0&quot;
static OPENFILENAME ofn = {0};

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	HWND         hwnd;
	MSG          msg;
	WNDCLASSEX   wndclassex = {0};

	wndclassex.cbSize        = sizeof(WNDCLASSEX);
	static char szAppName[]= &quot;Menü Erstellung&quot;;
	wndclassex.style         = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc   = WndProc;
    wndclassex.cbClsExtra    = 0;
    wndclassex.cbWndExtra    = 0;
    wndclassex.hInstance     = hInstance;
    wndclassex.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
    wndclassex.hCursor       = LoadCursor (NULL, IDC_ARROW);
    wndclassex.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
    wndclassex.lpszMenuName  = &quot;MENU&quot;;
    wndclassex.lpszClassName = szAppName;
    wndclassex.hIconSm       = wndclassex.hIcon;
    RegisterClassEx(&amp;wndclassex);

    hwnd = CreateWindowEx (WS_EX_CLIENTEDGE, szAppName, &quot;Graphische Datenverarbeitung 2&quot;, WS_OVERLAPPEDWINDOW,
						   0, 0, 1200, 768, NULL, NULL, hInstance, NULL); 

	ShowWindow (hwnd, iCmdShow);
	UpdateWindow (hwnd);

	while (GetMessage (&amp;msg, NULL, 0, 0)==TRUE)
	{
		TranslateMessage (&amp;msg);
		DispatchMessage (&amp;msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ 
	static	int zustand=0, zustand2=0;
	char DateiName[_MAX_PATH+1] = &quot;&quot;;	 
	static HBITMAP         hBitMap; 
	static BITMAP           bitmap ;
	HDC hdc, hdcMem;
	PAINTSTRUCT ps;

	switch (message)
	{
		case WM_CREATE: 

		return 0; 

		case WM_COMMAND:
		switch(LOWORD(wParam))
		{
			case IDM_APP_EXIT:

			MessageBox(NULL, &quot;Copyright 2004 by Christian Hofferer&quot;, &quot;Auf Wiedersehen&quot;, MB_OK);
			SendMessage(hwnd, WM_CLOSE, 0, 0);
			return 0;

			case IDM_APP_SPEICHERN:

			zustand = 2;
			InvalidateRect(hwnd,NULL,TRUE);
			return 0;

			case IDM_APP_OPEN:
			zustand = 1;	
			InvalidateRect(hwnd,NULL,TRUE);
			return 0;

			case IDM_APP_ABOUT:

			MessageBox(NULL, &quot;Christian Hofferer\n658733&quot;, &quot;GDV2-Praktikum&quot;, MB_OK);
			return 0;
		}
		return 0;

		case WM_PAINT:

		hdc = BeginPaint (hwnd, &amp;ps) ; 
 		if (zustand ==1 &amp;&amp; zustand2 ==0)
		{
			ofn.lStructSize       = sizeof (OPENFILENAME) ;
			ofn.hwndOwner         = NULL;
			ofn.nMaxFile          = _MAX_PATH;
			ofn.lpstrFile         = DateiName;
			ofn.lpstrDefExt		  = &quot;bmp&quot;;
			ofn.lpstrFilter       = FILTER;
			if (GetOpenFileName(&amp;ofn))
			{

				switch (ofn.nFilterIndex)
                {
					case 1:

					break;
                }
			}
		}
		if (zustand ==1)
		{
					hBitMap = (HBITMAP)LoadImage(0, DateiName ,IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);  
			        GetObject (hBitMap, sizeof (BITMAP), &amp;bitmap);			 
					hdcMem = CreateCompatibleDC (hdc) ; 
					SelectObject (hdcMem, hBitMap) ; 
					BitBlt (hdc, 50, 50, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY) ; 
					DeleteDC (hdcMem) ;
					MessageBox(NULL, &quot;Christian Hofferer\n658733&quot;, &quot;GDV2-Praktikum&quot;, MB_OK);
					zustand2 =1;
		}

		if (zustand ==2)
		{
			ofn.lStructSize       = sizeof (OPENFILENAME) ;
			ofn.hwndOwner         = NULL;
			ofn.nMaxFile          = _MAX_PATH;
			ofn.lpstrFile         = DateiName;
			ofn.lpstrDefExt		  = &quot;bmp&quot;;
			ofn.lpstrFilter       = FILTER;
			if (GetSaveFileName(&amp;ofn))
			{
                switch (ofn.nFilterIndex)
                {
					case 1:
                    zustand =0;
                    break; 
                }
			}
			EndPaint (hwnd, &amp;ps) ; 
			return 0 ; 

			case WM_DESTROY:
			PostQuitMessage (0);
			return (0);
		}
	}
	return DefWindowProc (hwnd, message, wParam, lParam);
}
</code></pre>
<p>Dann wäre ich noch dankbar für ein paar Hinweise wo ich etwas zu den Themen Bitmap invertieren oder Bitmap als Graustufenbild ausgeben finden könnte und wie ich dies dann speichere.</p>
<p>Vielen Dank schonmal für eure Hilfe, ich dreh nämlich langsam aber sicher durch.</p>
<p>Mfg Hoffyy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/497818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/497818</guid><dc:creator><![CDATA[Hoffyyy]]></dc:creator><pubDate>Thu, 08 Apr 2004 17:15:23 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap in der Dialogbox auswählen, anzeigen und wieder speichern on Thu, 08 Apr 2004 17:46:41 GMT]]></title><description><![CDATA[<p>Hoffyyy schrieb:</p>
<blockquote>
<p>Hi,</p>
<p>ich hoffe mir kann jemand helfen. Also mein Problem:</p>
<p>Ich will aus der &quot;öffnen&quot; Dialogbox eine .bmp Fileöffnen. Soweit so gut...<br />
Er zeigt mir auch die Bitmap an. Aber sobald er das Fenster neu zeichnen will habe ich ein Problem. Entweder er öffnet dann bei jedem Neuzeichnen wieder die Dialogbox oder aber er zeichnet gar nicht neu.Ich möchte aber einfach das nach dem Öffnen der Bitmap, diese permanent angezeigt wird. Aber leider finde ich den Fehler nicht.</p>
</blockquote>
<p>Das Problem liegt offensichtlich bei den Zustandsvariablen. Wenn &quot;zustand&quot; '1' ist, wird nicht dafür gesorgt, dass es einen anderen Wert hat. Somit würde nämlich der if-Block, der &quot;zustand&quot; auf den Wert '1' abprüft, nicht mehr ausgeführt werden. Das erinnert mich an einen User, der erst vor Kurzem ein ähnliches Problem hatte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/497841</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/497841</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Thu, 08 Apr 2004 17:46:41 GMT</pubDate></item></channel></rss>