Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
be917909
Commit
be917909
authored
Jan 19, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
view: Convert to Unicode.
parent
c5235eea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
80 deletions
+85
-80
Makefile.in
programs/view/Makefile.in
+2
-1
view.c
programs/view/view.c
+83
-79
No files found.
programs/view/Makefile.in
View file @
be917909
MODULE
=
view.exe
MODULE
=
view.exe
APPMODE
=
-mwindows
APPMODE
=
-mwindows
-municode
EXTRADEFS
=
-DWINE_NO_UNICODE_MACROS
IMPORTS
=
comdlg32 user32 gdi32
IMPORTS
=
comdlg32 user32 gdi32
C_SRCS
=
\
C_SRCS
=
\
...
...
programs/view/view.c
View file @
be917909
...
@@ -24,8 +24,8 @@
...
@@ -24,8 +24,8 @@
static
HINSTANCE
hInst
;
static
HINSTANCE
hInst
;
static
HWND
hMainWnd
;
static
HWND
hMainWnd
;
static
char
szAppName
[
5
]
=
"View"
;
static
WCHAR
szAppName
[
5
]
=
{
'V'
,
'i'
,
'e'
,
'w'
,
0
}
;
static
char
szTitle
[
80
];
static
WCHAR
szTitle
[
80
];
static
HMETAFILE
hmf
;
static
HMETAFILE
hmf
;
static
HENHMETAFILE
enhmf
;
static
HENHMETAFILE
enhmf
;
...
@@ -48,75 +48,88 @@ typedef struct
...
@@ -48,75 +48,88 @@ typedef struct
#define APMHEADER_KEY 0x9AC6CDD7l
#define APMHEADER_KEY 0x9AC6CDD7l
static
BOOL
FileOpen
(
HWND
hWnd
,
char
*
fn
,
int
fnsz
)
static
BOOL
FileOpen
(
HWND
hWnd
,
WCHAR
*
fn
,
int
fnsz
)
{
{
OPENFILENAME
ofn
=
{
sizeof
(
OPENFILENAME
),
static
const
WCHAR
filter
[]
=
{
'M'
,
'e'
,
't'
,
'a'
,
'f'
,
'i'
,
'l'
,
'e'
,
's'
,
'\0'
,
'*'
,
'.'
,
'w'
,
'm'
,
'f'
,
';'
,
'*'
,
'.'
,
'e'
,
'm'
,
'f'
,
'\0'
,
0
};
0
,
0
,
NULL
,
NULL
,
0
,
0
,
NULL
,
OPENFILENAMEW
ofn
=
{
sizeof
(
OPENFILENAMEW
),
fnsz
,
NULL
,
0
,
NULL
,
NULL
,
0
,
0
,
NULL
,
NULL
,
0
,
0
,
NULL
,
OFN_SHOWHELP
,
0
,
0
,
NULL
,
0
,
NULL
};
fnsz
,
NULL
,
0
,
NULL
,
NULL
,
ofn
.
lpstrFilter
=
"Metafiles
\0
*.wmf;*.emf
\0
"
;
OFN_SHOWHELP
,
0
,
0
,
NULL
,
0
,
NULL
};
ofn
.
lpstrFilter
=
filter
;
ofn
.
hwndOwner
=
hWnd
;
ofn
.
hwndOwner
=
hWnd
;
ofn
.
lpstrFile
=
fn
;
ofn
.
lpstrFile
=
fn
;
if
(
fnsz
<
1
)
if
(
fnsz
<
1
)
return
FALSE
;
return
FALSE
;
*
fn
=
0
;
*
fn
=
0
;
return
GetOpenFileName
(
&
ofn
);
return
GetOpenFileName
W
(
&
ofn
);
}
}
static
BOOL
FileIsEnhanced
(
LPCSTR
szFileName
)
static
BOOL
FileIsEnhanced
(
LPC
W
STR
szFileName
)
{
{
HFILE
hInFile
;
ENHMETAHEADER
enh
;
ENHMETAHEADER
enh
;
HANDLE
handle
;
DWORD
size
;
if
(
(
hInFile
=
_lopen
(
szFileName
,
OF_READ
)
)
==
HFILE_ERROR
)
handle
=
CreateFileW
(
szFileName
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
0
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
return
FALSE
;
if
(
_lread
(
hInFile
,
&
enh
,
sizeof
(
ENHMETAHEADER
)
)
!=
sizeof
(
ENHMETAHEADER
)
)
if
(
!
ReadFile
(
handle
,
&
enh
,
sizeof
(
ENHMETAHEADER
),
&
size
,
NULL
)
||
size
!=
sizeof
(
ENHMETAHEADER
)
)
{
{
_lclose
(
hInFi
le
);
CloseHandle
(
hand
le
);
return
FALSE
;
return
FALSE
;
}
}
_lclose
(
hInFi
le
);
CloseHandle
(
hand
le
);
/* Is it enhanced? */
/* Is it enhanced? */
return
(
enh
.
dSignature
==
ENHMETA_SIGNATURE
);
return
(
enh
.
dSignature
==
ENHMETA_SIGNATURE
);
}
}
static
BOOL
FileIsPlaceable
(
LPCSTR
szFileName
)
static
BOOL
FileIsPlaceable
(
LPC
W
STR
szFileName
)
{
{
HFILE
hInFile
;
APMFILEHEADER
apmh
;
APMFILEHEADER
apmh
;
HANDLE
handle
;
DWORD
size
;
if
(
(
hInFile
=
_lopen
(
szFileName
,
OF_READ
)
)
==
HFILE_ERROR
)
handle
=
CreateFileW
(
szFileName
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
0
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
return
FALSE
;
if
(
_lread
(
hInFile
,
&
apmh
,
sizeof
(
APMFILEHEADER
)
)
if
(
!
ReadFile
(
handle
,
&
apmh
,
sizeof
(
APMFILEHEADER
),
&
size
,
NULL
)
||
size
!=
sizeof
(
APMFILEHEADER
))
!=
sizeof
(
APMFILEHEADER
)
)
{
{
CloseHandle
(
handle
);
_lclose
(
hInFile
);
return
FALSE
;
return
FALSE
;
}
}
_lclose
(
hInFi
le
);
CloseHandle
(
hand
le
);
/* Is it placeable? */
/* Is it placeable? */
return
(
apmh
.
key
==
APMHEADER_KEY
);
return
(
apmh
.
key
==
APMHEADER_KEY
);
}
}
static
HMETAFILE
GetPlaceableMetaFile
(
LPCSTR
szFileName
)
static
HMETAFILE
GetPlaceableMetaFile
(
LPC
W
STR
szFileName
)
{
{
LPBYTE
lpData
;
LPBYTE
lpData
;
METAHEADER
mfHeader
;
METAHEADER
mfHeader
;
APMFILEHEADER
APMHeader
;
APMFILEHEADER
APMHeader
;
HFILE
fh
;
HANDLE
handle
;
DWORD
size
;
HMETAFILE
hmf
;
HMETAFILE
hmf
;
WORD
checksum
,
*
p
;
WORD
checksum
,
*
p
;
HDC
hdc
;
HDC
hdc
;
int
i
;
int
i
;
if
(
(
fh
=
_lopen
(
szFileName
,
OF_READ
)
)
==
HFILE_ERROR
)
return
0
;
handle
=
CreateFileW
(
szFileName
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
_llseek
(
fh
,
0
,
0
);
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
0
);
if
(
!
_lread
(
fh
,
&
APMHeader
,
sizeof
(
APMFILEHEADER
)))
return
0
;
if
(
handle
==
INVALID_HANDLE_VALUE
)
_llseek
(
fh
,
sizeof
(
APMFILEHEADER
),
0
);
return
0
;
if
(
!
ReadFile
(
handle
,
&
APMHeader
,
sizeof
(
APMFILEHEADER
),
&
size
,
NULL
)
||
size
!=
sizeof
(
APMFILEHEADER
))
{
CloseHandle
(
handle
);
return
0
;
}
checksum
=
0
;
checksum
=
0
;
p
=
(
WORD
*
)
&
APMHeader
;
p
=
(
WORD
*
)
&
APMHeader
;
...
@@ -126,22 +139,31 @@ static HMETAFILE GetPlaceableMetaFile( LPCSTR szFileName )
...
@@ -126,22 +139,31 @@ static HMETAFILE GetPlaceableMetaFile( LPCSTR szFileName )
char
msg
[
128
];
char
msg
[
128
];
sprintf
(
msg
,
"Computed checksum %04x != stored checksum %04x
\n
"
,
sprintf
(
msg
,
"Computed checksum %04x != stored checksum %04x
\n
"
,
checksum
,
APMHeader
.
checksum
);
checksum
,
APMHeader
.
checksum
);
MessageBox
(
hMainWnd
,
msg
,
"Checksum failed"
,
MB_OK
);
MessageBoxA
(
hMainWnd
,
msg
,
"Checksum failed"
,
MB_OK
);
CloseHandle
(
handle
);
return
0
;
return
0
;
}
}
if
(
!
_lread
(
fh
,
&
mfHeader
,
sizeof
(
METAHEADER
)))
return
0
;
if
(
!
ReadFile
(
handle
,
&
mfHeader
,
sizeof
(
METAHEADER
),
&
size
,
NULL
)
||
size
!=
sizeof
(
METAHEADER
))
{
CloseHandle
(
handle
);
return
0
;
}
if
(
!
(
lpData
=
GlobalAlloc
(
GPTR
,
(
mfHeader
.
mtSize
*
2L
))))
return
0
;
if
(
!
(
lpData
=
GlobalAlloc
(
GPTR
,
(
mfHeader
.
mtSize
*
2L
))))
{
CloseHandle
(
handle
);
return
0
;
}
_llseek
(
fh
,
sizeof
(
APMFILEHEADER
),
0
);
SetFilePointer
(
handle
,
sizeof
(
APMFILEHEADER
),
NULL
,
FILE_BEGIN
);
if
(
!
_lread
(
fh
,
lpData
,
(
UINT
)(
mfHeader
.
mtSize
*
2L
))
)
if
(
!
ReadFile
(
handle
,
lpData
,
mfHeader
.
mtSize
*
2
,
&
size
,
NULL
)
||
size
!=
mfHeader
.
mtSize
*
2
)
{
{
GlobalFree
(
lpData
);
GlobalFree
(
lpData
);
_lclose
(
fh
);
CloseHandle
(
handle
);
return
0
;
return
0
;
}
}
_lclose
(
fh
);
CloseHandle
(
handle
);
if
(
!
(
hmf
=
SetMetaFileBitsEx
(
mfHeader
.
mtSize
*
2
,
lpData
)))
if
(
!
(
hmf
=
SetMetaFileBitsEx
(
mfHeader
.
mtSize
*
2
,
lpData
)))
return
0
;
return
0
;
...
@@ -161,7 +183,7 @@ static HMETAFILE GetPlaceableMetaFile( LPCSTR szFileName )
...
@@ -161,7 +183,7 @@ static HMETAFILE GetPlaceableMetaFile( LPCSTR szFileName )
return
hmf
;
return
hmf
;
}
}
static
void
DoOpenFile
(
LPCSTR
filename
)
static
void
DoOpenFile
(
LPC
W
STR
filename
)
{
{
if
(
!
filename
)
return
;
if
(
!
filename
)
return
;
...
@@ -172,9 +194,9 @@ static void DoOpenFile(LPCSTR filename)
...
@@ -172,9 +194,9 @@ static void DoOpenFile(LPCSTR filename)
RECT
r
;
RECT
r
;
isEnhanced
=
FileIsEnhanced
(
filename
);
isEnhanced
=
FileIsEnhanced
(
filename
);
if
(
isEnhanced
)
if
(
isEnhanced
)
enhmf
=
GetEnhMetaFile
(
filename
);
enhmf
=
GetEnhMetaFile
W
(
filename
);
else
else
hmf
=
GetMetaFile
(
filename
);
hmf
=
GetMetaFile
W
(
filename
);
GetClientRect
(
hMainWnd
,
&
r
);
GetClientRect
(
hMainWnd
,
&
r
);
width
=
r
.
right
-
r
.
left
;
width
=
r
.
right
-
r
.
left
;
height
=
r
.
bottom
-
r
.
top
;
height
=
r
.
bottom
-
r
.
top
;
...
@@ -212,9 +234,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
...
@@ -212,9 +234,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
{
{
case
IDM_OPEN
:
case
IDM_OPEN
:
{
{
char
filename
[
MAX_PATH
];
WCHAR
filename
[
MAX_PATH
];
if
(
FileOpen
(
hwnd
,
filename
,
sizeof
(
filename
)))
if
(
FileOpen
(
hwnd
,
filename
,
sizeof
(
filename
)
/
sizeof
(
WCHAR
)))
DoOpenFile
(
filename
);
DoOpenFile
(
filename
);
}
}
break
;
break
;
...
@@ -252,7 +274,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
...
@@ -252,7 +274,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
break
;
break
;
default:
default:
return
DefWindowProc
(
hwnd
,
uMessage
,
wparam
,
lparam
);
return
DefWindowProc
W
(
hwnd
,
uMessage
,
wparam
,
lparam
);
}
}
break
;
break
;
...
@@ -261,22 +283,22 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
...
@@ -261,22 +283,22 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM
break
;
break
;
default:
/* Passes it on if unprocessed */
default:
/* Passes it on if unprocessed */
return
DefWindowProc
(
hwnd
,
uMessage
,
wparam
,
lparam
);
return
DefWindowProc
W
(
hwnd
,
uMessage
,
wparam
,
lparam
);
}
}
return
0
;
return
0
;
}
}
static
BOOL
InitApplication
(
HINSTANCE
hInstance
)
static
BOOL
InitApplication
(
HINSTANCE
hInstance
)
{
{
WNDCLASSEX
wc
;
WNDCLASSEX
W
wc
;
/* Load the application description strings */
/* Load the application description strings */
LoadString
(
hInstance
,
IDS_DESCRIPTION
,
szTitle
,
sizeof
(
szTitle
));
LoadString
W
(
hInstance
,
IDS_DESCRIPTION
,
szTitle
,
sizeof
(
szTitle
)
/
sizeof
(
WCHAR
));
/* Fill in window class structure with parameters that describe the
/* Fill in window class structure with parameters that describe the
main window */
main window */
wc
.
cbSize
=
sizeof
(
WNDCLASSEX
);
wc
.
cbSize
=
sizeof
(
WNDCLASSEXW
);
wc
.
style
=
CS_HREDRAW
|
CS_VREDRAW
;
/* Class style(s) */
wc
.
style
=
CS_HREDRAW
|
CS_VREDRAW
;
/* Class style(s) */
wc
.
lpfnWndProc
=
WndProc
;
/* Window Procedure */
wc
.
lpfnWndProc
=
WndProc
;
/* Window Procedure */
wc
.
cbClsExtra
=
0
;
/* No per-class extra data */
wc
.
cbClsExtra
=
0
;
/* No per-class extra data */
...
@@ -284,18 +306,12 @@ static BOOL InitApplication(HINSTANCE hInstance)
...
@@ -284,18 +306,12 @@ static BOOL InitApplication(HINSTANCE hInstance)
wc
.
hInstance
=
hInstance
;
/* Owner of this class */
wc
.
hInstance
=
hInstance
;
/* Owner of this class */
wc
.
hIcon
=
NULL
;
wc
.
hIcon
=
NULL
;
wc
.
hIconSm
=
NULL
;
wc
.
hIconSm
=
NULL
;
wc
.
hCursor
=
LoadCursor
(
NULL
,
IDC_ARROW
);
/* Cursor */
wc
.
hCursor
=
LoadCursor
W
(
NULL
,
(
LPWSTR
)
IDC_ARROW
);
wc
.
hbrBackground
=
(
HBRUSH
)(
COLOR_WINDOW
+
1
);
/* Default color */
wc
.
hbrBackground
=
(
HBRUSH
)(
COLOR_WINDOW
+
1
);
/* Default color */
wc
.
lpszMenuName
=
szAppName
;
/* Menu name from .rc */
wc
.
lpszMenuName
=
szAppName
;
/* Menu name from .rc */
wc
.
lpszClassName
=
szAppName
;
/* Name to register as */
wc
.
lpszClassName
=
szAppName
;
/* Name to register as */
/* Register the window class and return FALSE if unsuccessful */
if
(
!
RegisterClassExW
(
&
wc
))
return
FALSE
;
if
(
!
RegisterClassEx
(
&
wc
))
{
if
(
!
RegisterClass
((
LPWNDCLASS
)
&
wc
.
style
))
return
FALSE
;
}
/* Call module specific initialization functions here */
/* Call module specific initialization functions here */
...
@@ -308,7 +324,7 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
...
@@ -308,7 +324,7 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
hInst
=
hInstance
;
hInst
=
hInstance
;
/* Create main window */
/* Create main window */
hMainWnd
=
CreateWindow
(
szAppName
,
/* See RegisterClass() call */
hMainWnd
=
CreateWindow
W
(
szAppName
,
/* See RegisterClass() call */
szTitle
,
/* window title */
szTitle
,
/* window title */
WS_OVERLAPPEDWINDOW
,
/* Window style */
WS_OVERLAPPEDWINDOW
,
/* Window style */
CW_USEDEFAULT
,
0
,
/* positioning */
CW_USEDEFAULT
,
0
,
/* positioning */
...
@@ -330,36 +346,24 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
...
@@ -330,36 +346,24 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
return
TRUE
;
return
TRUE
;
}
}
static
void
HandleCommandLine
(
LPSTR
cmdline
)
static
void
HandleCommandLine
(
LP
W
STR
cmdline
)
{
{
CHAR
delimiter
;
/* skip white space */
/* skip white space */
while
(
*
cmdline
==
' '
)
cmdline
++
;
while
(
*
cmdline
==
' '
)
cmdline
++
;
/* skip executable name */
delimiter
=
(
*
cmdline
==
'"'
?
'"'
:
' '
);
if
(
*
cmdline
==
delimiter
)
cmdline
++
;
while
(
*
cmdline
&&
*
cmdline
!=
delimiter
)
cmdline
++
;
if
(
*
cmdline
==
delimiter
)
cmdline
++
;
if
(
*
cmdline
)
if
(
*
cmdline
)
{
{
/* file name is passed on the command line */
/* file name is passed on the command line */
if
(
cmdline
[
0
]
==
'"'
)
if
(
cmdline
[
0
]
==
'"'
)
{
{
cmdline
++
;
cmdline
++
;
cmdline
[
lstrlen
(
cmdline
)
-
1
]
=
0
;
cmdline
[
lstrlen
W
(
cmdline
)
-
1
]
=
0
;
}
}
DoOpenFile
(
cmdline
);
DoOpenFile
(
cmdline
);
}
}
}
}
int
APIENTRY
WinMain
(
HINSTANCE
hInstance
,
int
APIENTRY
wWinMain
(
HINSTANCE
hInstance
,
HINSTANCE
hPrevInstance
,
LPWSTR
lpCmdLine
,
int
nCmdShow
)
HINSTANCE
hPrevInstance
,
LPSTR
lpCmdLine
,
int
nCmdShow
)
{
{
MSG
msg
;
MSG
msg
;
HANDLE
hAccelTable
;
HANDLE
hAccelTable
;
...
@@ -380,21 +384,21 @@ int APIENTRY WinMain(HINSTANCE hInstance,
...
@@ -380,21 +384,21 @@ int APIENTRY WinMain(HINSTANCE hInstance,
return
FALSE
;
return
FALSE
;
}
}
HandleCommandLine
(
GetCommandLine
()
);
HandleCommandLine
(
lpCmdLine
);
hAccelTable
=
LoadAccelerators
(
hInstance
,
szAppName
);
hAccelTable
=
LoadAccelerators
W
(
hInstance
,
szAppName
);
/* Main loop */
/* Main loop */
/* Acquire and dispatch messages until a WM_QUIT message is received */
/* Acquire and dispatch messages until a WM_QUIT message is received */
while
(
GetMessage
(
&
msg
,
NULL
,
0
,
0
))
while
(
GetMessage
W
(
&
msg
,
NULL
,
0
,
0
))
{
{
/* Add other Translation functions (for modeless dialogs
/* Add other Translation functions (for modeless dialogs
and/or MDI windows) here. */
and/or MDI windows) here. */
if
(
!
TranslateAccelerator
(
msg
.
hwnd
,
hAccelTable
,
&
msg
))
if
(
!
TranslateAccelerator
W
(
msg
.
hwnd
,
hAccelTable
,
&
msg
))
{
{
TranslateMessage
(
&
msg
);
TranslateMessage
(
&
msg
);
DispatchMessage
(
&
msg
);
DispatchMessage
W
(
&
msg
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment