i have my code to play a mp3....but cant get the listbox item
here is my code
Expand|Select|Wrap|Line Numbers
- #define _WIN32_IE 0x0300
- // includes
- #include <windows.h>
- #include <mmsystem.h>
- #include <ufmod.h>
- #include <sys/stat.h>
- #include <commdlg.h>
- #include "res.h"
- #include "muzic.h"
- #include <commctrl.h>
- #include "vfw.h"
- MCIDEVICEID pDevice = 0;
- using namespace std;
- HBITMAP hCarBmp = NULL;
- HBITMAP hSkinMBmp = NULL;
- int i = 0;
- HBITMAP hskin;
- RECT rc;
- HBITMAP hbup;
- HBITMAP hbdn;
- HBITMAP exitup;
- HBITMAP exitdn;
- HWND m_Video;
- MCI_OPEN_PARMS op;
- // Destroy our windows caption
- void DestroyCaption(HWND hwnd, int windowWidth, int windowHeight)
- {
- DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE);
- dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
- SetWindowLong(hwnd, GWL_STYLE, dwStyle);
- InvalidateRect(hwnd, NULL, true);
- SetWindowPos(hwnd, NULL, 0,0,windowWidth, windowHeight, SWP_NOMOVE | SWP_NOZORDER);
- }
- // Our dialogs callback routine
- BOOL CALLBACK dialog(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
- {
- INITCOMMONCONTROLSEX InitCtrlEx;
- InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
- InitCtrlEx.dwICC = ICC_PROGRESS_CLASS;
- InitCommonControlsEx(&InitCtrlEx);
- switch(Message)
- {
- // make window layered and set all pixels with an RGB value of 0,0,255 invisible
- case WM_INITDIALOG:
- {
- case IDC_LIST1:
- // It's our listbox, check the notification code
- switch(HIWORD(wParam))
- {
- case LBN_SELCHANGE:
- // Selection changed, do stuff here.
- break;
- }
- break;
- m_Video = NULL;
- //AnimateWindow(hWnd);
- }
- break;
- // move our window
- case WM_LBUTTONDOWN:
- {
- PostMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION,0);
- break;
- }
- case WM_DRAWITEM:
- {
- break;
- }
- // cleanup
- case WM_CLOSE:
- {
- DeleteObject(hSkinMBmp);
- EndDialog(hwnd, 0);
- break;
- }
- // draw our bitmap
- case WM_PAINT:
- {
- RECT rect;
- BITMAP bm;
- BITMAP talkwithhandle;
- PAINTSTRUCT attribstobmp;
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hwnd, &ps);
- HDC dcstuff = BeginPaint(hwnd, &attribstobmp);
- HDC dcSkin = CreateCompatibleDC(hdc);
- HDC dcinmem = CreateCompatibleDC(dcstuff);
- GetObject(hSkinMBmp, sizeof(bm), &bm);
- GetObject(hCarBmp, sizeof(talkwithhandle), &talkwithhandle);
- SelectObject(dcSkin, hSkinMBmp);
- SelectObject(dcinmem, hCarBmp);
- BitBlt(hdc, 10,10,160,108, dcinmem, 0, 0, SRCCOPY);
- DeleteDC(dcSkin);
- DeleteDC(dcinmem);
- EndPaint(hwnd, &ps);
- EndPaint(hwnd, &attribstobmp);
- break;
- }
- case WM_COMMAND:
- {
- if(((HWND)lParam) && (HIWORD(wParam) == BN_CLICKED)){
- int iMID;
- iMID = LOWORD(wParam);
- switch(iMID){
- case ID_ADD:
- {
- OPENFILENAME ofn; // common dialog box structure
- char szFile[260]; // buffer for file name
- // Initialize OPENFILENAME
- ZeroMemory(&ofn, sizeof(ofn));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hwnd; // handle to owner window
- ofn.lpstrFile = szFile;
- //
- // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
- // use the contents of szFile to initialize itself.
- //
- ofn.lpstrTitle = TEXT("Your Title Here");
- ofn.lpstrFile[0] = '\0';
- ofn.nMaxFile = sizeof(szFile);
- // filter name followed by null followed by filter extension,
- // repeat for each filter, and end list with double-null
- ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
- ofn.nFilterIndex = 1; // initial filter to select
- ofn.lpstrFileTitle = NULL; // initial file to select
- ofn.nMaxFileTitle = 0;
- ofn.lpstrInitialDir = NULL;
- ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
- // Display the Open dialog box.
- if(GetOpenFileName(&ofn) == TRUE){
- m_Video = MCIWndCreate(hwnd,NULL,MCIWNDF_NOPLAYBAR,szFile);
- MoveWindow (m_Video, 729, 729, 1, 1, TRUE);
- SendDlgItemMessage(hwnd, IDC_LIST1, LB_ADDFILE, (WPARAM) NULL, (LPARAM)szFile);
- MCIWndPlay(m_Video);
- }
- }
- break;
- case ID_PLAY:
- {
- }
- break;
- case ID_CLEAR:
- {
- SendDlgItemMessage(hwnd, IDC_LIST1,LB_RESETCONTENT, 0, 0);
- }
- break;
- case ID_REMOVE:
- {
- SendDlgItemMessage(hwnd, IDC_LIST1, LB_GETCURSEL, 0, 0);
- SendDlgItemMessage(hwnd, IDC_LIST1, LB_DELETESTRING , 0, 0);
- }
- }}
- break;
- }
- default:
- return FALSE;
- }
- return DefWindowProc(hwnd,Message,wParam,lParam);
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
- {
- WNDCLASSEX wc;
- wc.cbClsExtra = 0;
- wc.cbSize = sizeof(wc);
- wc.cbWndExtra = 0;
- wc.hbrBackground = NULL;
- wc.hIcon = LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON));
- wc.hIconSm = LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON));
- wc.hInstance = GetModuleHandle(NULL);
- wc.lpszClassName = "WinPatch";
- wc.lpszMenuName = NULL;
- wc.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC |CS_DBLCLKS;
- // load our bitmap
- hCarBmp= LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BALL));
- // create ourlog
- return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, dialog);
- }