<?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[Uhr Geht Falsch]]></title><description><![CDATA[<p>Also ich will/habe mir eine Stopuhr programmiert.<br />
Diese Uhr soll/zeigt milisecunden, secunden und minuten an.<br />
Und das sobald man auf die Lehrtase trückt.<br />
Leider nicht ganz richtig.</p>
<p>Der zuständige teil sieht so aus.</p>
<pre><code class="language-cpp">switch(wParam)
				{
					case VK_SPACE:
					{
						isActive = !isActive;

						if(isActive)
						{
							SetTimer(hWnd, TimerID, 1, NULL);
						}
						else
						{
							KillTimer(hWnd, TimerID);
						}
						return 0;
					}
</code></pre>
<p>isActive prüft ob die lehrtase gedrückt wurde.<br />
Standartmäßig so:<br />
bool isActive = false;</p>
<p>jetzt sollte der Timer ja alle milisec eine nachricht schicken.<br />
Tut er aber nicht. Denn eine sec in meinem Programm entspricht nicht einer real sec.<br />
Woran kann das liegen?<br />
So sieht meine rechnung aus.</p>
<pre><code class="language-cpp">case WM_TIMER:
			{
				if(iMSec &lt; 1000)
				{
					iMSec++;
				}
				else if(iSec &lt; 60)
				{
					iSec++;
					if(iSec &gt; 59)
					{
						iMin++;
						iSec = 0;
					}
					iMSec = 0;
				}
				else
				{
				}
				InvalidateRect(hWnd, NULL, TRUE);
				return 0;	
			}
</code></pre>
<p>wenn ich SetTimer(hWnd, TimerID, 1, NULL); nehme und nur sec und min ausgeben lasse stimmt es wieder...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161192/uhr-geht-falsch</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 10:31:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161192.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Oct 2006 10:58:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Uhr Geht Falsch on Wed, 04 Oct 2006 10:58:19 GMT]]></title><description><![CDATA[<p>Also ich will/habe mir eine Stopuhr programmiert.<br />
Diese Uhr soll/zeigt milisecunden, secunden und minuten an.<br />
Und das sobald man auf die Lehrtase trückt.<br />
Leider nicht ganz richtig.</p>
<p>Der zuständige teil sieht so aus.</p>
<pre><code class="language-cpp">switch(wParam)
				{
					case VK_SPACE:
					{
						isActive = !isActive;

						if(isActive)
						{
							SetTimer(hWnd, TimerID, 1, NULL);
						}
						else
						{
							KillTimer(hWnd, TimerID);
						}
						return 0;
					}
</code></pre>
<p>isActive prüft ob die lehrtase gedrückt wurde.<br />
Standartmäßig so:<br />
bool isActive = false;</p>
<p>jetzt sollte der Timer ja alle milisec eine nachricht schicken.<br />
Tut er aber nicht. Denn eine sec in meinem Programm entspricht nicht einer real sec.<br />
Woran kann das liegen?<br />
So sieht meine rechnung aus.</p>
<pre><code class="language-cpp">case WM_TIMER:
			{
				if(iMSec &lt; 1000)
				{
					iMSec++;
				}
				else if(iSec &lt; 60)
				{
					iSec++;
					if(iSec &gt; 59)
					{
						iMin++;
						iSec = 0;
					}
					iMSec = 0;
				}
				else
				{
				}
				InvalidateRect(hWnd, NULL, TRUE);
				return 0;	
			}
</code></pre>
<p>wenn ich SetTimer(hWnd, TimerID, 1, NULL); nehme und nur sec und min ausgeben lasse stimmt es wieder...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149132</guid><dc:creator><![CDATA[Sqwan]]></dc:creator><pubDate>Wed, 04 Oct 2006 10:58:19 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Wed, 04 Oct 2006 11:04:46 GMT]]></title><description><![CDATA[<p>Windows hat eine Auflösung von maximal 10ms, wenn nicht mehr, und ist ausserdem kein Echtzeitsystem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149136</guid><dc:creator><![CDATA[THX 1138]]></dc:creator><pubDate>Wed, 04 Oct 2006 11:04:46 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Wed, 04 Oct 2006 11:15:41 GMT]]></title><description><![CDATA[<p>Naja aus erfahrung weiss ich,<br />
dass solche Programme nicht Praxisfähig sind,<br />
ein kleiner &quot;Lag&quot; durch z.B. den Virenscanner<br />
und das Programm &quot;geht falsch&quot;</p>
<p>Versuch die Zeit vom System auszulesen,<br />
und die millisekunden dazuzuzählen, dann ist die Abweichung<br />
minimal...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149142</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149142</guid><dc:creator><![CDATA[Listing]]></dc:creator><pubDate>Wed, 04 Oct 2006 11:15:41 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Wed, 04 Oct 2006 12:37:18 GMT]]></title><description><![CDATA[<p>Multimedia Timer haben ne Auflösung von 1 Sekunde, die eignen sich da für eher.</p>
<p>Siehe:<br />
timeSetEvent()<br />
timeKillEvent()</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149217</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Wed, 04 Oct 2006 12:37:18 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Wed, 04 Oct 2006 14:44:08 GMT]]></title><description><![CDATA[<p>Ich meine die Milisec sind eh unrelevant. Am ende sollen eh nur 30 sec runtergezählt werden. Die stopuhr sollte nur eine Übung sein in der ich gcuke wie ich das mit der zeit am besten umsetze. ich habe am ende ein kleines fenster in das man klicken soll.<br />
Klickt man rein zählt es die klicks. man hat 30 sec zeit so viel zu klicken wie möglich.</p>
<p>Das problem zeit is auch eher klein. Wenn Milisec nicht gehen, is das net schlimm weil ich die eh nicht brauche.</p>
<p>viel schlimmer ist was anderes.<br />
Und zwar werden die Klicks zwar gezählt aber nicht ausgegeben. Ausgeben werden die erst wenn man das fenster klein macht und dann wieder öfnet.<br />
hat einer ne ahnung woran das liegen kann?</p>
<p>Hier mal mein script...</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

int i = 0;
const UINT sizeX = 300;
const UINT sizeY = 300;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{

		case WM_PAINT:
		{
			PAINTSTRUCT   ps;
			HDC           hDC;
			SIZE          size;
			char sTime[30];
			int iLength;

			iLength = wsprintf(sTime, &quot;Sie haben %i mal geklickt&quot;, i);

			hDC = BeginPaint(hWnd, &amp;ps);
			{
				GetTextExtentPoint32(hDC, sTime, iLength, &amp;size);

				TextOut(hDC, 100, 100, sTime, iLength);
			}
			EndPaint(hWnd, &amp;ps);         
			return 0;
		}
		case WM_LBUTTONDOWN:
		{
			i++;
			SendMessage(hWnd, WM_PAINT, 0, 0);
		}
		break;
		case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		}
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
   HWND         hWnd;
   MSG          msg;
   WNDCLASS     wc;

   char         szAppName[] = &quot;CountClick&quot;;

   wc.cbClsExtra          = 0;
   wc.cbWndExtra          = 0;
   wc.hbrBackground       = (HBRUSH)GetStockObject(WHITE_BRUSH);
   wc.hCursor             = LoadCursor(NULL, IDC_ARROW);
   wc.hIcon               = LoadIcon(NULL, IDI_APPLICATION);
   wc.hInstance           = hInstance;
   wc.lpfnWndProc         = WndProc;
   wc.lpszClassName       = szAppName;
   wc.lpszMenuName        = NULL;
   wc.style               = CS_HREDRAW | CS_VREDRAW;

   RegisterClass(&amp;wc);

   hWnd = CreateWindow(  szAppName,
                         szAppName,
                         WS_SYSMENU,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         sizeX,
                         sizeY,
                         NULL,
                         NULL,
                         hInstance,
                         NULL);

   ShowWindow(hWnd, iCmdShow);
   UpdateWindow(hWnd);

   while (GetMessage(&amp;msg, NULL, 0, 0))
   {
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
   }

   return msg.wParam;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1149318</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149318</guid><dc:creator><![CDATA[Sqwan]]></dc:creator><pubDate>Wed, 04 Oct 2006 14:44:08 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Wed, 04 Oct 2006 16:48:49 GMT]]></title><description><![CDATA[<p>statt SendMessage(hWnd, WM_PAINT, 0, 0); musst du <a href="http://msdn.microsoft.com/library/en-us/gdi/pantdraw_7ano.asp" rel="nofollow">InvalidateRect</a> aufrufen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149388</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Wed, 04 Oct 2006 16:48:49 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Wed, 04 Oct 2006 19:09:00 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> Hätte ich auch selber merken können...<br />
InvalidateRect(hWnd, NULL, FALSE); hats getan.<br />
Funzt jetzt...</p>
<p>THX</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149463</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149463</guid><dc:creator><![CDATA[Sqwan]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Thu, 05 Oct 2006 04:50:07 GMT]]></title><description><![CDATA[<p>Ähm der Aufruf von:</p>
<pre><code class="language-cpp">GetTextExtentPoint32(hDC, sTime, iLength, &amp;size);
</code></pre>
<p>Ist irgendwie überflüssig :p .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149622</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 05 Oct 2006 04:50:07 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Thu, 05 Oct 2006 08:08:23 GMT]]></title><description><![CDATA[<p>Wenn ich jezt noch die schrift größe ändern möchte bräuchte ich den doch oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149706</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149706</guid><dc:creator><![CDATA[Sqwan]]></dc:creator><pubDate>Thu, 05 Oct 2006 08:08:23 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Thu, 05 Oct 2006 08:12:28 GMT]]></title><description><![CDATA[<p>Jo, wenn du ihn auch noch richtig benutzt, dann ja <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149710</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 05 Oct 2006 08:12:28 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Thu, 05 Oct 2006 08:48:30 GMT]]></title><description><![CDATA[<p>ja an der richtigen verwendung arbeite ich nich. <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="🙂"
    /><br />
Wenn ich da einfach ne Zahl rein setzte sacht er mir<br />
das eine convertierung von const int in struct HDC__ * nicht möglich ist.</p>
<p>Mal sehen was google dazu sagt...</p>
<p>EDIT:<br />
Ok. Ich versuche das ding grade für was ganz falsches zu benutzen...<br />
ich lasse es weg....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149716</guid><dc:creator><![CDATA[Sqwan]]></dc:creator><pubDate>Thu, 05 Oct 2006 08:48:30 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Thu, 05 Oct 2006 09:00:07 GMT]]></title><description><![CDATA[<p>Sqwan schrieb:</p>
<blockquote>
<p>EDIT:<br />
Ok. Ich versuche das ding grade für was ganz falsches zu benutzen...<br />
ich lasse es weg....</p>
</blockquote>
<p>Also, wenn du mit sagst, was du erreichen willst, kann ich dir vllt helfen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149739</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 05 Oct 2006 09:00:07 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Thu, 05 Oct 2006 09:08:55 GMT]]></title><description><![CDATA[<p>ich wollte die schriftgröße änder.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149749</guid><dc:creator><![CDATA[Sqwan]]></dc:creator><pubDate>Thu, 05 Oct 2006 09:08:55 GMT</pubDate></item><item><title><![CDATA[Reply to Uhr Geht Falsch on Thu, 05 Oct 2006 10:59:58 GMT]]></title><description><![CDATA[<p>Sqwan schrieb:</p>
<blockquote>
<p>ich wollte die schriftgröße änder.</p>
</blockquote>
<p>Ahso <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> . Das geht zum Beispiel so ( <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> Setzt eine aktuellere (=schönere, wie ich finde <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ) Schriftart und ändert nur die Größe), ist aber nur der WM_PAINT-Handler:</p>
<pre><code class="language-cpp">case WM_PAINT: {
            PAINTSTRUCT   ps;
            HDC           hDC;
            char sTime[30];
            int iLength;

            iLength = wsprintf(sTime, &quot;Sie haben %i mal geklickt&quot;, i);

            hDC = BeginPaint(hWnd, &amp;ps);
            {
                LOGFONT lfData;
                GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &amp;lfData);
                lfData.lfHeight = 15;
                // Hier kannst du weitere Dinge modifizieren, schau dir einfach mal die LOGFONT-Struktur an ;-)
                // lfData. ... = ...;
                HFONT hfOldFont = (HFONT)SelectObject(hDC, CreateFontIndirect(&amp;lfData));

                TextOut(hDC, 100, 100, sTime, iLength);
                DeleteObject(SelectObject(hDC, hfOldFont);
            }
            EndPaint(hWnd, &amp;ps);        
            } return (0);
</code></pre>
<p>Wenn du mehr wissen willst, schau dir einfach die Docs du den Funktionen an oder google n bissl da findet sich ne Menge <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149824</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149824</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 05 Oct 2006 10:59:58 GMT</pubDate></item></channel></rss>