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
cd5a04fd
Commit
cd5a04fd
authored
Oct 24, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notepad: Fallback to default position if saved position if off-screen.
parent
1dc38cf2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
29 deletions
+36
-29
main.c
programs/notepad/main.c
+36
-24
main.h
programs/notepad/main.h
+0
-5
No files found.
programs/notepad/main.c
View file @
cd5a04fd
...
...
@@ -34,6 +34,7 @@
NOTEPAD_GLOBALS
Globals
;
static
ATOM
aFINDMSGSTRING
;
static
RECT
main_rect
;
static
const
WCHAR
notepad_reg_key
[]
=
{
'S'
,
'o'
,
'f'
,
't'
,
'w'
,
'a'
,
'r'
,
'e'
,
'\\'
,
'M'
,
'i'
,
'c'
,
'r'
,
'o'
,
's'
,
'o'
,
'f'
,
't'
,
'\\'
,
'N'
,
'o'
,
't'
,
'e'
,
'p'
,
'a'
,
'd'
,
'\0'
};
...
...
@@ -111,20 +112,15 @@ static VOID NOTEPAD_SaveSettingToRegistry(void)
REG_OPTION_NON_VOLATILE
,
KEY_ALL_ACCESS
,
NULL
,
&
hkey
,
&
disp
)
==
ERROR_SUCCESS
)
{
DWORD
data
;
RECT
rect
;
GetWindowRect
(
Globals
.
hMainWnd
,
&
rect
);
Globals
.
iWindowPosX
=
rect
.
left
;
Globals
.
iWindowPosY
=
rect
.
top
;
Globals
.
iWindowPosDX
=
rect
.
right
-
rect
.
left
;
Globals
.
iWindowPosDY
=
rect
.
bottom
-
rect
.
top
;
#define SET_NOTEPAD_REG(hkey, value_name, value_data) do { DWORD data = (DWORD)value_data; RegSetValueEx(hkey, value_name, 0, REG_DWORD, (LPBYTE)&data, sizeof(DWORD)); }while(0)
GetWindowRect
(
Globals
.
hMainWnd
,
&
main_rect
);
#define SET_NOTEPAD_REG(hkey, value_name, value_data) do { DWORD data = (DWORD)(value_data); RegSetValueEx(hkey, value_name, 0, REG_DWORD, (LPBYTE)&data, sizeof(DWORD)); }while(0)
SET_NOTEPAD_REG
(
hkey
,
value_fWrap
,
Globals
.
bWrapLongLines
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosX
,
Globals
.
iWindowPosX
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosY
,
Globals
.
iWindowPosY
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosDX
,
Globals
.
iWindowPosDX
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosDY
,
Globals
.
iWindowPosDY
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosX
,
main_rect
.
left
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosY
,
main_rect
.
top
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosDX
,
main_rect
.
right
-
main_rect
.
left
);
SET_NOTEPAD_REG
(
hkey
,
value_iWindowPosDY
,
main_rect
.
bottom
-
main_rect
.
top
);
SET_NOTEPAD_REG
(
hkey
,
value_lfCharSet
,
Globals
.
lfFont
.
lfCharSet
);
SET_NOTEPAD_REG
(
hkey
,
value_lfClipPrecision
,
Globals
.
lfFont
.
lfClipPrecision
);
SET_NOTEPAD_REG
(
hkey
,
value_lfEscapement
,
Globals
.
lfFont
.
lfEscapement
);
...
...
@@ -158,15 +154,14 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void)
{
static
const
WCHAR
systemW
[]
=
{
'S'
,
'y'
,
's'
,
't'
,
'e'
,
'm'
,
'\0'
};
HKEY
hkey
;
INT
base_length
;
INT
base_length
,
dx
,
dy
;
base_length
=
(
GetSystemMetrics
(
SM_CXSCREEN
)
>
GetSystemMetrics
(
SM_CYSCREEN
))
?
GetSystemMetrics
(
SM_CYSCREEN
)
:
GetSystemMetrics
(
SM_CXSCREEN
);
Globals
.
iWindowPosX
=
0
;
Globals
.
iWindowPosY
=
0
;
Globals
.
iWindowPosDX
=
base_length
*
.
95
;
Globals
.
iWindowPosDY
=
Globals
.
iWindowPosDX
*
3
/
4
;
dx
=
base_length
*
.
95
;
dy
=
dx
*
3
/
4
;
SetRect
(
&
main_rect
,
0
,
0
,
dx
,
dy
);
Globals
.
bWrapLongLines
=
TRUE
;
...
...
@@ -192,10 +187,10 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void)
#define QUERY_NOTEPAD_REG(hkey, value_name, ret) do { DWORD type, data; DWORD size = sizeof(DWORD); if(RegQueryValueEx(hkey, value_name, 0, &type, (LPBYTE)&data, &size) == ERROR_SUCCESS) if(type == REG_DWORD) ret = (typeof(ret))data; } while(0)
QUERY_NOTEPAD_REG
(
hkey
,
value_fWrap
,
Globals
.
bWrapLongLines
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosX
,
Globals
.
iWindowPosX
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosY
,
Globals
.
iWindowPosY
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosDX
,
Globals
.
iWindowPosDX
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosDY
,
Globals
.
iWindowPosDY
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosX
,
main_rect
.
left
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosY
,
main_rect
.
top
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosDX
,
dx
);
QUERY_NOTEPAD_REG
(
hkey
,
value_iWindowPosDY
,
dy
);
QUERY_NOTEPAD_REG
(
hkey
,
value_lfCharSet
,
Globals
.
lfFont
.
lfCharSet
);
QUERY_NOTEPAD_REG
(
hkey
,
value_lfClipPrecision
,
Globals
.
lfFont
.
lfClipPrecision
);
QUERY_NOTEPAD_REG
(
hkey
,
value_lfEscapement
,
Globals
.
lfFont
.
lfEscapement
);
...
...
@@ -209,6 +204,9 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void)
QUERY_NOTEPAD_REG
(
hkey
,
value_lfWeight
,
Globals
.
lfFont
.
lfWeight
);
#undef QUERY_NOTEPAD_REG
main_rect
.
right
=
main_rect
.
left
+
dx
;
main_rect
.
bottom
=
main_rect
.
top
+
dy
;
size
=
sizeof
(
DWORD
);
if
(
RegQueryValueEx
(
hkey
,
value_iPointSize
,
0
,
&
type
,
(
LPBYTE
)
&
data
,
&
size
)
==
ERROR_SUCCESS
)
if
(
type
==
REG_DWORD
)
...
...
@@ -593,6 +591,9 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
MSG
msg
;
HACCEL
hAccel
;
WNDCLASSEX
class
;
HMONITOR
monitor
;
MONITORINFO
info
;
INT
x
,
y
;
static
const
WCHAR
className
[]
=
{
'N'
,
'o'
,
't'
,
'e'
,
'p'
,
'a'
,
'd'
,
0
};
static
const
WCHAR
winName
[]
=
{
'N'
,
'o'
,
't'
,
'e'
,
'p'
,
'a'
,
'd'
,
0
};
...
...
@@ -616,10 +617,21 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
/* Setup windows */
monitor
=
MonitorFromRect
(
&
main_rect
,
MONITOR_DEFAULTTOPRIMARY
);
info
.
cbSize
=
sizeof
(
info
);
GetMonitorInfoW
(
monitor
,
&
info
);
x
=
main_rect
.
left
;
y
=
main_rect
.
top
;
if
(
main_rect
.
left
>=
info
.
rcWork
.
right
||
main_rect
.
top
>=
info
.
rcWork
.
bottom
||
main_rect
.
right
<
info
.
rcWork
.
left
||
main_rect
.
bottom
<
info
.
rcWork
.
top
)
x
=
y
=
CW_USEDEFAULT
;
Globals
.
hMainWnd
=
CreateWindow
(
className
,
winName
,
WS_OVERLAPPEDWINDOW
,
Globals
.
iWindowPosX
,
Globals
.
iWindowPosY
,
Globals
.
iWindowPosDX
,
Globals
.
iWindowPosDY
,
CreateWindow
(
className
,
winName
,
WS_OVERLAPPEDWINDOW
,
x
,
y
,
main_rect
.
right
-
main_rect
.
left
,
main_rect
.
bottom
-
main_rect
.
top
,
NULL
,
NULL
,
Globals
.
hInstance
,
NULL
);
if
(
!
Globals
.
hMainWnd
)
{
...
...
programs/notepad/main.h
View file @
cd5a04fd
...
...
@@ -45,11 +45,6 @@ typedef struct
WCHAR
szHeader
[
MAX_PATH
];
WCHAR
szFooter
[
MAX_PATH
];
INT
iWindowPosX
;
INT
iWindowPosY
;
INT
iWindowPosDX
;
INT
iWindowPosDY
;
FINDREPLACE
find
;
FINDREPLACE
lastFind
;
HGLOBAL
hDevMode
;
/* printer mode */
...
...
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