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.
This commit is contained in:
parent
5f8f4f77f5
commit
3c1ebcceca
|
@ -1,23 +1,24 @@
|
||||||
/*
|
/*
|
||||||
* IP Address control
|
* IP Address control
|
||||||
*
|
*
|
||||||
|
* Copyright 1999 Chris Morgan<cmorgan@wpi.edu> and
|
||||||
|
* James Abbatiello<abbeyj@wpi.edu>
|
||||||
* Copyright 1998, 1999 Eric Kohl
|
* Copyright 1998, 1999 Eric Kohl
|
||||||
* Copyright 1998 Alex Priem <alexp@sci.kun.nl>
|
* Copyright 1998 Alex Priem <alexp@sci.kun.nl>
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
|
|
||||||
*
|
*
|
||||||
* TODO:
|
* 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.
|
* -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.
|
* -CurrentFocus: field that has focus at moment of processing.
|
||||||
* -connect Rect32 rcClient.
|
* -connect Rect32 rcClient.
|
||||||
* -handle right and left arrows correctly. Boring.
|
|
||||||
* -split GotoNextField in CheckField and GotoNextField.
|
|
||||||
* -check ipaddress.cpp for missing features.
|
* -check ipaddress.cpp for missing features.
|
||||||
* -refresh: draw '.' instead of setpixel.
|
* -refresh: draw '.' instead of setpixel.
|
||||||
* -handle VK_ESCAPE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -31,16 +32,13 @@
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(ipaddress)
|
DEFAULT_DEBUG_CHANNEL(ipaddress)
|
||||||
|
|
||||||
|
|
||||||
#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongA (hwnd, 0))
|
#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongA (hwnd, 0))
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
IPADDRESS_SendNotify (HWND hwnd, UINT command);
|
IPADDRESS_SendNotify (HWND hwnd, UINT command);
|
||||||
static BOOL
|
static BOOL
|
||||||
IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue);
|
IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue);
|
||||||
|
|
||||||
|
|
||||||
/* property name of tooltip window handle */
|
/* property name of tooltip window handle */
|
||||||
#define IP_SUBCLASS_PROP "CCIP32SubclassInfo"
|
#define IP_SUBCLASS_PROP "CCIP32SubclassInfo"
|
||||||
|
|
||||||
|
@ -49,8 +47,6 @@ static LRESULT CALLBACK
|
||||||
IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
IPADDRESS_Refresh (HWND hwnd, HDC hdc)
|
IPADDRESS_Refresh (HWND hwnd, HDC hdc)
|
||||||
{
|
{
|
||||||
|
@ -74,15 +70,10 @@ IPADDRESS_Refresh (HWND hwnd, HDC hdc)
|
||||||
SetPixel (hdc, x, 14, clr);
|
SetPixel (hdc, x, 14, clr);
|
||||||
SetPixel (hdc, x+1, 13, clr);
|
SetPixel (hdc, x+1, 13, clr);
|
||||||
SetPixel (hdc, x+1, 14, clr);
|
SetPixel (hdc, x+1, 14, clr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
IPADDRESS_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
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.top =rcClient.top+2;
|
||||||
edit.bottom=rcClient.bottom-2;
|
edit.bottom=rcClient.bottom-2;
|
||||||
|
|
||||||
lpipsi=(LPIP_SUBCLASS_INFO)
|
lpipsi=(LPIP_SUBCLASS_INFO) GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP);
|
||||||
GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP);
|
|
||||||
if (lpipsi == NULL) {
|
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->hwnd = hwnd;
|
||||||
lpipsi->uRefCount++;
|
lpipsi->uRefCount++;
|
||||||
SetPropA ((HWND)hwnd, IP_SUBCLASS_PROP,
|
SetPropA ((HWND)hwnd, IP_SUBCLASS_PROP, (HANDLE)lpipsi);
|
||||||
(HANDLE)lpipsi);
|
|
||||||
/* infoPtr->lpipsi= lpipsi; */
|
/* infoPtr->lpipsi= lpipsi; */
|
||||||
} else
|
} else
|
||||||
WARN("IP-create called twice\n");
|
WARN("IP-create called twice\n");
|
||||||
|
|
||||||
for (i=0; i<=3; i++) {
|
for (i=0; i<=3; i++)
|
||||||
|
{
|
||||||
infoPtr->LowerLimit[i]=0;
|
infoPtr->LowerLimit[i]=0;
|
||||||
infoPtr->UpperLimit[i]=255;
|
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;
|
edit.right=rcClient.left+(i+1)*fieldsize-2;
|
||||||
lpipsi->hwndIP[i]= CreateWindowA ("edit", NULL,
|
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,
|
edit.left, edit.top, edit.right-edit.left, edit.bottom-edit.top,
|
||||||
hwnd, (HMENU) 1, GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
|
hwnd, (HMENU) 1, GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
|
||||||
lpipsi->wpOrigProc[i]= (WNDPROC)
|
lpipsi->wpOrigProc[i]= (WNDPROC)
|
||||||
SetWindowLongA (lpipsi->hwndIP[i],GWL_WNDPROC, (LONG)
|
SetWindowLongA (lpipsi->hwndIP[i],GWL_WNDPROC, (LONG)
|
||||||
IPADDRESS_SubclassProc);
|
IPADDRESS_SubclassProc);
|
||||||
SetPropA ((HWND)lpipsi->hwndIP[i], IP_SUBCLASS_PROP,
|
SetPropA ((HWND)lpipsi->hwndIP[i], IP_SUBCLASS_PROP, (HANDLE)lpipsi);
|
||||||
(HANDLE)lpipsi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lpipsi->infoPtr= infoPtr;
|
lpipsi->infoPtr= infoPtr;
|
||||||
|
@ -212,7 +201,6 @@ IPADDRESS_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
IPADDRESS_SendNotify (HWND hwnd, UINT command)
|
IPADDRESS_SendNotify (HWND hwnd, UINT command)
|
||||||
|
|
||||||
{
|
{
|
||||||
TRACE("%x\n",command);
|
TRACE("%x\n",command);
|
||||||
return (BOOL)SendMessageA (GetParent (hwnd), WM_COMMAND,
|
return (BOOL)SendMessageA (GetParent (hwnd), WM_COMMAND,
|
||||||
|
@ -238,8 +226,6 @@ IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
IPADDRESS_ClearAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
IPADDRESS_ClearAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -262,6 +248,7 @@ IPADDRESS_ClearAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
IPADDRESS_IsBlank (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
IPADDRESS_IsBlank (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -281,6 +268,7 @@ IPADDRESS_IsBlank (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
IPADDRESS_GetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
IPADDRESS_GetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -332,6 +320,7 @@ IPADDRESS_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
IPADDRESS_SetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
IPADDRESS_SetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -364,14 +353,12 @@ IPADDRESS_SetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
IPADDRESS_SetFocusToField (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
IPADDRESS_SetFocusToField (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
/* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */
|
/* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */
|
||||||
LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
|
LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) GetPropA ((HWND)hwnd,
|
||||||
GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP);
|
IP_SUBCLASS_PROP);
|
||||||
INT index;
|
INT index;
|
||||||
|
|
||||||
index=(INT) wParam;
|
index=(INT) wParam;
|
||||||
|
@ -397,53 +384,100 @@ IPADDRESS_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static INT
|
||||||
/* tab/shift-tab: IPN_FIELDCHANGED, lose focus.
|
IPADDRESS_CheckField (LPIP_SUBCLASS_INFO lpipsi, int currentfield)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
int newField,fieldvalue;
|
int newField,fieldvalue;
|
||||||
char field[20];
|
char field[20];
|
||||||
IPADDRESS_INFO *infoPtr=lpipsi->infoPtr;
|
IPADDRESS_INFO *infoPtr=lpipsi->infoPtr;
|
||||||
|
|
||||||
|
if(currentfield >= 0 && currentfield < 4)
|
||||||
|
{
|
||||||
TRACE("\n");
|
TRACE("\n");
|
||||||
GetWindowTextA (lpipsi->hwndIP[currentfield],field,4);
|
GetWindowTextA (lpipsi->hwndIP[currentfield],field,4);
|
||||||
if (field[0]) {
|
if (field[0])
|
||||||
|
{
|
||||||
field[3]=0;
|
field[3]=0;
|
||||||
newField=-1;
|
newField=-1;
|
||||||
fieldvalue=atoi(field);
|
fieldvalue=atoi(field);
|
||||||
|
|
||||||
if (fieldvalue < infoPtr->LowerLimit[currentfield])
|
if (fieldvalue < infoPtr->LowerLimit[currentfield])
|
||||||
newField=infoPtr->LowerLimit[currentfield];
|
newField=infoPtr->LowerLimit[currentfield];
|
||||||
|
|
||||||
if (fieldvalue > infoPtr->UpperLimit[currentfield])
|
if (fieldvalue > infoPtr->UpperLimit[currentfield])
|
||||||
newField=infoPtr->UpperLimit[currentfield];
|
newField=infoPtr->UpperLimit[currentfield];
|
||||||
if (newField>=0) {
|
|
||||||
|
if (newField >= 0)
|
||||||
|
{
|
||||||
sprintf (field,"%d",newField);
|
sprintf (field,"%d",newField);
|
||||||
SetWindowTextA (lpipsi->hwndIP[currentfield], field);
|
SetWindowTextA (lpipsi->hwndIP[currentfield], field);
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
if(currentfield < 3)
|
||||||
|
{
|
||||||
SetFocus (lpipsi->hwndIP[currentfield+1]);
|
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
|
LRESULT CALLBACK
|
||||||
IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int i,l,index;
|
|
||||||
IPADDRESS_INFO *infoPtr;
|
IPADDRESS_INFO *infoPtr;
|
||||||
LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
|
LPIP_SUBCLASS_INFO lpipsi = (LPIP_SUBCLASS_INFO) GetPropA
|
||||||
GetPropA ((HWND)hwnd,IP_SUBCLASS_PROP);
|
((HWND)hwnd,IP_SUBCLASS_PROP);
|
||||||
|
CHAR c = (CHAR)wParam;
|
||||||
|
INT i, l, index, startsel, endsel;
|
||||||
|
|
||||||
infoPtr = lpipsi->infoPtr;
|
infoPtr = lpipsi->infoPtr;
|
||||||
index=0; /* FIXME */
|
index=0; /* FIXME */
|
||||||
|
@ -451,51 +485,111 @@ IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
if (lpipsi->hwndIP[i]==hwnd) index=i;
|
if (lpipsi->hwndIP[i]==hwnd) index=i;
|
||||||
|
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_CHAR: break;
|
case WM_CHAR:
|
||||||
case WM_KEYDOWN: {
|
if(isdigit(c)) /* process all digits */
|
||||||
char c=(char) wParam;
|
{
|
||||||
if (c==VK_TAB) {
|
int return_val;
|
||||||
HWND pwnd;
|
SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel);
|
||||||
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);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((c==' ') || (c=='.') || (c==VK_RIGHT)) {
|
|
||||||
IPADDRESS_GotoNextField (lpipsi,index);
|
|
||||||
wParam=0;
|
|
||||||
lParam=0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (c==VK_LEFT) {
|
|
||||||
|
|
||||||
}
|
|
||||||
if (c==VK_RETURN) {
|
|
||||||
}
|
|
||||||
if (((c>='0') && (c<='9')) || (iscntrl(c))) {
|
|
||||||
l = GetWindowTextLengthA (lpipsi->hwndIP[index]);
|
l = GetWindowTextLengthA (lpipsi->hwndIP[index]);
|
||||||
if (l==3)
|
if(l==2 && startsel==endsel) /* field is full after this key is processed */
|
||||||
if (IPADDRESS_GotoNextField (lpipsi,index)) {
|
{
|
||||||
wParam=0;
|
/* 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;
|
lParam = 0;
|
||||||
|
wParam = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wParam=0;
|
if(c == '.') /* VK_PERIOD */
|
||||||
lParam=0;
|
{
|
||||||
break;
|
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_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_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
return CallWindowProcA (lpipsi->wpOrigProc[index], hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT WINAPI
|
LRESULT WINAPI
|
||||||
IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
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
|
void IPADDRESS_Register (void)
|
||||||
IPADDRESS_Register (void)
|
|
||||||
{
|
{
|
||||||
WNDCLASSA wndClass;
|
WNDCLASSA wndClass;
|
||||||
|
|
||||||
|
@ -572,10 +665,9 @@ IPADDRESS_Register (void)
|
||||||
RegisterClassA (&wndClass);
|
RegisterClassA (&wndClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
|
||||||
IPADDRESS_Unregister (void)
|
VOID IPADDRESS_Unregister (void)
|
||||||
{
|
{
|
||||||
if (GlobalFindAtomA (WC_IPADDRESSA))
|
if (GlobalFindAtomA (WC_IPADDRESSA))
|
||||||
UnregisterClassA (WC_IPADDRESSA, (HINSTANCE)NULL);
|
UnregisterClassA (WC_IPADDRESSA, (HINSTANCE)NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue