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
58b007b0
Commit
58b007b0
authored
Dec 09, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clock: Convert to Unicode.
parent
305fcef6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
55 deletions
+56
-55
Makefile.in
programs/clock/Makefile.in
+1
-0
main.c
programs/clock/main.c
+39
-38
main.h
programs/clock/main.h
+1
-1
winclock.c
programs/clock/winclock.c
+14
-15
winclock.h
programs/clock/winclock.h
+1
-1
No files found.
programs/clock/Makefile.in
View file @
58b007b0
...
...
@@ -5,6 +5,7 @@ VPATH = @srcdir@
MODULE
=
clock.exe
APPMODE
=
-mwindows
IMPORTS
=
comdlg32 shell32 user32 gdi32 kernel32
EXTRADEFS
=
-DWINE_NO_UNICODE_MACROS
C_SRCS
=
\
main.c
\
...
...
programs/clock/main.c
View file @
58b007b0
...
...
@@ -38,18 +38,18 @@ CLOCK_GLOBALS Globals;
static
VOID
WineLicense
(
HWND
Wnd
)
{
char
cap
[
20
],
text
[
1024
];
LoadString
(
Globals
.
hInstance
,
IDS_LICENSE
,
text
,
sizeof
text
);
LoadString
(
Globals
.
hInstance
,
IDS_LICENSE_CAPTION
,
cap
,
sizeof
cap
);
MessageBox
(
Wnd
,
text
,
cap
,
MB_ICONINFORMATION
|
MB_OK
);
WCHAR
cap
[
20
],
text
[
1024
];
LoadString
W
(
Globals
.
hInstance
,
IDS_LICENSE
,
text
,
sizeof
(
text
)
/
sizeof
(
WCHAR
)
);
LoadString
W
(
Globals
.
hInstance
,
IDS_LICENSE_CAPTION
,
cap
,
sizeof
(
cap
)
/
sizeof
(
WCHAR
)
);
MessageBox
W
(
Wnd
,
text
,
cap
,
MB_ICONINFORMATION
|
MB_OK
);
}
static
VOID
WineWarranty
(
HWND
Wnd
)
{
char
cap
[
20
],
text
[
1024
];
LoadString
(
Globals
.
hInstance
,
IDS_WARRANTY
,
text
,
sizeof
text
);
LoadString
(
Globals
.
hInstance
,
IDS_WARRANTY_CAPTION
,
cap
,
sizeof
cap
);
MessageBox
(
Wnd
,
text
,
cap
,
MB_ICONEXCLAMATION
|
MB_OK
);
WCHAR
cap
[
20
],
text
[
1024
];
LoadString
W
(
Globals
.
hInstance
,
IDS_WARRANTY
,
text
,
sizeof
(
text
)
/
sizeof
(
WCHAR
)
);
LoadString
W
(
Globals
.
hInstance
,
IDS_WARRANTY_CAPTION
,
cap
,
sizeof
(
cap
)
/
sizeof
(
WCHAR
)
);
MessageBox
W
(
Wnd
,
text
,
cap
,
MB_ICONEXCLAMATION
|
MB_OK
);
}
static
VOID
CLOCK_UpdateMenuCheckmarks
(
VOID
)
...
...
@@ -81,13 +81,13 @@ static VOID CLOCK_UpdateMenuCheckmarks(VOID)
static
VOID
CLOCK_UpdateWindowCaption
(
VOID
)
{
CHAR
szCaption
[
MAX_STRING_LEN
];
W
CHAR
szCaption
[
MAX_STRING_LEN
];
int
chars
=
0
;
/* Set frame caption */
if
(
Globals
.
bDate
)
{
chars
=
GetDateFormat
(
LOCALE_USER_DEFAULT
,
DATE_LONGDATE
,
NULL
,
NULL
,
szCaption
,
sizeof
(
szCaption
));
chars
=
GetDateFormat
W
(
LOCALE_USER_DEFAULT
,
DATE_LONGDATE
,
NULL
,
NULL
,
szCaption
,
sizeof
(
szCaption
)
/
sizeof
(
WCHAR
));
if
(
chars
)
{
--
chars
;
szCaption
[
chars
++
]
=
' '
;
...
...
@@ -96,8 +96,8 @@ static VOID CLOCK_UpdateWindowCaption(VOID)
szCaption
[
chars
]
=
'\0'
;
}
}
LoadString
(
0
,
IDS_CLOCK
,
szCaption
+
chars
,
sizeof
(
szCaption
)
-
chars
);
SetWindowText
(
Globals
.
hMainWnd
,
szCaption
);
LoadString
W
(
0
,
IDS_CLOCK
,
szCaption
+
chars
,
MAX_STRING_LEN
-
chars
);
SetWindowText
W
(
Globals
.
hMainWnd
,
szCaption
);
}
/***********************************************************************
...
...
@@ -119,9 +119,10 @@ static BOOL CLOCK_ResetTimer(void)
period
=
1000
;
if
(
!
SetTimer
(
Globals
.
hMainWnd
,
TIMER_ID
,
period
,
NULL
))
{
CHAR
szApp
[
MAX_STRING_LEN
];
LoadString
(
Globals
.
hInstance
,
IDS_CLOCK
,
szApp
,
sizeof
(
szApp
));
MessageBox
(
0
,
"No available timers"
,
szApp
,
MB_ICONEXCLAMATION
|
MB_OK
);
static
const
WCHAR
notimersW
[]
=
{
'N'
,
'o'
,
' '
,
'a'
,
'v'
,
'a'
,
'i'
,
'l'
,
'a'
,
'b'
,
'l'
,
'e'
,
' '
,
't'
,
'i'
,
'm'
,
'e'
,
'r'
,
's'
,
0
};
WCHAR
szApp
[
MAX_STRING_LEN
];
LoadStringW
(
Globals
.
hInstance
,
IDS_CLOCK
,
szApp
,
MAX_STRING_LEN
);
MessageBoxW
(
0
,
notimersW
,
szApp
,
MB_ICONEXCLAMATION
|
MB_OK
);
return
FALSE
;
}
return
TRUE
;
...
...
@@ -151,15 +152,15 @@ static VOID CLOCK_ResetFont(VOID)
*/
static
VOID
CLOCK_ChooseFont
(
VOID
)
{
LOGFONT
lf
;
CHOOSEFONT
cf
;
LOGFONT
W
lf
;
CHOOSEFONT
W
cf
;
memset
(
&
cf
,
0
,
sizeof
(
cf
));
lf
=
Globals
.
logfont
;
cf
.
lStructSize
=
sizeof
(
cf
);
cf
.
hwndOwner
=
Globals
.
hMainWnd
;
cf
.
lpLogFont
=
&
lf
;
cf
.
Flags
=
CF_SCREENFONTS
|
CF_INITTOLOGFONTSTRUCT
;
if
(
ChooseFont
(
&
cf
))
{
if
(
ChooseFont
W
(
&
cf
))
{
Globals
.
logfont
=
lf
;
CLOCK_ResetFont
();
}
...
...
@@ -172,7 +173,7 @@ static VOID CLOCK_ChooseFont(VOID)
static
VOID
CLOCK_ToggleTitle
(
VOID
)
{
/* Also shows/hides the menu */
LONG
style
=
GetWindowLong
(
Globals
.
hMainWnd
,
GWL_STYLE
);
LONG
style
=
GetWindowLong
W
(
Globals
.
hMainWnd
,
GWL_STYLE
);
if
((
Globals
.
bWithoutTitle
=
!
Globals
.
bWithoutTitle
))
{
style
=
(
style
&
~
WS_OVERLAPPEDWINDOW
)
|
WS_POPUP
|
WS_THICKFRAME
;
SetMenu
(
Globals
.
hMainWnd
,
0
);
...
...
@@ -182,7 +183,7 @@ static VOID CLOCK_ToggleTitle(VOID)
SetMenu
(
Globals
.
hMainWnd
,
Globals
.
hMainMenu
);
SetWindowRgn
(
Globals
.
hMainWnd
,
0
,
TRUE
);
}
SetWindowLong
(
Globals
.
hMainWnd
,
GWL_STYLE
,
style
);
SetWindowLong
W
(
Globals
.
hMainWnd
,
GWL_STYLE
,
style
);
SetWindowPos
(
Globals
.
hMainWnd
,
0
,
0
,
0
,
0
,
0
,
SWP_DRAWFRAME
|
SWP_NOMOVE
|
SWP_NOSIZE
|
SWP_NOZORDER
);
...
...
@@ -215,8 +216,8 @@ static VOID CLOCK_ToggleOnTop(VOID)
static
int
CLOCK_MenuCommand
(
WPARAM
wParam
)
{
CHAR
szApp
[
MAX_STRING_LEN
];
CHAR
szAppRelease
[
MAX_STRING_LEN
];
W
CHAR
szApp
[
MAX_STRING_LEN
];
W
CHAR
szAppRelease
[
MAX_STRING_LEN
];
switch
(
wParam
)
{
/* switch to analog */
case
IDM_ANALOG
:
{
...
...
@@ -279,9 +280,9 @@ static int CLOCK_MenuCommand (WPARAM wParam)
}
/* show "about" box */
case
IDM_ABOUT
:
{
LoadString
(
Globals
.
hInstance
,
IDS_CLOCK
,
szApp
,
sizeof
(
szApp
));
lstrcpy
(
szAppRelease
,
szApp
);
ShellAbout
(
Globals
.
hMainWnd
,
szApp
,
szAppRelease
,
0
);
LoadString
W
(
Globals
.
hInstance
,
IDS_CLOCK
,
szApp
,
sizeof
(
szApp
)
/
sizeof
(
WCHAR
));
lstrcpy
W
(
szAppRelease
,
szApp
);
ShellAbout
W
(
Globals
.
hMainWnd
,
szApp
,
szAppRelease
,
0
);
break
;
}
}
...
...
@@ -341,7 +342,7 @@ static LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
switch
(
msg
)
{
/* L button drag moves the window */
case
WM_NCHITTEST
:
{
LRESULT
ret
=
DefWindowProc
(
hWnd
,
msg
,
wParam
,
lParam
);
LRESULT
ret
=
DefWindowProc
W
(
hWnd
,
msg
,
wParam
,
lParam
);
if
(
ret
==
HTCLIENT
)
ret
=
HTCAPTION
;
return
ret
;
...
...
@@ -398,7 +399,7 @@ static LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
}
default:
return
DefWindowProc
(
hWnd
,
msg
,
wParam
,
lParam
);
return
DefWindowProc
W
(
hWnd
,
msg
,
wParam
,
lParam
);
}
return
0
;
}
...
...
@@ -412,10 +413,10 @@ static LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
int
PASCAL
WinMain
(
HINSTANCE
hInstance
,
HINSTANCE
prev
,
LPSTR
cmdline
,
int
show
)
{
MSG
msg
;
WNDCLASS
class
;
WNDCLASS
W
class
;
static
const
char
szClassName
[]
=
"CLClass"
;
/* To make sure className >= 0x10000 */
static
const
char
szWinName
[]
=
"Clock"
;
static
const
WCHAR
szClassName
[]
=
{
'C'
,
'L'
,
'C'
,
'l'
,
'a'
,
's'
,
's'
,
0
};
static
const
WCHAR
szWinName
[]
=
{
'C'
,
'l'
,
'o'
,
'c'
,
'k'
,
0
}
;
/* Setup Globals */
memset
(
&
Globals
.
hFont
,
0
,
sizeof
(
Globals
.
hFont
));
...
...
@@ -428,17 +429,17 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
class
.
cbClsExtra
=
0
;
class
.
cbWndExtra
=
0
;
class
.
hInstance
=
hInstance
;
class
.
hIcon
=
LoadIcon
(
0
,
IDI_APPLICATION
);
class
.
hCursor
=
LoadCursor
(
0
,
IDC_ARROW
);
class
.
hIcon
=
LoadIcon
W
(
0
,
(
LPCWSTR
)
IDI_APPLICATION
);
class
.
hCursor
=
LoadCursor
W
(
0
,
(
LPCWSTR
)
IDC_ARROW
);
class
.
hbrBackground
=
0
;
class
.
lpszMenuName
=
0
;
class
.
lpszClassName
=
szClassName
;
}
if
(
!
RegisterClass
(
&
class
))
return
FALSE
;
if
(
!
RegisterClass
W
(
&
class
))
return
FALSE
;
Globals
.
MaxX
=
Globals
.
MaxY
=
INITIAL_WINDOW_SIZE
;
Globals
.
hMainWnd
=
CreateWindow
(
szClassName
,
szWinName
,
WS_OVERLAPPEDWINDOW
,
Globals
.
hMainWnd
=
CreateWindow
W
(
szClassName
,
szWinName
,
WS_OVERLAPPEDWINDOW
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
Globals
.
MaxX
,
Globals
.
MaxY
,
0
,
0
,
hInstance
,
0
);
...
...
@@ -446,7 +447,7 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
if
(
!
CLOCK_ResetTimer
())
return
FALSE
;
Globals
.
hMainMenu
=
LoadMenu
(
0
,
MAKEINTRESOURCE
(
MAIN_MENU
));
Globals
.
hMainMenu
=
LoadMenu
W
(
0
,
MAKEINTRESOURCEW
(
MAIN_MENU
));
SetMenu
(
Globals
.
hMainWnd
,
Globals
.
hMainMenu
);
CLOCK_UpdateMenuCheckmarks
();
CLOCK_UpdateWindowCaption
();
...
...
@@ -454,9 +455,9 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
ShowWindow
(
Globals
.
hMainWnd
,
show
);
UpdateWindow
(
Globals
.
hMainWnd
);
while
(
GetMessage
(
&
msg
,
0
,
0
,
0
))
{
while
(
GetMessage
W
(
&
msg
,
0
,
0
,
0
))
{
TranslateMessage
(
&
msg
);
DispatchMessage
(
&
msg
);
DispatchMessage
W
(
&
msg
);
}
KillTimer
(
Globals
.
hMainWnd
,
TIMER_ID
);
...
...
programs/clock/main.h
View file @
58b007b0
...
...
@@ -25,7 +25,7 @@
typedef
struct
{
LOGFONT
logfont
;
LOGFONT
W
logfont
;
HFONT
hFont
;
HANDLE
hInstance
;
HWND
hMainWnd
;
...
...
programs/clock/winclock.c
View file @
58b007b0
...
...
@@ -177,17 +177,17 @@ void AnalogClock(HDC dc, int x, int y, BOOL bSeconds, BOOL border)
}
HFONT
SizeFont
(
HDC
dc
,
int
x
,
int
y
,
BOOL
bSeconds
,
const
LOGFONT
*
font
)
HFONT
SizeFont
(
HDC
dc
,
int
x
,
int
y
,
BOOL
bSeconds
,
const
LOGFONT
W
*
font
)
{
SIZE
extent
;
LOGFONT
lf
;
LOGFONT
W
lf
;
double
xscale
,
yscale
;
HFONT
oldFont
,
newFont
;
CHAR
szTime
[
255
];
W
CHAR
szTime
[
255
];
int
chars
;
chars
=
GetTimeFormat
(
LOCALE_USER_DEFAULT
,
bSeconds
?
0
:
TIME_NOSECONDS
,
NULL
,
NULL
,
szTime
,
sizeof
(
szTime
));
chars
=
GetTimeFormat
W
(
LOCALE_USER_DEFAULT
,
bSeconds
?
0
:
TIME_NOSECONDS
,
NULL
,
NULL
,
szTime
,
sizeof
(
szTime
)
/
sizeof
(
WCHAR
));
if
(
!
chars
)
return
0
;
...
...
@@ -199,14 +199,14 @@ HFONT SizeFont(HDC dc, int x, int y, BOOL bSeconds, const LOGFONT* font)
x
-=
2
*
SHADOW_DEPTH
;
y
-=
2
*
SHADOW_DEPTH
;
oldFont
=
SelectObject
(
dc
,
CreateFontIndirect
(
&
lf
));
GetTextExtentPoint
(
dc
,
szTime
,
chars
,
&
extent
);
oldFont
=
SelectObject
(
dc
,
CreateFontIndirect
W
(
&
lf
));
GetTextExtentPoint
W
(
dc
,
szTime
,
chars
,
&
extent
);
DeleteObject
(
SelectObject
(
dc
,
oldFont
));
xscale
=
(
double
)
x
/
extent
.
cx
;
yscale
=
(
double
)
y
/
extent
.
cy
;
lf
.
lfHeight
*=
min
(
xscale
,
yscale
);
newFont
=
CreateFontIndirect
(
&
lf
);
newFont
=
CreateFontIndirect
W
(
&
lf
);
return
newFont
;
}
...
...
@@ -215,26 +215,25 @@ void DigitalClock(HDC dc, int x, int y, BOOL bSeconds, HFONT font)
{
SIZE
extent
;
HFONT
oldFont
;
CHAR
szTime
[
255
];
W
CHAR
szTime
[
255
];
int
chars
;
chars
=
GetTimeFormat
(
LOCALE_USER_DEFAULT
,
bSeconds
?
0
:
TIME_NOSECONDS
,
NULL
,
NULL
,
szTime
,
sizeof
(
szTime
));
chars
=
GetTimeFormat
W
(
LOCALE_USER_DEFAULT
,
bSeconds
?
0
:
TIME_NOSECONDS
,
NULL
,
NULL
,
szTime
,
sizeof
(
szTime
)
/
sizeof
(
WCHAR
));
if
(
!
chars
)
return
;
--
chars
;
oldFont
=
SelectObject
(
dc
,
font
);
GetTextExtentPoint
(
dc
,
szTime
,
chars
,
&
extent
);
GetTextExtentPoint
W
(
dc
,
szTime
,
chars
,
&
extent
);
SetBkColor
(
dc
,
BackgroundColor
);
SetTextColor
(
dc
,
ShadowColor
);
TextOut
(
dc
,
(
x
-
extent
.
cx
)
/
2
+
SHADOW_DEPTH
,
(
y
-
extent
.
cy
)
/
2
+
SHADOW_DEPTH
,
szTime
,
chars
);
TextOutW
(
dc
,
(
x
-
extent
.
cx
)
/
2
+
SHADOW_DEPTH
,
(
y
-
extent
.
cy
)
/
2
+
SHADOW_DEPTH
,
szTime
,
chars
);
SetBkMode
(
dc
,
TRANSPARENT
);
SetTextColor
(
dc
,
HandColor
);
TextOut
(
dc
,
(
x
-
extent
.
cx
)
/
2
,
(
y
-
extent
.
cy
)
/
2
,
szTime
,
chars
);
TextOut
W
(
dc
,
(
x
-
extent
.
cx
)
/
2
,
(
y
-
extent
.
cy
)
/
2
,
szTime
,
chars
);
SelectObject
(
dc
,
oldFont
);
}
programs/clock/winclock.h
View file @
58b007b0
...
...
@@ -22,5 +22,5 @@
*/
void
AnalogClock
(
HDC
dc
,
int
X
,
int
Y
,
BOOL
bSeconds
,
BOOL
border
);
HFONT
SizeFont
(
HDC
dc
,
int
x
,
int
y
,
BOOL
bSeconds
,
const
LOGFONT
*
font
);
HFONT
SizeFont
(
HDC
dc
,
int
x
,
int
y
,
BOOL
bSeconds
,
const
LOGFONT
W
*
font
);
void
DigitalClock
(
HDC
dc
,
int
X
,
int
Y
,
BOOL
bSeconds
,
HFONT
font
);
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