1 /*****************************************************************************
2 * vlc.c: the vlc player, WinCE version
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: vlc.c,v 1.6 2004/01/24 21:06:52 hartman Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
26 #define WIN32_LEAN_AND_MEAN
30 #include "../share/resource.h"
34 /*****************************************************************************
36 *****************************************************************************/
37 static LRESULT CALLBACK About ( HWND hDlg, UINT message,
38 WPARAM wParam, LPARAM lParam );
39 static long FAR PASCAL WndProc ( HWND hWnd, UINT message,
40 WPARAM wParam, LPARAM lParam );
42 /*****************************************************************************
44 *****************************************************************************/
48 /*****************************************************************************
49 * main: parse command line, start interface and spawn threads
50 *****************************************************************************/
51 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
52 LPTSTR lpCmdLine, int nCmdShow )
56 char * ppsz_argv[] = { lpCmdLine, "-vv", "--intf", "dummy", NULL, NULL };
64 wchar_t pwz_title[100];
67 ppsz_argv[4] = "washington.mpeg";
68 ppsz_argv[4] = "shovel.mpeg";
69 ppsz_argv[4] = "11h50.wav";
70 ppsz_argv[4] = "apple_promouse.mpeg";
72 /* Store our instance for future reference */
75 /* Register window class */
76 memset( &wc, 0, sizeof(wc) );
77 wc.style = CS_HREDRAW | CS_VREDRAW;
78 wc.lpfnWndProc = (WNDPROC) WndProc;
84 wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
86 wc.lpszClassName = L"VLC";
90 /* Print the version information */
91 sprintf( psz_title, "VLC media player %s", VLC_Version() );
92 MultiByteToWideChar( CP_ACP, 0, psz_title, -1, pwz_title, 100 );
94 /* Create our nice window */
95 window = CreateWindow( L"VLC", pwz_title,
96 WS_VISIBLE /*| WS_SIZEBOX | WS_CAPTION*/,
97 CW_USEDEFAULT, CW_USEDEFAULT,
98 //CW_USEDEFAULT, CW_USEDEFAULT,
100 NULL, NULL, hInst, NULL );
102 ShowWindow( window, nCmdShow );
103 UpdateWindow( window );
105 hAccelTable = LoadAccelerators( hInst, (LPCTSTR)IDC_NIOUP );
107 /* Create a libvlc structure */
108 i_ret = VLC_Create();
111 DestroyWindow( window );
115 /* Initialize libvlc */
116 i_ret = VLC_Init( 0, i_argc, ppsz_argv );
120 DestroyWindow( window );
124 /* Run libvlc, in non-blocking mode */
125 i_ret = VLC_Play( 0 );
127 /* Add a non-blocking interface and keep the return value */
128 i_ret = VLC_AddIntf( 0, NULL, VLC_FALSE );
130 while( GetMessage( &message, NULL, 0, 0 ) )
132 if( !TranslateAccelerator(message.hwnd, hAccelTable, &message) )
134 TranslateMessage( &message );
135 DispatchMessage( &message );
139 /* Kill the threads */
142 /* Finish the threads */
145 /* Destroy the libvlc structure */
148 DestroyWindow( window );
153 /*****************************************************************************
154 * Message handler for the About box.
155 *****************************************************************************/
156 static LRESULT CALLBACK About ( HWND hDlg, UINT message,
157 WPARAM wParam, LPARAM lParam)
160 int DlgWidth, DlgHeight; // dialog width and height in pixel units
161 int NewPosX, NewPosY;
166 /* trying to center the About dialog */
167 if( GetWindowRect( hDlg, &rt1 ) )
169 GetClientRect( GetParent(hDlg), &rt );
170 DlgWidth = rt1.right - rt1.left;
171 DlgHeight = rt1.bottom - rt1.top ;
172 NewPosX = ( rt.right - rt.left - DlgWidth ) / 2;
173 NewPosY = ( rt.bottom - rt.top - DlgHeight ) / 2;
175 /* if the About box is larger than the physical screen */
176 if( NewPosX < 0 ) NewPosX = 0;
177 if( NewPosY < 0 ) NewPosY = 0;
178 SetWindowPos( hDlg, 0, NewPosX, NewPosY,
179 0, 0, SWP_NOZORDER | SWP_NOSIZE );
184 if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
186 EndDialog(hDlg, LOWORD(wParam));
194 /*****************************************************************************
195 * Message handler for the main window
196 *****************************************************************************/
197 static long FAR PASCAL WndProc ( HWND hWnd, UINT message,
198 WPARAM wParam, LPARAM lParam )
211 Rectangle(hdc, x-4, y-4, x+4, y+4);
212 ReleaseDC(hWnd, hdc);
215 wmId = LOWORD(wParam);
216 wmEvent = HIWORD(wParam);
217 // Parse the menu selections:
221 DialogBox( hInst, (LPCTSTR)IDD_ABOUTBOX,
222 hWnd, (DLGPROC)About );
225 /* Do random stuff */
231 return DefWindowProc( hWnd, message, wParam, lParam );
235 hwndCB = CommandBar_Create(hInst, hWnd, 1);
236 CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
237 //CommandBar_AddAdornments(hwndCB, 0, 0);
242 hdc = BeginPaint(hWnd, &ps);
243 GetClientRect(hWnd, &rt);
244 DrawText( hdc, L"VLC roulaize!", _tcslen(L"VLC roulaize!"), &rt,
245 DT_SINGLELINE | DT_VCENTER | DT_CENTER );
250 CommandBar_Destroy(hwndCB);
254 return DefWindowProc(hWnd, message, wParam, lParam);