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
3c1ebcce
Commit
3c1ebcce
authored
Jun 26, 1999
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authors: Chris Morgan <cmorgan@wpi.edu>, James Abbatiello <abbeyj@wpi.edu>
Complete rewrite of messaging code to implement/fix all input behaviors. Fixed a few fixmes.
parent
5f8f4f77
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
181 additions
and
89 deletions
+181
-89
ipaddress.c
dlls/comctl32/ipaddress.c
+181
-89
No files found.
dlls/comctl32/ipaddress.c
View file @
3c1ebcce
/*
* IP Address control
*
* Copyright 1999 Chris Morgan<cmorgan@wpi.edu> and
* James Abbatiello<abbeyj@wpi.edu>
* Copyright 1998, 1999 Eric Kohl
* Copyright 1998 Alex Priem <alexp@sci.kun.nl>
*
* NOTES
*
* TODO:
* -Check ranges when changing field-focus.
* -Edit control doesn't support the ES_CENTER style which prevents
* this ipaddress control from having centered text look like the
* windows ipaddress control
* -Check all notifications/behavior.
* -Optimization: include lpipsi in IPADDRESS_INFO.
* -Optimization:
* -include lpipsi in IPADDRESS_INFO.
* -CurrentFocus: field that has focus at moment of processing.
* -connect Rect32 rcClient.
* -handle right and left arrows correctly. Boring.
* -split GotoNextField in CheckField and GotoNextField.
* -check ipaddress.cpp for missing features.
* -refresh: draw '.' instead of setpixel.
* -handle VK_ESCAPE.
*/
#include <ctype.h>
...
...
@@ -31,16 +32,13 @@
DEFAULT_DEBUG_CHANNEL
(
ipaddress
)
#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongA (hwnd, 0))
static
BOOL
IPADDRESS_SendNotify
(
HWND
hwnd
,
UINT
command
);
static
BOOL
IPADDRESS_SendIPAddressNotify
(
HWND
hwnd
,
UINT
field
,
BYTE
newValue
);
/* property name of tooltip window handle */
#define IP_SUBCLASS_PROP "CCIP32SubclassInfo"
...
...
@@ -49,8 +47,6 @@ static LRESULT CALLBACK
IPADDRESS_SubclassProc
(
HWND
hwnd
,
UINT
uMsg
,
WPARAM
wParam
,
LPARAM
lParam
);
static
VOID
IPADDRESS_Refresh
(
HWND
hwnd
,
HDC
hdc
)
{
...
...
@@ -66,7 +62,7 @@ IPADDRESS_Refresh (HWND hwnd, HDC hdc)
DeleteObject
(
hbr
);
x
=
rcClient
.
left
;
fieldsize
=
(
rcClient
.
right
-
rcClient
.
left
)
/
4
;
fieldsize
=
(
rcClient
.
right
-
rcClient
.
left
)
/
4
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
/* Should draw text "." here */
x
+=
fieldsize
;
...
...
@@ -74,15 +70,10 @@ IPADDRESS_Refresh (HWND hwnd, HDC hdc)
SetPixel
(
hdc
,
x
,
14
,
clr
);
SetPixel
(
hdc
,
x
+
1
,
13
,
clr
);
SetPixel
(
hdc
,
x
+
1
,
14
,
clr
);
}
}
static
LRESULT
IPADDRESS_Create
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
...
...
@@ -102,32 +93,30 @@ IPADDRESS_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
edit
.
top
=
rcClient
.
top
+
2
;
edit
.
bottom
=
rcClient
.
bottom
-
2
;
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
GetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
);
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
GetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
);
if
(
lpipsi
==
NULL
)
{
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
COMCTL32_Alloc
(
sizeof
(
IP_SUBCLASS_INFO
));
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
COMCTL32_Alloc
(
sizeof
(
IP_SUBCLASS_INFO
));
lpipsi
->
hwnd
=
hwnd
;
lpipsi
->
uRefCount
++
;
SetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
,
(
HANDLE
)
lpipsi
);
SetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
,
(
HANDLE
)
lpipsi
);
/* infoPtr->lpipsi= lpipsi; */
}
else
WARN
(
"IP-create called twice
\n
"
);
for
(
i
=
0
;
i
<=
3
;
i
++
)
{
for
(
i
=
0
;
i
<=
3
;
i
++
)
{
infoPtr
->
LowerLimit
[
i
]
=
0
;
infoPtr
->
UpperLimit
[
i
]
=
255
;
edit
.
left
=
rcClient
.
left
+
i
*
fieldsize
+
3
;
edit
.
left
=
rcClient
.
left
+
i
*
fieldsize
+
6
;
edit
.
right
=
rcClient
.
left
+
(
i
+
1
)
*
fieldsize
-
2
;
lpipsi
->
hwndIP
[
i
]
=
CreateWindowA
(
"edit"
,
NULL
,
WS_CHILD
|
WS_VISIBLE
|
ES_LEFT
,
WS_CHILD
|
WS_VISIBLE
|
ES_CENTER
,
edit
.
left
,
edit
.
top
,
edit
.
right
-
edit
.
left
,
edit
.
bottom
-
edit
.
top
,
hwnd
,
(
HMENU
)
1
,
GetWindowLongA
(
hwnd
,
GWL_HINSTANCE
),
NULL
);
lpipsi
->
wpOrigProc
[
i
]
=
(
WNDPROC
)
SetWindowLongA
(
lpipsi
->
hwndIP
[
i
],
GWL_WNDPROC
,
(
LONG
)
IPADDRESS_SubclassProc
);
SetPropA
((
HWND
)
lpipsi
->
hwndIP
[
i
],
IP_SUBCLASS_PROP
,
(
HANDLE
)
lpipsi
);
SetPropA
((
HWND
)
lpipsi
->
hwndIP
[
i
],
IP_SUBCLASS_PROP
,
(
HANDLE
)
lpipsi
);
}
lpipsi
->
infoPtr
=
infoPtr
;
...
...
@@ -212,7 +201,6 @@ IPADDRESS_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
static
BOOL
IPADDRESS_SendNotify
(
HWND
hwnd
,
UINT
command
)
{
TRACE
(
"%x
\n
"
,
command
);
return
(
BOOL
)
SendMessageA
(
GetParent
(
hwnd
),
WM_COMMAND
,
...
...
@@ -238,8 +226,6 @@ IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue)
}
static
LRESULT
IPADDRESS_ClearAddress
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
...
...
@@ -262,6 +248,7 @@ IPADDRESS_ClearAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
return
0
;
}
static
LRESULT
IPADDRESS_IsBlank
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
...
...
@@ -281,6 +268,7 @@ IPADDRESS_IsBlank (HWND hwnd, WPARAM wParam, LPARAM lParam)
return
1
;
}
static
LRESULT
IPADDRESS_GetAddress
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
...
...
@@ -332,6 +320,7 @@ IPADDRESS_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
return
1
;
}
static
LRESULT
IPADDRESS_SetAddress
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
...
...
@@ -364,14 +353,12 @@ IPADDRESS_SetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
}
static
LRESULT
IPADDRESS_SetFocusToField
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
/* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */
LPIP_SUBCLASS_INFO
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
GetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
);
LPIP_SUBCLASS_INFO
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
GetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
);
INT
index
;
index
=
(
INT
)
wParam
;
...
...
@@ -397,53 +384,100 @@ IPADDRESS_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
}
/* tab/shift-tab: IPN_FIELDCHANGED, lose focus.
dot, space,right arrow: set focus to next child edit.
numerics (0..9), control characters: forward to default edit control
other characters: dropped
*/
static
int
IPADDRESS_GotoNextField
(
LPIP_SUBCLASS_INFO
lpipsi
,
int
currentfield
)
static
INT
IPADDRESS_CheckField
(
LPIP_SUBCLASS_INFO
lpipsi
,
int
currentfield
)
{
int
newField
,
fieldvalue
;
char
field
[
20
];
IPADDRESS_INFO
*
infoPtr
=
lpipsi
->
infoPtr
;
if
(
currentfield
>=
0
&&
currentfield
<
4
)
{
TRACE
(
"
\n
"
);
GetWindowTextA
(
lpipsi
->
hwndIP
[
currentfield
],
field
,
4
);
if
(
field
[
0
])
{
if
(
field
[
0
])
{
field
[
3
]
=
0
;
newField
=-
1
;
fieldvalue
=
atoi
(
field
);
if
(
fieldvalue
<
infoPtr
->
LowerLimit
[
currentfield
])
if
(
fieldvalue
<
infoPtr
->
LowerLimit
[
currentfield
])
newField
=
infoPtr
->
LowerLimit
[
currentfield
];
if
(
fieldvalue
>
infoPtr
->
UpperLimit
[
currentfield
])
if
(
fieldvalue
>
infoPtr
->
UpperLimit
[
currentfield
])
newField
=
infoPtr
->
UpperLimit
[
currentfield
];
if
(
newField
>=
0
)
{
if
(
newField
>=
0
)
{
sprintf
(
field
,
"%d"
,
newField
);
SetWindowTextA
(
lpipsi
->
hwndIP
[
currentfield
],
field
);
return
1
;
return
TRUE
;
}
}
}
return
FALSE
;
}
if
(
currentfield
<
3
)
static
INT
IPADDRESS_GotoNextField
(
LPIP_SUBCLASS_INFO
lpipsi
,
int
currentfield
)
{
if
(
currentfield
>=
-
1
&&
currentfield
<
4
)
{
IPADDRESS_CheckField
(
lpipsi
,
currentfield
);
/* check the fields value */
if
(
currentfield
<
3
)
{
SetFocus
(
lpipsi
->
hwndIP
[
currentfield
+
1
]);
return
0
;
return
TRUE
;
}
}
return
FALSE
;
}
/* period: move and select the text in the next field to the right if */
/* the current field is not empty(l!=0), we are not in the */
/* left most position, and nothing is selected(startsel==endsel) */
/* spacebar: same behavior as period */
/* alpha characters: completely ignored */
/* digits: accepted when field text length < 2 ignored otherwise. */
/* when 3 numbers have been entered into the field the value */
/* of the field is checked, if the field value exceeds the */
/* maximum value and is changed the field remains the current */
/* field, otherwise focus moves to the field to the right */
/* tab: change focus from the current ipaddress control to the next */
/* control in the tab order */
/* right arrow: move to the field on the right to the left most */
/* position in that field if no text is selected, */
/* we are in the right most position in the field, */
/* we are not in the right most field */
/* left arrow: move to the field on the left to the right most */
/* position in that field if no text is selected, */
/* we are in the left most position in the current field */
/* and we are not in the left most field */
/* backspace: delete the character to the left of the cursor position, */
/* if none are present move to the field on the left if */
/* we are not in the left most field and delete the right */
/* most digit in that field while keeping the cursor */
/* on the right side of the field */
LRESULT
CALLBACK
IPADDRESS_SubclassProc
(
HWND
hwnd
,
UINT
uMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
int
i
,
l
,
index
;
IPADDRESS_INFO
*
infoPtr
;
LPIP_SUBCLASS_INFO
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
GetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
);
LPIP_SUBCLASS_INFO
lpipsi
=
(
LPIP_SUBCLASS_INFO
)
GetPropA
((
HWND
)
hwnd
,
IP_SUBCLASS_PROP
);
CHAR
c
=
(
CHAR
)
wParam
;
INT
i
,
l
,
index
,
startsel
,
endsel
;
infoPtr
=
lpipsi
->
infoPtr
;
index
=
0
;
/* FIXME */
...
...
@@ -451,51 +485,111 @@ IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if
(
lpipsi
->
hwndIP
[
i
]
==
hwnd
)
index
=
i
;
switch
(
uMsg
)
{
case
WM_CHAR
:
break
;
case
WM_KEYDOWN
:
{
char
c
=
(
char
)
wParam
;
if
(
c
==
VK_TAB
)
{
HWND
pwnd
;
int
shift
;
shift
=
GetKeyState
(
VK_SHIFT
)
&
0x8000
;
if
(
shift
)
pwnd
=
GetNextDlgTabItem
(
GetParent
(
hwnd
),
0
,
TRUE
);
else
pwnd
=
GetNextDlgTabItem
(
GetParent
(
hwnd
),
0
,
FALSE
);
if
(
pwnd
)
SetFocus
(
pwnd
);
case
WM_CHAR
:
if
(
isdigit
(
c
))
/* process all digits */
{
int
return_val
;
SendMessageA
(
lpipsi
->
hwndIP
[
index
],
EM_GETSEL
,
(
WPARAM
)
&
startsel
,
(
LPARAM
)
&
endsel
);
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
]);
if
(
l
==
2
&&
startsel
==
endsel
)
/* field is full after this key is processed */
{
/* process the digit press before we check the field */
return_val
=
CallWindowProcA
(
lpipsi
->
wpOrigProc
[
index
],
hwnd
,
uMsg
,
wParam
,
lParam
);
/* if the field value was changed stay at the current field */
if
(
!
IPADDRESS_CheckField
(
lpipsi
,
index
))
IPADDRESS_GotoNextField
(
lpipsi
,
index
);
return
return_val
;
}
if
(
l
>
2
)
/* field is full, stop key messages */
{
lParam
=
0
;
wParam
=
0
;
}
break
;
}
if
((
c
==
' '
)
||
(
c
==
'.'
)
||
(
c
==
VK_RIGHT
))
{
IPADDRESS_GotoNextField
(
lpipsi
,
index
);
wParam
=
0
;
lParam
=
0
;
if
(
c
==
'.'
)
/* VK_PERIOD */
{
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
]);
SendMessageA
(
lpipsi
->
hwndIP
[
index
],
EM_GETSEL
,
(
WPARAM
)
&
startsel
,
(
LPARAM
)
&
endsel
);
if
(
l
!=
0
&&
startsel
==
endsel
&&
startsel
!=
0
)
{
IPADDRESS_GotoNextField
(
lpipsi
,
index
);
SendMessageA
(
lpipsi
->
hwndIP
[
index
+
1
],
EM_SETSEL
,
(
WPARAM
)
0
,
(
LPARAM
)
3
);
}
}
/* stop all other characters */
wParam
=
0
;
lParam
=
0
;
break
;
case
WM_KEYDOWN
:
if
(
c
==
VK_SPACE
)
{
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
]);
SendMessageA
(
lpipsi
->
hwndIP
[
index
],
EM_GETSEL
,
(
WPARAM
)
&
startsel
,
(
LPARAM
)
&
endsel
);
if
(
l
!=
0
&&
startsel
==
endsel
&&
startsel
!=
0
)
{
IPADDRESS_GotoNextField
(
lpipsi
,
index
);
SendMessageA
(
lpipsi
->
hwndIP
[
index
+
1
],
EM_SETSEL
,
(
WPARAM
)
0
,
(
LPARAM
)
3
);
}
if
(
c
==
VK_LEFT
)
{
}
if
(
c
==
VK_RIGHT
)
{
SendMessageA
(
lpipsi
->
hwndIP
[
index
],
EM_GETSEL
,
(
WPARAM
)
&
startsel
,
(
LPARAM
)
&
endsel
);
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
]);
if
(
startsel
==
endsel
&&
startsel
==
l
)
{
IPADDRESS_GotoNextField
(
lpipsi
,
index
);
SendMessageA
(
lpipsi
->
hwndIP
[
index
+
1
],
EM_SETSEL
,
(
WPARAM
)
0
,(
LPARAM
)
0
);
}
if
(
c
==
VK_RETURN
)
{
}
if
(((
c
>=
'0'
)
&&
(
c
<=
'9'
))
||
(
iscntrl
(
c
)))
{
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
]);
if
(
l
==
3
)
if
(
IPADDRESS_GotoNextField
(
lpipsi
,
index
))
{
wParam
=
0
;
lParam
=
0
;
if
(
c
==
VK_LEFT
)
{
SendMessageA
(
lpipsi
->
hwndIP
[
index
],
EM_GETSEL
,
(
WPARAM
)
&
startsel
,
(
LPARAM
)
&
endsel
);
if
(
startsel
==
0
&&
startsel
==
endsel
&&
index
>
0
)
{
IPADDRESS_GotoNextField
(
lpipsi
,
index
-
2
);
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
-
1
]);
SendMessageA
(
lpipsi
->
hwndIP
[
index
-
1
],
EM_SETSEL
,
(
WPARAM
)
l
,(
LPARAM
)
l
);
}
break
;
}
wParam
=
0
;
lParam
=
0
;
break
;
if
(
c
==
VK_BACK
)
/* VK_BACKSPACE */
{
CHAR
buf
[
4
];
SendMessageA
(
lpipsi
->
hwndIP
[
index
],
EM_GETSEL
,
(
WPARAM
)
&
startsel
,
(
LPARAM
)
&
endsel
);
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
]);
if
(
startsel
==
endsel
&&
startsel
==
0
&&
index
>
0
)
{
l
=
GetWindowTextLengthA
(
lpipsi
->
hwndIP
[
index
-
1
]);
if
(
l
!=
0
)
{
GetWindowTextA
(
lpipsi
->
hwndIP
[
index
-
1
],
buf
,
4
);
buf
[
l
-
1
]
=
'\0'
;
SetWindowTextA
(
lpipsi
->
hwndIP
[
index
-
1
],
buf
);
SendMessageA
(
lpipsi
->
hwndIP
[
index
-
1
],
EM_SETSEL
,
(
WPARAM
)
l
,(
LPARAM
)
l
);
}
IPADDRESS_GotoNextField
(
lpipsi
,
index
-
2
);
}
}
break
;
default:
break
;
}
return
CallWindowProcA
(
lpipsi
->
wpOrigProc
[
index
],
hwnd
,
uMsg
,
wParam
,
lParam
);
}
LRESULT
WINAPI
IPADDRESS_WindowProc
(
HWND
hwnd
,
UINT
uMsg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
...
...
@@ -553,8 +647,7 @@ IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
void
IPADDRESS_Register
(
void
)
void
IPADDRESS_Register
(
void
)
{
WNDCLASSA
wndClass
;
...
...
@@ -572,10 +665,9 @@ IPADDRESS_Register (void)
RegisterClassA
(
&
wndClass
);
}
VOID
IPADDRESS_Unregister
(
void
)
VOID
IPADDRESS_Unregister
(
void
)
{
if
(
GlobalFindAtomA
(
WC_IPADDRESSA
))
UnregisterClassA
(
WC_IPADDRESSA
,
(
HINSTANCE
)
NULL
);
}
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