Simple player
STDAFX.H
// stdafx.h: include File for Standard System Include Files, // OR Project Specific Include Files That Are Used Frequently, But // Are Changed Infrequently //
#if! defined (AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__included _) # define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__included_
#if _MSC_VER> 1000 # prgma overce # endif //_MSC_VER> 1000
#define Win32_Lean_and_mean // Exclude Rarely-useed Stuff from Windows Headers
#include
// Todo: Reference Additional Headers your Program Requires Here
// {{AFX_INSERT_LOCATION}} // Microsoft Visual C Will Insert Additional Declarations Immediately Before The Previous Line.
#ENDIF /! Defined (AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__included_)
Resource.h
// stdafx.h: include File for Standard System Include Files, // OR Project Specific Include Files That Are Used Frequently, But // Are Changed Infrequently //
#if! defined (AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__included _) # define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__included_
#if _MSC_VER> 1000 # prgma overce # endif //_MSC_VER> 1000
#define Win32_Lean_and_mean // Exclude Rarely-useed Stuff from Windows Headers
#include
// Todo: Reference Additional Headers your Program Requires Here
// {{AFX_INSERT_LOCATION}} // Microsoft Visual C will insert additional declarations immediately before the previous line. # Endif //! Defined (AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
Simple player .CPP
// Easy player .cpp: defines the entry point for the application. / / / 简 简 器 .cpp
Purpose: Simple player (source code file)
Create: (CALVIN) Date: 2003.06 Version: 1.0
* ////
#include "stdafx.h" #include "resource.h"
// Global instance handle Hinstance Ghinst;
#define mciplay_app_class "mciplay_app" #define mciplay_doc_class mciwnd_window_class
// Parent window handle HWND GHWNDAPP; / / MDI Client window handle, MCI playback window is created after hwnd ghwndmdi; // mci window handle hWnd hwndmcinew; / * Open flag: true == Movie open, false = none * / // bool fmovieopen = false; / * window handle of the movie * /// hwnd hwndmovie;
LResult Callback AppWndProc (HWND, UINT, WPARAM, LPARAM);
//// *
About static functions in C language:
# Static function allows other source files to establish and use the same name of the same name, not mutual conflict
# Declare a static function that cannot be called by other source files because its name cannot be obtained
* //// static void mdiFilterSendMessage (HWND, UINT, WPARAM, LPARAM); static LRESULT mdiSendMessage (HWND hwndMdi, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); static HWND mdiCreateClient (HWND, HMENU); static void MCI_OnCommand (HWND, INT, HWND, UINT); Static Hwnd Mdicreatedoc (LPSTR, LPSTR, LPARAM); Static Void MCI_onsize (HWND, UINT, INT, INT);
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {MSG msg; ghInst = hInstance; WNDCLASS cls; cls.hCursor = LoadCursor (NULL, IDC_ARROW); cls.hIcon = LoadIcon (hInstance, "ICON1") ; cls.lpszMenuName = MAKEINTRESOURCE (IDR_MENU1); cls.lpszClassName = MCIPLAY_APP_CLASS; cls.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE 1); cls.hInstance = ghInst; cls.style = 0; cls.lpfnWndProc = (WNDPROC) AppWndProc; CLS.cbclsextra = 0; cls.cbwndextra = 0; if (! RegisterClass (& CLS)) Return 0; // !!! NOT USING MCIWNDCREATE, SO Weme Must init ourselves if (! mciWndregisterClass ()) Return False;
ghwndApp = CreateWindow (MCIPLAY_APP_CLASS, "easy players", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, (HWND) NULL, // no parent (HMENU) NULL, // use class menu hInstance, // handle to window Instance (lpstr) null; // no params to pass on
// Make Window Visible According To The Way The App IS Activated ShowWindow (GhwndApp, ncmdshow); // Polling for For (;;) {IF (PEEKMESG, NULL, 0, 0, PM_REMOVE) from the message event queue {IF (msg.Message == wm_quit) Break;
IF (! TranslateMdi, & MSG)) {TranslateMessage (& MSG); DispatchMessage (& MSG);}} else {// idle time here, dont be a pig! WaitMessage ();}} return msg.wpaam;}
LRESULT CALLBACK AppWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {switch (msg) {case WM_CREATE: // ghwndMdi = mdiCreateClient (hwnd, GetSubMenu (GetMenu (hwnd), GetMenuItemCount (GetMenu (hwnd)) - 1) Break;
Case WM_COMMAND: HANDLE_WM_COMMAND (HWND, WPARAM, LPARAM, MCI_ONCOMMAND); BREAK;
Case WM_Palettechanged: MdisndMessage (GHWndmdi, (HWND) -1, MSG, WPARAM, LPARAM; Break;
Case WM_QuerynewPalette: Return MdisndMessage (Ghwndmdi, Null, MSG, WPARAM, LPARAM); Break;
// Case WM_INITMENUPOPUP: // Handle_WM_INITMENUPOPUP (HWND, WPARAM, LPARAM, MCI_ONINITMENUPOPUP); // Break;
Case WM_SIZE: HANDLE_WM_SIZE (HWND, WPARAM, LPARAM, MCI_ONSIZE); BREAK;
case WM_DESTROY: PostQuitMessage (0); return (0);} return DefFrameProc (hwnd, ghwndMdi, msg, wParam, lParam);} static LRESULT mdiSendMessage (HWND hwndMdi, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {if (hWnd == (hWnd) -1) {for (hwnd = getWindow (hwndmdi, gw_child); hwnd; hwnd = getWindow (hwnd, gw_hwndnext)) SendMessage (HWND, MSG, WPARAM, LPARAM); RETURN 0L;} else { IF (hwnd == null) hwnd = forward_wm_mdigetActive (hwndmdi, sendmessage); if (hwnd) return sendmessage (hwnd, msg, wparam, lparam);}}
Static void mci_oncommand (hwnd hwnd, uint codenotify {hwnd hwndnew; hwnd hwndmovie = forward_wm_mdigetActive (ghwndmdi, sendmessage); Bool Bgothelp; switch (id) {
Case IDC_EXIT: PostMessage (HWND, WM_CLOSE, 0, 0L); BREAK;
Case menu_open: {OpenFileName Offen; char szfilename [max_path]; // char szfiletitle [max_path];
/ * Prompt user for file to open * / off.lstructSize = sizeof (OpenFileName); off.hwndowner = hwnd; off.hinstance = null; off.lpstrfilter = "videofiles (*. avi, *. dat, *. mpeg, * .mpg) / 0*.avi; *. dat; *. mpeg; *. mpg / 0/0 "; off.lpstrcustomfilter = null; off.nmaxcustfilter = 0; off.nfilterIndex = 0; * SZFileName = '/ 0 '; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.lpstrTitle = "Open"; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY ; ofn.nFileOffset = 0; ofn.nFileExtension = 0; ofn.lpstrDefExt = NULL; ofn.lCustData = 0; ofn.lpfnHook = NULL; ofn.lpTemplateName = NULL; if (GetOpenFileName (& ofn)) if (hwndNew = mdiCreateDoc ( McIPlay_Doc_Class, 0, (LPARAM) (LPSTR ) STFOCUS (HWndNew);} Break; Case IDC_Aboutvedio: bgothelp = WinHelp (hwnd, "generic.hlp", help_contents, (dword) 0); if (! bgothelp) {MessageBox (getfocus (), "Easy Play Mer. HLP "," Simple Player. HLP ", MB_OK | MB_ICONHAND);} Break; Default: Forward_WM_COMMAND (NULL, ID, HWNDCTL, CODENOTIFY, MDIFILTERSENDMESSAGE); Break;} return;}
Static HWnd MdicreateClient (HWND HWNDP, HMENU HMENUWINDOW) {ClientCreatestruct CCS;
ccs.hWindowMenu = hmenuWindow; ccs.idFirstChild = 100; return CreateWindow ( "MDICLIENT", NULL, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, 0, 0, 0, 0, hwndP, 0, ghInst, (LPVOID) & ccs);} static HWND MDICREATEDOC (LPSTR SZCLASS, LPSTR SZTITLE, LPARAM L) {MDicreatestruct MDICS;
mdics.szClass = szClass; mdics.szTitle = szTitle; mdics.hOwner = ghInst; mdics.x = CW_USEDEFAULT; mdics.y = 0; mdics.cx = CW_USEDEFAULT; mdics.cy = 0; mdics.style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | McIWNDF_SHOWALL; mdics.lparam = L;
Return forward_wm_mdicreate (ghwndmdi, (lpmdicreatestruct) & mdics, sendmessage);
Static void MDiFiltersndMessage (HWND HWND, UINT MSG, WPARAM WPARAM, LPARAM LPARAM) {mdisendMessage (GHWndMDi, HWND, MSG, WPARAM, LPARAM);
Static void mci_onsize (hwnd hwnd, uint state, int cx, int CY) {MoveWindow (GHWNDMDI, 0, 0, CX, CY, TRUE); Return;}
// Microsoft Developer Studio generated resource script.//#include "resource.h"
#define apstudio_readonly_symbols ///// generated from the textinclude 2 resource.//#clude "afxres.h"
/ # undef apstudio_readonly_symbols
/// Chinese (p.r.c.) Resources
#if! defined (AFX_RESOURCE_DLL) || Defined (AFX_TARG_CHS) #ifdef _win32language lang_chinese, SUBLANG_CHINESE_SIMPLIFIED # Pragma code_page (936) #ENDIF / / _WIN32
///// Dialog //
IDD_DIALOG_VEDIOPLAY DIALOGEX 0, 0, 397, 240STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENUEXSTYLE WS_EX_CLIENTEDGECAPTION "simple media player beta version 1" FONT 10, "System", 0, 0, 0x1BEGIN PUSHBUTTON "open file", IDC_BUTTON_OPEN, 343, 7, 47, 13 pushbutton "Exit", IDC_Button_exit, 343, 56, 47, 13nd ///// designInfo //
#ifdef apstudio_invokedguidelines designInfo Discardable Begin IDD_DIALOG_VEDIOPLAY, DIALOG BEGIN LEFTMARGIN, 7 Right Margin, 390 Topmargin, 7 Bottommargin, 233 Endend # endif // APSTUDIO_INVOKED
#ifdef apstudio_invoked ///// Textinclude //
1 Textinclude Discardable Begin "Resource.h / 0" end
2 Textinclude Discardable Begin "#include" "AfXRES.H" "/ r / n" "/ 0" end
3 textinclude discardable begin "/ r / n" "/ 0" end
#ENDIF // APSTUDIO_INVOKED
//// Menu //
IDR_MENU1 MENU DISCARDABLE BEGIN POPUP "File" BEGIN MENUITEM SEPARATOR MENUITEM "exit", IDC_EXIT END POPUP "video" BEGIN MENUITEM "open file", MENU_OPEN END POPUP "Help" BEGIN MENUITEM "Help on this program", IDC_ABOUTVEDIO MENUITEM SEPARATOR ENDEND
///// iCon //
// icon with lowest id value placed first to ensure Application Icon // Remains consistent on all systems.idi_icon1 icon discardable "icon1.ico" #ENDIF // Chinese (p.r.c.) Resources /
#ifndef apstudio_invoked ///// generated from the textinclude 3 resource.//
/ # endif // not APSTUDIO_INVOKED