1 /*****************************************************************************
2 * vlc.c: the vlc player, WinCE version
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: vlc.c,v 1.3 2002/11/20 13:37:35 sam 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", "shovel.mpeg", NULL };
64 wchar_t pwz_title[100];
66 /* Store our instance for future reference */
69 /* Register window class */
70 wc.style = CS_HREDRAW | CS_VREDRAW;
71 wc.lpfnWndProc = (WNDPROC) WndProc;
77 wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
79 wc.lpszClassName = L"VLC";
83 /* Print the version information */
84 sprintf( psz_title, "VideoLAN Client %s", VLC_Version() );
85 MultiByteToWideChar( CP_ACP, 0, psz_title, -1, pwz_title, 100 );
87 /* Create our nice window */
88 window = CreateWindow( L"VLC", pwz_title,
89 WS_VISIBLE | WS_SIZEBOX | WS_CAPTION,
90 CW_USEDEFAULT, CW_USEDEFAULT,
91 //CW_USEDEFAULT, CW_USEDEFAULT,
93 NULL, NULL, hInst, NULL );
95 ShowWindow( window, nCmdShow );
96 UpdateWindow( window );
98 hAccelTable = LoadAccelerators( hInst, (LPCTSTR)IDC_NIOUP );
100 /* Create a libvlc structure */
101 i_ret = VLC_Create();
104 DestroyWindow( window );
108 /* Initialize libvlc */
109 i_ret = VLC_Init( 0, i_argc, ppsz_argv );
113 DestroyWindow( window );
117 /* Run libvlc, in non-blocking mode */
118 i_ret = VLC_Play( 0 );
120 /* Add a non-blocking interface and keep the return value */
121 i_ret = VLC_AddIntf( 0, NULL, VLC_FALSE );
123 while( GetMessage( &message, NULL, 0, 0 ) )
125 if( !TranslateAccelerator(message.hwnd, hAccelTable, &message) )
127 TranslateMessage( &message );
128 DispatchMessage( &message );
132 /* Kill the threads */
135 /* Finish the threads */
138 /* Destroy the libvlc structure */
141 DestroyWindow( window );
146 /*****************************************************************************
147 * Message handler for the About box.
148 *****************************************************************************/
149 static LRESULT CALLBACK About ( HWND hDlg, UINT message,
150 WPARAM wParam, LPARAM lParam)
153 int DlgWidth, DlgHeight; // dialog width and height in pixel units
154 int NewPosX, NewPosY;
159 /* trying to center the About dialog */
160 if( GetWindowRect( hDlg, &rt1 ) )
162 GetClientRect( GetParent(hDlg), &rt );
163 DlgWidth = rt1.right - rt1.left;
164 DlgHeight = rt1.bottom - rt1.top ;
165 NewPosX = ( rt.right - rt.left - DlgWidth ) / 2;
166 NewPosY = ( rt.bottom - rt.top - DlgHeight ) / 2;
168 /* if the About box is larger than the physical screen */
169 if( NewPosX < 0 ) NewPosX = 0;
170 if( NewPosY < 0 ) NewPosY = 0;
171 SetWindowPos( hDlg, 0, NewPosX, NewPosY,
172 0, 0, SWP_NOZORDER | SWP_NOSIZE );
177 if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
179 EndDialog(hDlg, LOWORD(wParam));
187 /*****************************************************************************
188 * Message handler for the main window
189 *****************************************************************************/
190 static long FAR PASCAL WndProc ( HWND hWnd, UINT message,
191 WPARAM wParam, LPARAM lParam )
200 wmId = LOWORD(wParam);
201 wmEvent = HIWORD(wParam);
202 // Parse the menu selections:
206 DialogBox( hInst, (LPCTSTR)IDD_ABOUTBOX,
207 hWnd, (DLGPROC)About );
210 /* Do random stuff */
216 return DefWindowProc( hWnd, message, wParam, lParam );
220 hwndCB = CommandBar_Create(hInst, hWnd, 1);
221 CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
222 //CommandBar_AddAdornments(hwndCB, 0, 0);
227 hdc = BeginPaint(hWnd, &ps);
228 GetClientRect(hWnd, &rt);
229 DrawText( hdc, L"VLC roulaize!", _tcslen(L"VLC roulaize!"), &rt,
230 DT_SINGLELINE | DT_VCENTER | DT_CENTER );
235 CommandBar_Destroy(hwndCB);
239 return DefWindowProc(hWnd, message, wParam, lParam);