<?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[Variablen werden unbemerkt verändert]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich bin gerade dabei einen native Viewer für mein Fotoalbum Virtual Photo Organizer zu schreiben. Beim Bildbetrachtungsfenster bin ich auf ein paar Probleme gestoßen. Alle HWNDs sind bei mir Teile von Klassen, die WndProc s sind dabei static. Ich habe zwei private int Vars (PbClientWidth und PbClientHeight) um die Dimensionen eines Fensters zu speichern, d.h. diese Variablen werden nur in einer WndProc in der WM_SIZE message verändert. Wenn ich diese Variablen nachher in einer von WM_PAINT aufgerufenen Methode auslese haben sie andere Werte als ihnen bei WM_SIZE zugewiesen wurden.</p>
<p>Hier ist der zugehörige Code:<br />
PhotoViewer.h</p>
<pre><code class="language-cpp">#ifndef PHOTO_VIEWER_H
#define PHOTO_VIEWER_H
#pragma once

#include &quot;Photo.h&quot;
#include &quot;Collection.h&quot;
#include &quot;Bitmap.h&quot;

#define MAXZOOM 48

class PhotoViewer
{
public:
	PhotoViewer(Collection&lt;Photo *&gt; *photos, int index, HINSTANCE hInstance);
	~PhotoViewer(void);
	void Show();
	static LRESULT CALLBACK ParentWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK PhotoBoxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
private:
	static PhotoViewer *pThis;
	HWND hParent, hPhotoBox, hInfoPane;
	HINSTANCE hInst;
	Collection&lt;Photo *&gt; *Photos;
	Bitmap *Image;
	RECT ImgRect;
	HCURSOR hDefault, hCross;
	POINT MousePos;
	bool Zooming;
	int ZoomLevel;
	int PbClientWidth, PbClientHeight, SbWidth, SbHeight;
	bool VSbVisible;
	bool HSbVisible;
	int CurrIndex;
	void LoadPhoto();
	void DrawPhoto(HDC hdc);
	void NextPhoto();
	void PrevPhoto();
	bool SetCursorIcon();
	void ZoomIn();
	void ZoomOut();
	RECT GetZoomedRect();
	static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
};

#endif
</code></pre>
<p>PhotoViewer.cpp</p>
<pre><code class="language-cpp">#include &quot;StdAfx.h&quot;
#include &quot;PhotoViewer.h&quot;
#include &quot;Resource.h&quot;

#define PANEWIDTH 443
#define PANEHEIGHT 154
#define SBHEIGHT 17

PhotoViewer::PhotoViewer(Collection&lt;Photo *&gt; *photos, int index, HINSTANCE hInstance) {
	Photos = photos;
	CurrIndex = index;
	hInst = hInstance;
	Zooming = false;
	ZoomLevel = 0;
	hParent = NULL;
	hPhotoBox = NULL;
	hInfoPane = NULL;
	Image = NULL;
	PbClientHeight = 0;
	PbClientWidth = 0;
	HSbVisible = false;
	VSbVisible = false;
	SbWidth = 0;
	SbHeight = 0;
	hDefault = LoadCursor(NULL, IDC_ARROW);
	hCross = LoadCursor(NULL, IDC_CROSS);
}

PhotoViewer::~PhotoViewer(void) {
	if (hInfoPane)
		DestroyWindow(hInfoPane);
	if (hPhotoBox)
		DestroyWindow(hPhotoBox);
	if (hParent)
		DestroyWindow(hParent);
	if (Image)
		delete Image;
}

void PhotoViewer::Show() {
	LoadPhoto();
	hParent = CreateWindow(C_PHOTOVIEWER, &quot;&quot;, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, PANEWIDTH, 500, NULL, NULL, hInst, NULL);
	SetWindowLongPtr(hParent, GWLP_USERDATA, (LONG_PTR) this);
	hPhotoBox = CreateWindow(C_PHOTOBOX, &quot;&quot;, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, 0, 0, PANEWIDTH, 100, hParent, NULL, hInst, (LPVOID) this);
	hInfoPane = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PVIEWERPANE), hParent, this-&gt;DlgProc, (LPARAM) this);
	ShowWindow(hParent, SW_SHOW);
}

LRESULT CALLBACK PhotoViewer::ParentWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
	PhotoViewer *pv = (PhotoViewer *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message) {
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &amp;ps);
			EndPaint(hWnd, &amp;ps);
			break;
		case WM_SIZE: {
				int cx = LOWORD(lParam);
				int cy = HIWORD(lParam) - PANEHEIGHT;
				MoveWindow(pv-&gt;hPhotoBox, 0, 0, cx, cy, TRUE);
				//MoveWindow(pv-&gt;hInfoPane, (cx - PANEWIDTH) / 2, cy, PANEWIDTH, PANEHEIGHT, TRUE);  
			}
			break;
		case WM_CLOSE:
			delete pv;
			return DefWindowProc(hWnd, message, wParam, lParam);                   
		default: return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

LRESULT CALLBACK PhotoViewer::PhotoBoxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
	PhotoViewer *pv = (PhotoViewer *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message) {
		case WM_CREATE:
			SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
			break;
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &amp;ps);
			pv-&gt;DrawPhoto(hdc);
			EndPaint(hWnd, &amp;ps);
			break;
		case WM_SIZE:
			pv-&gt;PbClientWidth = LOWORD(lParam);
			pv-&gt;PbClientHeight = HIWORD(lParam);
			break;
		case WM_LBUTTONUP:
			if (pv-&gt;SetCursorIcon())
				pv-&gt;ZoomIn();
			break;
		case WM_RBUTTONUP:
			if (pv-&gt;SetCursorIcon())
				pv-&gt;ZoomOut();
			break;
		case WM_MOUSEMOVE:
			pv-&gt;MousePos.x = LOWORD(lParam);
			pv-&gt;MousePos.y = HIWORD(lParam);
			pv-&gt;SetCursorIcon();
			break;
		default: return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

void PhotoViewer::DrawPhoto(HDC hdc) {
	if (PbClientWidth == 0 || PbClientHeight == 0)
		return;
	if (!Zooming) {
		if ((Image-&gt;GetWidth() &gt; PbClientWidth) || (Image-&gt;GetHeight() &gt; PbClientHeight)) {
			// photo is larger than screen
			double ratio = Image-&gt;GetHeight() / Image-&gt;GetHeight();
			if (ratio &lt; (PbClientHeight / PbClientWidth)) {
				// width is constant
				int height = (Image-&gt;GetHeight() * PbClientWidth) / Image-&gt;GetWidth();
				ImgRect.left = 0;
				ImgRect.top = (PbClientHeight - height) / 2;
				ImgRect.right = PbClientWidth;
				ImgRect.bottom = ImgRect.top + height;
			} else {
				// height is constant
				int width = (Image-&gt;GetWidth() * PbClientHeight) / Image-&gt;GetHeight();
				ImgRect.top = 0;
				ImgRect.left = (PbClientWidth - width) / 2;
				ImgRect.right = ImgRect.left + width;
				ImgRect.bottom = PbClientHeight;
			}
		} else {
			// just calculate offset
			ImgRect.top = (PbClientHeight - Image-&gt;GetHeight()) / 2;
			ImgRect.left = (PbClientWidth - Image-&gt;GetWidth()) / 2;
			ImgRect.right = ImgRect.left + Image-&gt;GetWidth();
			ImgRect.bottom = ImgRect.top + Image-&gt;GetHeight();
		}
	} else {
		// draw zoomed version
		RECT area = this-&gt;GetZoomedRect();
		// check if image is still smaller than client area
		int width = Image-&gt;GetWidth() * ZoomLevel;
		int height = Image-&gt;GetHeight() * ZoomLevel;
		if (width &lt; PbClientWidth) {
			ImgRect.left = (PbClientWidth - width) / 2;
			ImgRect.right = ImgRect.left + width;
		} else {
			ImgRect.left = 0;
			ImgRect.right = PbClientWidth;
		}
		if (height &lt; PbClientHeight) {
			ImgRect.top = (PbClientHeight - height) / 2;
			ImgRect.bottom = ImgRect.top + height;
		} else {
			ImgRect.top = 0;
			ImgRect.bottom = PbClientHeight;
		}
	}
	RECT drawArea;
	drawArea.left = 0;
	drawArea.top = 0;
	drawArea.right = PbClientWidth;
	drawArea.bottom = PbClientHeight;
	Image-&gt;Draw(hdc, &amp;ImgRect, &amp;drawArea);
}
</code></pre>
<p>Ich bin dankbar für jeden Lösungsansatz.</p>
<p>*EDIT: unnötiger Code entfernt<br />
*EDIT 2: Wer den vollständigen Code braucht: <a href="http://tommazzo.com/misc/PhotoViewer.cpp" rel="nofollow">http://tommazzo.com/misc/PhotoViewer.cpp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118271/variablen-werden-unbemerkt-verändert</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 18:29:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118271.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Aug 2005 21:46:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Variablen werden unbemerkt verändert on Tue, 16 Aug 2005 22:01:48 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich bin gerade dabei einen native Viewer für mein Fotoalbum Virtual Photo Organizer zu schreiben. Beim Bildbetrachtungsfenster bin ich auf ein paar Probleme gestoßen. Alle HWNDs sind bei mir Teile von Klassen, die WndProc s sind dabei static. Ich habe zwei private int Vars (PbClientWidth und PbClientHeight) um die Dimensionen eines Fensters zu speichern, d.h. diese Variablen werden nur in einer WndProc in der WM_SIZE message verändert. Wenn ich diese Variablen nachher in einer von WM_PAINT aufgerufenen Methode auslese haben sie andere Werte als ihnen bei WM_SIZE zugewiesen wurden.</p>
<p>Hier ist der zugehörige Code:<br />
PhotoViewer.h</p>
<pre><code class="language-cpp">#ifndef PHOTO_VIEWER_H
#define PHOTO_VIEWER_H
#pragma once

#include &quot;Photo.h&quot;
#include &quot;Collection.h&quot;
#include &quot;Bitmap.h&quot;

#define MAXZOOM 48

class PhotoViewer
{
public:
	PhotoViewer(Collection&lt;Photo *&gt; *photos, int index, HINSTANCE hInstance);
	~PhotoViewer(void);
	void Show();
	static LRESULT CALLBACK ParentWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
	static LRESULT CALLBACK PhotoBoxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
private:
	static PhotoViewer *pThis;
	HWND hParent, hPhotoBox, hInfoPane;
	HINSTANCE hInst;
	Collection&lt;Photo *&gt; *Photos;
	Bitmap *Image;
	RECT ImgRect;
	HCURSOR hDefault, hCross;
	POINT MousePos;
	bool Zooming;
	int ZoomLevel;
	int PbClientWidth, PbClientHeight, SbWidth, SbHeight;
	bool VSbVisible;
	bool HSbVisible;
	int CurrIndex;
	void LoadPhoto();
	void DrawPhoto(HDC hdc);
	void NextPhoto();
	void PrevPhoto();
	bool SetCursorIcon();
	void ZoomIn();
	void ZoomOut();
	RECT GetZoomedRect();
	static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
};

#endif
</code></pre>
<p>PhotoViewer.cpp</p>
<pre><code class="language-cpp">#include &quot;StdAfx.h&quot;
#include &quot;PhotoViewer.h&quot;
#include &quot;Resource.h&quot;

#define PANEWIDTH 443
#define PANEHEIGHT 154
#define SBHEIGHT 17

PhotoViewer::PhotoViewer(Collection&lt;Photo *&gt; *photos, int index, HINSTANCE hInstance) {
	Photos = photos;
	CurrIndex = index;
	hInst = hInstance;
	Zooming = false;
	ZoomLevel = 0;
	hParent = NULL;
	hPhotoBox = NULL;
	hInfoPane = NULL;
	Image = NULL;
	PbClientHeight = 0;
	PbClientWidth = 0;
	HSbVisible = false;
	VSbVisible = false;
	SbWidth = 0;
	SbHeight = 0;
	hDefault = LoadCursor(NULL, IDC_ARROW);
	hCross = LoadCursor(NULL, IDC_CROSS);
}

PhotoViewer::~PhotoViewer(void) {
	if (hInfoPane)
		DestroyWindow(hInfoPane);
	if (hPhotoBox)
		DestroyWindow(hPhotoBox);
	if (hParent)
		DestroyWindow(hParent);
	if (Image)
		delete Image;
}

void PhotoViewer::Show() {
	LoadPhoto();
	hParent = CreateWindow(C_PHOTOVIEWER, &quot;&quot;, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, PANEWIDTH, 500, NULL, NULL, hInst, NULL);
	SetWindowLongPtr(hParent, GWLP_USERDATA, (LONG_PTR) this);
	hPhotoBox = CreateWindow(C_PHOTOBOX, &quot;&quot;, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, 0, 0, PANEWIDTH, 100, hParent, NULL, hInst, (LPVOID) this);
	hInfoPane = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PVIEWERPANE), hParent, this-&gt;DlgProc, (LPARAM) this);
	ShowWindow(hParent, SW_SHOW);
}

LRESULT CALLBACK PhotoViewer::ParentWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
	PhotoViewer *pv = (PhotoViewer *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message) {
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &amp;ps);
			EndPaint(hWnd, &amp;ps);
			break;
		case WM_SIZE: {
				int cx = LOWORD(lParam);
				int cy = HIWORD(lParam) - PANEHEIGHT;
				MoveWindow(pv-&gt;hPhotoBox, 0, 0, cx, cy, TRUE);
				//MoveWindow(pv-&gt;hInfoPane, (cx - PANEWIDTH) / 2, cy, PANEWIDTH, PANEHEIGHT, TRUE);  
			}
			break;
		case WM_CLOSE:
			delete pv;
			return DefWindowProc(hWnd, message, wParam, lParam);                   
		default: return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

LRESULT CALLBACK PhotoViewer::PhotoBoxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
	PhotoViewer *pv = (PhotoViewer *) GetWindowLongPtr(hWnd, GWLP_USERDATA);
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message) {
		case WM_CREATE:
			SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
			break;
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &amp;ps);
			pv-&gt;DrawPhoto(hdc);
			EndPaint(hWnd, &amp;ps);
			break;
		case WM_SIZE:
			pv-&gt;PbClientWidth = LOWORD(lParam);
			pv-&gt;PbClientHeight = HIWORD(lParam);
			break;
		case WM_LBUTTONUP:
			if (pv-&gt;SetCursorIcon())
				pv-&gt;ZoomIn();
			break;
		case WM_RBUTTONUP:
			if (pv-&gt;SetCursorIcon())
				pv-&gt;ZoomOut();
			break;
		case WM_MOUSEMOVE:
			pv-&gt;MousePos.x = LOWORD(lParam);
			pv-&gt;MousePos.y = HIWORD(lParam);
			pv-&gt;SetCursorIcon();
			break;
		default: return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

void PhotoViewer::DrawPhoto(HDC hdc) {
	if (PbClientWidth == 0 || PbClientHeight == 0)
		return;
	if (!Zooming) {
		if ((Image-&gt;GetWidth() &gt; PbClientWidth) || (Image-&gt;GetHeight() &gt; PbClientHeight)) {
			// photo is larger than screen
			double ratio = Image-&gt;GetHeight() / Image-&gt;GetHeight();
			if (ratio &lt; (PbClientHeight / PbClientWidth)) {
				// width is constant
				int height = (Image-&gt;GetHeight() * PbClientWidth) / Image-&gt;GetWidth();
				ImgRect.left = 0;
				ImgRect.top = (PbClientHeight - height) / 2;
				ImgRect.right = PbClientWidth;
				ImgRect.bottom = ImgRect.top + height;
			} else {
				// height is constant
				int width = (Image-&gt;GetWidth() * PbClientHeight) / Image-&gt;GetHeight();
				ImgRect.top = 0;
				ImgRect.left = (PbClientWidth - width) / 2;
				ImgRect.right = ImgRect.left + width;
				ImgRect.bottom = PbClientHeight;
			}
		} else {
			// just calculate offset
			ImgRect.top = (PbClientHeight - Image-&gt;GetHeight()) / 2;
			ImgRect.left = (PbClientWidth - Image-&gt;GetWidth()) / 2;
			ImgRect.right = ImgRect.left + Image-&gt;GetWidth();
			ImgRect.bottom = ImgRect.top + Image-&gt;GetHeight();
		}
	} else {
		// draw zoomed version
		RECT area = this-&gt;GetZoomedRect();
		// check if image is still smaller than client area
		int width = Image-&gt;GetWidth() * ZoomLevel;
		int height = Image-&gt;GetHeight() * ZoomLevel;
		if (width &lt; PbClientWidth) {
			ImgRect.left = (PbClientWidth - width) / 2;
			ImgRect.right = ImgRect.left + width;
		} else {
			ImgRect.left = 0;
			ImgRect.right = PbClientWidth;
		}
		if (height &lt; PbClientHeight) {
			ImgRect.top = (PbClientHeight - height) / 2;
			ImgRect.bottom = ImgRect.top + height;
		} else {
			ImgRect.top = 0;
			ImgRect.bottom = PbClientHeight;
		}
	}
	RECT drawArea;
	drawArea.left = 0;
	drawArea.top = 0;
	drawArea.right = PbClientWidth;
	drawArea.bottom = PbClientHeight;
	Image-&gt;Draw(hdc, &amp;ImgRect, &amp;drawArea);
}
</code></pre>
<p>Ich bin dankbar für jeden Lösungsansatz.</p>
<p>*EDIT: unnötiger Code entfernt<br />
*EDIT 2: Wer den vollständigen Code braucht: <a href="http://tommazzo.com/misc/PhotoViewer.cpp" rel="nofollow">http://tommazzo.com/misc/PhotoViewer.cpp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/853746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853746</guid><dc:creator><![CDATA[tommazzo]]></dc:creator><pubDate>Tue, 16 Aug 2005 22:01:48 GMT</pubDate></item><item><title><![CDATA[Reply to Variablen werden unbemerkt verändert on Tue, 16 Aug 2005 21:54:14 GMT]]></title><description><![CDATA[<p>Warum postest du hier soviel Code der nix mit dem Problem zu tun hat? Oder kann man da nix mehr minimieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853750</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853750</guid><dc:creator><![CDATA[minimalistic]]></dc:creator><pubDate>Tue, 16 Aug 2005 21:54:14 GMT</pubDate></item><item><title><![CDATA[Reply to Variablen werden unbemerkt verändert on Tue, 16 Aug 2005 22:00:16 GMT]]></title><description><![CDATA[<p>Du hast Recht. Ich habe den Code, der sicher nichts mit dem Problem zu tun hat jetzt entfernt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853753</guid><dc:creator><![CDATA[tommazzo]]></dc:creator><pubDate>Tue, 16 Aug 2005 22:00:16 GMT</pubDate></item><item><title><![CDATA[Reply to Variablen werden unbemerkt verändert on Wed, 17 Aug 2005 08:42:34 GMT]]></title><description><![CDATA[<p>Kein Ahnung ob das mit deinem Problem zu tun hat aber diese zeile kommt mir ziemlich sinnlos vor.</p>
<pre><code class="language-cpp">double ratio = Image-&gt;GetHeight() / Image-&gt;GetHeight();
</code></pre>
<p>und bei der folgenden Zeile</p>
<pre><code class="language-cpp">if (ratio &lt; (PbClientHeight / PbClientWidth)) {
</code></pre>
<p>wirst du PbClientHeight und PbClientWidth nach double casten müssen um ein vernünftiges Ergebnis zu bekommen.<br />
Hoffe das hilft dir weiter.<br />
Kurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853927</guid><dc:creator><![CDATA[ZuK]]></dc:creator><pubDate>Wed, 17 Aug 2005 08:42:34 GMT</pubDate></item><item><title><![CDATA[Reply to Variablen werden unbemerkt verändert on Wed, 17 Aug 2005 08:58:42 GMT]]></title><description><![CDATA[<p>Die beiden Stellen haben zwar wirklich nichts mit dem Problem zu tun, aber trotzdem danke für den Hinweis (das mit ratio war ein kleiner Tippfehler meinerseits).</p>
<p>Was das eigentliche Problem angeht, so bin ich der Lösung schon näher gekommen. Ich habe einen statischen This Pointer in die Klasse eingefügt, der im ctor initialisiert wird. Wenn ich nun das Ergebnis von GetWindowLongPtr(hPhotoBox, GWLP_USERDATA) in einen PhotoViewer Pointer caste, stimmt die Memoryadresse nicht mit der des statischen This Pointers überein. Folglich muss ich bei CreateWindow() den this Pointer irgendwie falsch übergeben, sodass er nicht korrekt gespeichert wird. Die Frage ist nun, wie übergebe ich ihn richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853951</guid><dc:creator><![CDATA[tommazzo]]></dc:creator><pubDate>Wed, 17 Aug 2005 08:58:42 GMT</pubDate></item><item><title><![CDATA[Reply to Variablen werden unbemerkt verändert on Wed, 17 Aug 2005 09:25:24 GMT]]></title><description><![CDATA[<p>Problem gelöst!</p>
<p>Geholfen hat mir hierbei ein <a href="http://blogs.msdn.com/oldnewthing/archive/2005/04/22/410773.aspx" rel="nofollow">Eintrag</a> in Raymond Chens Blog.<br />
Dank Mr. Chen weiß ich nun, dass (im Gegensatz zu Dialogen) bei WM_CREATE messages von HWNDs in lParam eine LPCREATESTRUCT drinnensteckt und nicht einfach der Parameter, der bei CreateWindow() übergeben wurde.<br />
Alles was schlussendlich nötig ist um die Klasse zum funktionieren zu bringen ist folgende Änderung bei WM_CREATE in PhotoBoxWndProc():</p>
<pre><code class="language-cpp">case WM_CREATE: {
			LPCREATESTRUCT create = (LPCREATESTRUCT) lParam;
			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG) create-&gt;lpCreateParams);
			}
			break;
</code></pre>
<p>Danke an alle, die mir helfen wollten!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853998</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853998</guid><dc:creator><![CDATA[tommazzo]]></dc:creator><pubDate>Wed, 17 Aug 2005 09:25:24 GMT</pubDate></item></channel></rss>