Problem mit hbutton
-
Hi Leute:
Ich hab mal ein klavir auf Winapi geschrieben und es funtz eigenlich wunderbar , aber wenn ich mehrere knöpf gleichzeitig drücken will funtz das nicht mehr
ps: den code hab ich von heneksoft.de /win32 programmierung ..
und immer wenn ich den code das 2te mal complieren möchte , schießt "Dev Cpp" ab - genau so wie alle anderen complirer
hier der ganze code: (fals wer noch anderes damit vor hat *g* :D:P )
(laüft erst mit den WINMM sound linker )
und noch was: wie wird der code in son weisen kästchen wieder gegeben?
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow)
{
char szName[] = "Fensterklasse";
HBRUSH MyBrush = CreateSolidBrush( RGB( 0, 150, 255 ) );
WNDCLASS wc;wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hI;
wc.hIcon = LoadIcon (NULL, IDI_WINLOGO);
wc.hCursor = 0;
wc.hbrBackground = MyBrush;
wc.lpszMenuName = NULL;
wc.lpszClassName = szName;RegisterClass (&wc);
HWND hwnd = CreateWindow (szName, "Interaktives Fenster", WS_OVERLAPPEDWINDOW,
0, 0, 400, 100, NULL, NULL, hI, NULL);
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);//-----------------------------------------------------------------------------------
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}//-----------------------------------------------------------------------------------
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;HWND hwndButton1, hwndButton2,hwndButton3, hwndButton4,hwndButton5, hwndButton6,hwndButton7,hwndButton8;
switch (message)
{return 0;
case WM_CREATE :
hwndButton8 = CreateWindow ( "button", "c",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
140, 20, 20, 40, hwnd, (HMENU)8,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
hwndButton7 = CreateWindow ( "button", "h",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
120, 20, 20, 40, hwnd, (HMENU)7,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
hwndButton6 = CreateWindow ( "button", "a",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
100, 20, 20, 40, hwnd, (HMENU)6,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
hwndButton5 = CreateWindow ( "button", "g",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
80, 20, 20, 40, hwnd, (HMENU)5,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
hwndButton4 = CreateWindow ( "button", "f",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
60, 20, 20, 40, hwnd, (HMENU)4,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
hwndButton2 = CreateWindow ( "button", "e",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
40, 20, 20, 40, hwnd, (HMENU)3,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
hwndButton2 = CreateWindow ( "button", "d",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20, 20, 20, 40, hwnd, (HMENU)2,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
hwndButton1 = CreateWindow ( "button", "c",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 20, 20, 40, hwnd, (HMENU)1,
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
return 0;case WM_COMMAND:
if(LOWORD(wParam) ==
{
PlaySound("c2.wav", NULL,SND_FILENAME);}
if(LOWORD(wParam) == 7)
{
PlaySound("h.wav", NULL, SND_FILENAME);}
if(LOWORD(wParam) == 6)
{
PlaySound("a.wav", NULL, SND_FILENAME);}
if(LOWORD(wParam) == 5)
{
PlaySound("g.wav", NULL, SND_FILENAME);}
if(LOWORD(wParam) == 4)
{
PlaySound("f.wav", NULL, SND_FILENAME);}
if(LOWORD(wParam) == 3)
{
PlaySound("e.wav", NULL, SND_FILENAME);}
if(LOWORD(wParam) == 2)
{
PlaySound("d.wav", NULL, SND_FILENAME);}
if(LOWORD(wParam) == 1)
{
PlaySound("c.wav", NULL, SND_FILENAME);}
return 0;
}return DefWindowProc (hwnd, message, wParam, lParam);
}
]
-
mach ein [ cpp ] und [/ cpp] drum, OHNE die Leerzeichen zwischen den Klammern. Vorher wird sich das auch keiner ansehen wollen...

-
Du suchst bestimmt SND_ASYNC (siehe PlaySound() in der msdn)
-
JOOO DANKE!!!
