<?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[musikabspielprogramm mit aktueller absielweite. mal gehts, mal gehts nicht.]]></title><description><![CDATA[<pre><code>#include &lt;windows.h&gt;
#include &lt;fstream&gt;
using namespace std;
static char position[32]=&quot;&quot;;
HINSTANCE hinstance;
HWND slider;
static int pos=0;

DWORD WINAPI ThreadFunc( LPVOID lpParam ) 
{ 
	while(true)
	{
		Sleep(100);	
		mciSendString(&quot;status mucke.mp3 position&quot;, position, 32, 0);
		SetScrollPos(slider, SB_CTL, atoi(position), TRUE);
	}
   return 0; 
} 

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
	hinstance=hInstance;
 static TCHAR szAppName[] = TEXT (&quot;dasmenu&quot;) ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

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

     if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

      hwnd = CreateWindow (szAppName,                 // Name der Fensterklasse
                  TEXT (&quot;Das erste echte Programm&quot;),  // Fenstertitel
                  WS_OVERLAPPEDWINDOW,                // Fensterstil
                  CW_USEDEFAULT,                      // X-Position des Fensters
                  CW_USEDEFAULT,                      // Y-Position des Fensters
                  CW_USEDEFAULT,                      // Fensterbreite
                  CW_USEDEFAULT,                      // Fensterhöhe
                  NULL,                               // übergeordnetes Fenster
                  0,                               // Menü
                  hInstance,                          // Programm-Kopiezähler (Programm-ID)
                  NULL) ;                             // zusätzliche Parameter

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

	 mciSendString(&quot;open mucke.mp3 wait&quot; , 0,0,0);
	 LoadMenu(hInstance,&quot;mymenu&quot;);
     while (GetMessage (&amp;msg, NULL, 0, 0))
     {
          TranslateMessage (&amp;msg) ;
          DispatchMessage (&amp;msg) ;
     }
     return msg.wParam ;
}

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

     switch (message)
     {
     case WM_CREATE:
		  char laenge[30];
          slider=CreateWindow(TEXT(&quot;scrollbar&quot;),NULL,
					WS_CHILD|WS_VISIBLE|
					WS_TABSTOP|SBS_VERT,
					0,0,200,200,
					hwnd,(HMENU)0,hinstance, NULL);
		  mciSendString(&quot;status mucke.mp3 length&quot; , laenge, sizeof(laenge),0);
		  SetScrollRange(slider, SB_CTL, 0, atoi(laenge), TRUE);
		  CreateThread(NULL,                        // default security attributes 
					   0,                           // use default stack size  
					   ThreadFunc,                  // thread function 
					   0,							// argument to thread function 
					   0,                           // use default creation flags 
					   0); 
		  mciSendString(&quot;play mucke.mp3&quot; , 0,0,0);
		  return 0 ;     

	/* case WM_VSCROLL:
		  switch(LOWORD(wParam))
		  {
			case SB_PAGEDOWN:
				SetScrollPos(slider, SB_CTL, 100, TRUE);
				return 0;
			case SB_LINEUP:	//Mausklick Pfeil oben
				SetScrollPos(slider, SB_CTL, --pos, TRUE);
				return 0;
			case SB_LINEDOWN:	//Mausklick Pfeil oben
				SetScrollPos(slider, SB_CTL, ++pos, TRUE);
				return 0;
		  }
		  return 0;*/
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<p>Normalwerweise müsste beim starten des Programms die mucke.mp3 abgespielt wereden und aller 100ms die scrollbar aktualisiert werden.<br />
Das funktioniert auch, nur irgendwie nicht immer. Mnchaml wird beim starten des Programms die Musik nicht abgespielt oder die Musik abgespielt, dafür aber die scrollbar nicht aktualisiert....ich habe keinen schimmer woran das liegt! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/90530/musikabspielprogramm-mit-aktueller-absielweite-mal-gehts-mal-gehts-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 02:52:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/90530.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 30 Oct 2004 11:35:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to musikabspielprogramm mit aktueller absielweite. mal gehts, mal gehts nicht. on Sat, 30 Oct 2004 11:35:59 GMT]]></title><description><![CDATA[<pre><code>#include &lt;windows.h&gt;
#include &lt;fstream&gt;
using namespace std;
static char position[32]=&quot;&quot;;
HINSTANCE hinstance;
HWND slider;
static int pos=0;

DWORD WINAPI ThreadFunc( LPVOID lpParam ) 
{ 
	while(true)
	{
		Sleep(100);	
		mciSendString(&quot;status mucke.mp3 position&quot;, position, 32, 0);
		SetScrollPos(slider, SB_CTL, atoi(position), TRUE);
	}
   return 0; 
} 

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
	hinstance=hInstance;
 static TCHAR szAppName[] = TEXT (&quot;dasmenu&quot;) ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

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

     if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

      hwnd = CreateWindow (szAppName,                 // Name der Fensterklasse
                  TEXT (&quot;Das erste echte Programm&quot;),  // Fenstertitel
                  WS_OVERLAPPEDWINDOW,                // Fensterstil
                  CW_USEDEFAULT,                      // X-Position des Fensters
                  CW_USEDEFAULT,                      // Y-Position des Fensters
                  CW_USEDEFAULT,                      // Fensterbreite
                  CW_USEDEFAULT,                      // Fensterhöhe
                  NULL,                               // übergeordnetes Fenster
                  0,                               // Menü
                  hInstance,                          // Programm-Kopiezähler (Programm-ID)
                  NULL) ;                             // zusätzliche Parameter

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

	 mciSendString(&quot;open mucke.mp3 wait&quot; , 0,0,0);
	 LoadMenu(hInstance,&quot;mymenu&quot;);
     while (GetMessage (&amp;msg, NULL, 0, 0))
     {
          TranslateMessage (&amp;msg) ;
          DispatchMessage (&amp;msg) ;
     }
     return msg.wParam ;
}

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

     switch (message)
     {
     case WM_CREATE:
		  char laenge[30];
          slider=CreateWindow(TEXT(&quot;scrollbar&quot;),NULL,
					WS_CHILD|WS_VISIBLE|
					WS_TABSTOP|SBS_VERT,
					0,0,200,200,
					hwnd,(HMENU)0,hinstance, NULL);
		  mciSendString(&quot;status mucke.mp3 length&quot; , laenge, sizeof(laenge),0);
		  SetScrollRange(slider, SB_CTL, 0, atoi(laenge), TRUE);
		  CreateThread(NULL,                        // default security attributes 
					   0,                           // use default stack size  
					   ThreadFunc,                  // thread function 
					   0,							// argument to thread function 
					   0,                           // use default creation flags 
					   0); 
		  mciSendString(&quot;play mucke.mp3&quot; , 0,0,0);
		  return 0 ;     

	/* case WM_VSCROLL:
		  switch(LOWORD(wParam))
		  {
			case SB_PAGEDOWN:
				SetScrollPos(slider, SB_CTL, 100, TRUE);
				return 0;
			case SB_LINEUP:	//Mausklick Pfeil oben
				SetScrollPos(slider, SB_CTL, --pos, TRUE);
				return 0;
			case SB_LINEDOWN:	//Mausklick Pfeil oben
				SetScrollPos(slider, SB_CTL, ++pos, TRUE);
				return 0;
		  }
		  return 0;*/
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<p>Normalwerweise müsste beim starten des Programms die mucke.mp3 abgespielt wereden und aller 100ms die scrollbar aktualisiert werden.<br />
Das funktioniert auch, nur irgendwie nicht immer. Mnchaml wird beim starten des Programms die Musik nicht abgespielt oder die Musik abgespielt, dafür aber die scrollbar nicht aktualisiert....ich habe keinen schimmer woran das liegt! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/640920</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/640920</guid><dc:creator><![CDATA[toni lla]]></dc:creator><pubDate>Sat, 30 Oct 2004 11:35:59 GMT</pubDate></item><item><title><![CDATA[Reply to musikabspielprogramm mit aktueller absielweite. mal gehts, mal gehts nicht. on Sat, 30 Oct 2004 11:52:49 GMT]]></title><description><![CDATA[<p>Evtl. müsstest du noch die Scrol-Range entsprechend einstellen - es könnte aber auch daran liegen, dass du das Device nicht schließt.<br />
Siehe auch: <a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39378" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic.php?t=39378</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/640935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/640935</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 30 Oct 2004 11:52:49 GMT</pubDate></item><item><title><![CDATA[Reply to musikabspielprogramm mit aktueller absielweite. mal gehts, mal gehts nicht. on Sat, 30 Oct 2004 12:59:07 GMT]]></title><description><![CDATA[<p>an der Range liegt es nicht.<br />
Der Thread kann irgendwie die aktuelle wiedergabe position nicht ermitteln.<br />
Er liefert dauernd 0.</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;fstream&gt;
using namespace std;
static char position[32]=&quot;&quot;;
HINSTANCE hinstance;
HWND slider;
static int pos=0;
HANDLE thread;
ofstream out(&quot;lala.txt&quot;);
DWORD WINAPI ThreadFunc( LPVOID lpParam ) 
{ 
	while(true)
	{
		Sleep(100);	
		mciSendString(&quot;status mucke.mp3 position&quot;, position, 32, NULL);
		out&lt;&lt;position&lt;&lt;endl;
		SetScrollPos(slider, SB_CTL, atoi(position), TRUE);
	}
   return 0; 
} 

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
	hinstance=hInstance;
 static TCHAR szAppName[] = TEXT (&quot;dasmenu&quot;) ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

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

     if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

      hwnd = CreateWindow (szAppName,                 // Name der Fensterklasse
                  TEXT (&quot;Das erste echte Programm&quot;),  // Fenstertitel
                  WS_OVERLAPPEDWINDOW,                // Fensterstil
                  CW_USEDEFAULT,                      // X-Position des Fensters
                  CW_USEDEFAULT,                      // Y-Position des Fensters
                  CW_USEDEFAULT,                      // Fensterbreite
                  CW_USEDEFAULT,                      // Fensterhöhe
                  NULL,                               // übergeordnetes Fenster
                  0,                               // Menü
                  hInstance,                          // Programm-Kopiezähler (Programm-ID)
                  NULL) ;                             // zusätzliche Parameter

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

	 mciSendString(&quot;open mucke.mp3 wait&quot; , 0,0,0);
	 //LoadMenu(hInstance,&quot;mymenu&quot;);
     while (GetMessage (&amp;msg, NULL, 0, 0))
     {
          TranslateMessage (&amp;msg) ;
          DispatchMessage (&amp;msg) ;
     }
     return msg.wParam ;
}

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

     switch (message)
     {
     case WM_CREATE:
		  char laenge[30];
          slider=CreateWindow(TEXT(&quot;scrollbar&quot;),NULL,
					WS_CHILD|WS_VISIBLE|
					WS_TABSTOP|SBS_VERT,
					0,0,200,200,
					hwnd,(HMENU)0,hinstance, NULL);
		  mciSendString(&quot;status mucke.mp3 length wait&quot; , laenge, 30,NULL);
		  SetScrollRange(slider, SB_CTL, 0, atoi(laenge), TRUE);
		  mciSendString(&quot;play mucke.mp3&quot; , NULL,NULL,NULL);
		  thread=CreateThread(NULL,                 // default security attributes 
					   0,                           // use default stack size  
					   ThreadFunc,                  // thread function 
					   0,							// argument to thread function 
					   0,                           // use default creation flags 
					   0); 

		  return 0 ;     

	 case WM_DESTROY:
		  mciSendString(&quot;stop mucke.mp3&quot;,NULL,NULL,NULL);
		  mciSendString(&quot;close mucke.mp3&quot;,NULL,NULL,NULL);
		  CloseHandle(thread);
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<p>lala.txt:</p>
<blockquote>
<p>0<br />
0<br />
0<br />
0<br />
0<br />
0<br />
0<br />
0<br />
0<br />
0</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/640993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/640993</guid><dc:creator><![CDATA[toni lla]]></dc:creator><pubDate>Sat, 30 Oct 2004 12:59:07 GMT</pubDate></item><item><title><![CDATA[Reply to musikabspielprogramm mit aktueller absielweite. mal gehts, mal gehts nicht. on Sat, 30 Oct 2004 14:34:58 GMT]]></title><description><![CDATA[<p>Versuch's doch mal mit dem Code aus den FAQ <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/641058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/641058</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 30 Oct 2004 14:34:58 GMT</pubDate></item><item><title><![CDATA[Reply to musikabspielprogramm mit aktueller absielweite. mal gehts, mal gehts nicht. on Sat, 30 Oct 2004 15:21:34 GMT]]></title><description><![CDATA[<p>der nützt mir nix...das was dort steht ist pille palle.<br />
Wenn ich diesen slider der abspiellänge anpassen will, so muss ich doch mit nem thread arbeiten!?<br />
- wie würdest du das machen?</p>
<p>wenn ich mit threads arbeite habe ich folgendes Problem:<br />
wenn ich die musik außerhalb des threads abspiele und im thread abfragen möchte wie weit nun gespielt wurde, kommt immer eine 0.<br />
lasse ich die musik im thread abspielen, kann ich zwar im thread auf die position zugreifen aber nicht mehr außerhalb des threads... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/641092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/641092</guid><dc:creator><![CDATA[toni lla]]></dc:creator><pubDate>Sat, 30 Oct 2004 15:21:34 GMT</pubDate></item><item><title><![CDATA[Reply to musikabspielprogramm mit aktueller absielweite. mal gehts, mal gehts nicht. on Sat, 30 Oct 2004 16:11:26 GMT]]></title><description><![CDATA[<p>Eigentlich solltest du gar keine Thrads brauchen - einfach SetTimer nehmen <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/641115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/641115</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 30 Oct 2004 16:11:26 GMT</pubDate></item></channel></rss>