Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sdcsdc.cpp : Defines the entry point for the application.
- //
- #include "stdafx.h"
- #pragma comment(lib, "winmm.lib")
- #include "sdcsdc.h"
- #include <mmsystem.h>
- #define MAX_LOADSTRING 100
- // Global Variables:
- HINSTANCE hInst; // current instance
- WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
- WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
- // Forward declarations of functions included in this code module:
- ATOM MyRegisterClass(HINSTANCE hInstance);
- BOOL InitInstance(HINSTANCE, int);
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
- int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
- _In_opt_ HINSTANCE hPrevInstance,
- _In_ LPWSTR lpCmdLine,
- _In_ int nCmdShow)
- {
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
- // TODO: Place code here.
- // Initialize global strings
- LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
- LoadStringW(hInstance, IDC_SDCSDC, szWindowClass, MAX_LOADSTRING);
- MyRegisterClass(hInstance);
- // Perform application initialization:
- if (!InitInstance (hInstance, nCmdShow))
- {
- return FALSE;
- }
- HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SDCSDC));
- MSG msg;
- // Main message loop:
- while (GetMessage(&msg, nullptr, 0, 0))
- {
- if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- return (int) msg.wParam;
- }
- //
- // FUNCTION: MyRegisterClass()
- //
- // PURPOSE: Registers the window class.
- //
- ATOM MyRegisterClass(HINSTANCE hInstance)
- {
- WNDCLASSEXW wcex;
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = WndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = hInstance;
- wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SDCSDC));
- wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_SDCSDC);
- wcex.lpszClassName = szWindowClass;
- wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
- return RegisterClassExW(&wcex);
- }
- //
- // FUNCTION: InitInstance(HINSTANCE, int)
- //
- // PURPOSE: Saves instance handle and creates main window
- //
- // COMMENTS:
- //
- // In this function, we save the instance handle in a global variable and
- // create and display the main program window.
- //
- BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
- {
- hInst = hInstance; // Store instance handle in our global variable
- HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
- 200, 150, 800, 400, nullptr, nullptr, hInstance, nullptr);
- if (!hWnd)
- {
- return FALSE;
- }
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
- return TRUE;
- }
- //
- // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
- //
- // PURPOSE: Processes messages for the main window.
- //
- // WM_COMMAND - process the application menu
- // WM_PAINT - Paint the main window
- // WM_DESTROY - post a quit message and return
- //
- //
- HWND hEdit;
- HWND hQ, hW, hE, hR, hT, hY, hA, hS, hD, hF, hG, hH, hZ, hX, hC, hV, hB, hN;
- void CreateAllButtons(HWND hWParent)
- {
- hQ=CreateWindow(L"button",L"Q", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 30, 30, 80, 60, hWParent, (HMENU)1, hInst, nullptr);
- hW=CreateWindow(L"button", L"W", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 140, 30, 80, 60, hWParent, (HMENU)2, hInst, nullptr);
- hE=CreateWindow(L"button", L"E", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 270, 30, 80, 60, hWParent, (HMENU)3, hInst, nullptr);
- hR=CreateWindow(L"button", L"R", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 400, 30, 80, 60, hWParent, (HMENU)4, hInst, nullptr);
- hT=CreateWindow(L"button", L"T", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 530, 30, 80, 60, hWParent, (HMENU)5, hInst, nullptr);
- hY=CreateWindow(L"button", L"Y", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 660, 30, 80, 60, hWParent, (HMENU)6, hInst, nullptr);
- hA=CreateWindow(L"button", L"A", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 30, 130, 80, 60, hWParent, (HMENU)7, hInst, nullptr);
- hS=CreateWindow(L"button", L"S", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 140, 130, 80, 60, hWParent, (HMENU)8, hInst, nullptr);
- hD=CreateWindow(L"button", L"D", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 270, 130, 80, 60, hWParent, (HMENU)9, hInst, nullptr);
- hF=CreateWindow(L"button", L"F", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 400, 130, 80, 60, hWParent, (HMENU)10, hInst, nullptr);
- hG=CreateWindow(L"button", L"G", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 530, 130, 80, 60, hWParent, (HMENU)11, hInst, nullptr);
- hH=CreateWindow(L"button", L"H", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 660, 130, 80, 60, hWParent, (HMENU)12, hInst, nullptr);
- hZ=CreateWindow(L"button", L"Z", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 30, 230, 80, 60, hWParent, (HMENU)13, hInst, nullptr);
- hX=CreateWindow(L"button", L"X", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 140, 230, 80, 60, hWParent, (HMENU)14, hInst, nullptr);
- hC=CreateWindow(L"button", L"C", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 270, 230, 80, 60, hWParent, (HMENU)15, hInst, nullptr);
- hV=CreateWindow(L"button", L"V", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 400, 230, 80, 60, hWParent, (HMENU)16, hInst, nullptr);
- hB=CreateWindow(L"button", L"B", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 530, 230, 80, 60, hWParent, (HMENU)17, hInst, nullptr);
- hN=CreateWindow(L"button", L"N", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 660, 230, 80, 60, hWParent, (HMENU)18, hInst, nullptr);
- //hEdit = CreateWindow("edit", "0", WS_CHILD | WS_VISIBLE | ES_RIGHT, 10, 10, 180, 20, hWParent, (HMENU)20, hInst, nullptr);
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- int wmId = LOWORD(wParam);
- switch (message)
- {
- case WM_CREATE:
- CreateAllButtons(hWnd);
- break;
- case WM_COMMAND:
- {
- // Parse the menu selections:
- switch (wmId)
- {
- case IDM_ABOUT:
- DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
- break;
- case IDM_EXIT:
- DestroyWindow(hWnd);
- break;
- default:
- SetFocus(hWnd);
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- }
- break;
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hWnd, &ps);
- // TODO: Add any drawing code that uses hdc here...
- EndPaint(hWnd, &ps);
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- //PlaySound((LPCSTR)"Fat Kick.wav", NULL, SND_SYNC);
- //PlaySound(TEXT("Fat Kick.wav"), NULL, SND_ALIAS);
- case WM_KEYDOWN:
- switch (wmId)
- {
- case 'Q':
- {
- SendMessage(hQ, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("1.wav"), NULL, SND_ALIAS);
- SendMessage(hQ, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'W':
- {
- SendMessage(hW, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("2.wav"), NULL, SND_ALIAS);
- SendMessage(hW, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'E':
- {
- if (wParam == 'E')SendMessage(hE, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("3.wav"), NULL, SND_ALIAS);
- if (wParam == 'E')SendMessage(hE, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'R':
- {
- if (wParam == 'R')SendMessage(hR, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("4.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'R')SendMessage(hR, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'T':
- {
- if (wParam == 'T')SendMessage(hT, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("5.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'T')SendMessage(hT, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'Y':
- {
- if (wParam == 'Y')SendMessage(hY, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("6.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'Y')SendMessage(hY, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'A':
- {
- if (wParam == 'A')SendMessage(hA, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("7.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'A')SendMessage(hA, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'S':
- {
- if (wParam == 'S')SendMessage(hS, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("8.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'S')SendMessage(hS, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'D':
- {
- if (wParam == 'D')SendMessage(hD, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("9.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'D')SendMessage(hD, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'F':
- {
- if (wParam == 'F')SendMessage(hF, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("10.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'F')SendMessage(hF, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'G':
- {
- if (wParam == 'G')SendMessage(hG, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'G')SendMessage(hG, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'H':
- {
- if (wParam == 'H')SendMessage(hH, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'H')SendMessage(hH, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'Z':
- {
- if (wParam == 'Z')SendMessage(hZ, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'Z')SendMessage(hZ, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'X':
- {
- if (wParam == 'X')SendMessage(hX, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'X')SendMessage(hX, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'C':
- {
- if (wParam == 'C')SendMessage(hC, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'C')SendMessage(hC, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'V':
- {
- if (wParam == 'V')SendMessage(hV, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'V')SendMessage(hV, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'B':
- {
- if (wParam == 'B')SendMessage(hB, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'B')SendMessage(hB, WM_LBUTTONUP, 0, 0);
- }
- break;
- case 'N':
- {
- if (wParam == 'N')SendMessage(hN, WM_LBUTTONDOWN, 0, 0);
- Sleep(100);
- if (wParam == 'N')SendMessage(hN, WM_LBUTTONUP, 0, 0);
- }
- break;
- }
- break;
- /*switch (wmId)
- {
- case 'N':
- {
- if (wParam == 'N')SendMessage(hN, WM_LBUTTONDOWN, 0, 0);
- PlaySound(TEXT("Clink Hit.wav"), NULL, SND_ALIAS);
- Sleep(100);
- if (wParam == 'N')SendMessage(hN, WM_LBUTTONUP, 0, 0);
- }
- break;
- }*/
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- break;
- }
- return 0;
- }
- // Message handler for about box.
- INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- UNREFERENCED_PARAMETER(lParam);
- switch (message)
- {
- case WM_INITDIALOG:
- return (INT_PTR)TRUE;
- case WM_COMMAND:
- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement