1 /*****************************************************************************
2 * vlc.c: the vlc player, WinCE version
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: vlc.c,v 1.1 2002/11/13 15:28:24 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", 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,
92 NULL, NULL, hInst, NULL );
94 ShowWindow( window, nCmdShow );
95 UpdateWindow( window );
97 hAccelTable = LoadAccelerators( hInst, (LPCTSTR)IDC_NIOUP );
99 /* Create a libvlc structure */
100 i_ret = VLC_Create();
103 DestroyWindow( window );
107 /* Initialize libvlc */
108 i_ret = VLC_Init( 0, i_argc, ppsz_argv );
112 DestroyWindow( window );
116 /* Run libvlc, in non-blocking mode */
117 i_ret = VLC_Play( 0 );
119 /* Add a non-blocking interface and keep the return value */
120 i_ret = VLC_AddIntf( 0, NULL, VLC_FALSE );
122 while( GetMessage( &message, NULL, 0, 0 ) )
124 if( !TranslateAccelerator(message.hwnd, hAccelTable, &message) )
126 TranslateMessage( &message );
127 DispatchMessage( &message );
131 /* Kill the threads */
134 /* Finish the threads */
137 /* Destroy the libvlc structure */
140 DestroyWindow( window );
145 /*****************************************************************************
146 * Message handler for the About box.
147 *****************************************************************************/
148 static LRESULT CALLBACK About ( HWND hDlg, UINT message,
149 WPARAM wParam, LPARAM lParam)
152 int DlgWidth, DlgHeight; // dialog width and height in pixel units
153 int NewPosX, NewPosY;
158 /* trying to center the About dialog */
159 if( GetWindowRect( hDlg, &rt1 ) )
161 GetClientRect( GetParent(hDlg), &rt );
162 DlgWidth = rt1.right - rt1.left;
163 DlgHeight = rt1.bottom - rt1.top ;
164 NewPosX = ( rt.right - rt.left - DlgWidth ) / 2;
165 NewPosY = ( rt.bottom - rt.top - DlgHeight ) / 2;
167 /* if the About box is larger than the physical screen */
168 if( NewPosX < 0 ) NewPosX = 0;
169 if( NewPosY < 0 ) NewPosY = 0;
170 SetWindowPos( hDlg, 0, NewPosX, NewPosY,
171 0, 0, SWP_NOZORDER | SWP_NOSIZE );
176 if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
178 EndDialog(hDlg, LOWORD(wParam));
186 /*****************************************************************************
187 * Message handler for the main window
188 *****************************************************************************/
189 static long FAR PASCAL WndProc ( HWND hWnd, UINT message,
190 WPARAM wParam, LPARAM lParam )
199 wmId = LOWORD(wParam);
200 wmEvent = HIWORD(wParam);
201 // Parse the menu selections:
205 DialogBox( hInst, (LPCTSTR)IDD_ABOUTBOX,
206 hWnd, (DLGPROC)About );
209 /* Do random stuff */
215 return DefWindowProc( hWnd, message, wParam, lParam );
219 hwndCB = CommandBar_Create(hInst, hWnd, 1);
220 CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
221 CommandBar_AddAdornments(hwndCB, 0, 0);
226 hdc = BeginPaint(hWnd, &ps);
227 GetClientRect(hWnd, &rt);
228 DrawText( hdc, L"VLC roulaize!", _tcslen(L"VLC roulaize!"), &rt,
229 DT_SINGLELINE | DT_VCENTER | DT_CENTER );
234 CommandBar_Destroy(hwndCB);
238 return DefWindowProc(hWnd, message, wParam, lParam);