Commit 85c03a5a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/ipaddress: Store current IP address text as a window text for IP Address control.

parent b7d7d589
......@@ -77,6 +77,29 @@ static const WCHAR IP_SUBCLASS_PROP[] =
static LRESULT CALLBACK
IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void IPADDRESS_UpdateText (const IPADDRESS_INFO *infoPtr)
{
static const WCHAR zero[2] = {'0', 0};
static const WCHAR dot[2] = {'.', 0};
WCHAR field[4];
WCHAR ip[16];
INT i;
ip[0] = 0;
for (i = 0; i < 4; i++) {
if (GetWindowTextW (infoPtr->Part[i].EditHwnd, field, 4))
strcatW(ip, field);
else
/* empty edit treated as zero */
strcatW(ip, zero);
if (i != 3)
strcatW(ip, dot);
}
SetWindowTextW(infoPtr->Self, ip);
}
static LRESULT IPADDRESS_Notify (const IPADDRESS_INFO *infoPtr, UINT command)
{
HWND hwnd = infoPtr->Self;
......@@ -219,6 +242,8 @@ static LRESULT IPADDRESS_Create (HWND hwnd, const CREATESTRUCTA *lpCreate)
EnableWindow(part->EditHwnd, infoPtr->Enabled);
}
IPADDRESS_UpdateText (infoPtr);
return 0;
}
......@@ -561,6 +586,7 @@ IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_COMMAND:
switch(wParam >> 16) {
case EN_CHANGE:
IPADDRESS_UpdateText(infoPtr);
IPADDRESS_Notify(infoPtr, EN_CHANGE);
break;
case EN_KILLFOCUS:
......
......@@ -11,6 +11,7 @@ CTESTS = \
dpa.c \
header.c \
imagelist.c \
ipaddress.c \
listview.c \
misc.c \
monthcal.c \
......
/* Unit test suite for IP Address control.
*
* Copyright 2009 Nikolay Sivov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <windows.h>
#include <commctrl.h>
#include <assert.h>
#include "wine/test.h"
#define expect(expected, got) ok(expected == got, "expected %d, got %d\n", expected,got)
static HWND create_ipaddress_control (void)
{
HWND handle;
handle = CreateWindowEx(0, WC_IPADDRESS, NULL,
WS_BORDER|WS_VISIBLE, 0, 0, 0, 0,
NULL, NULL, NULL, NULL);
assert(handle);
return handle;
}
static void test_get_set_text(void)
{
HWND hwnd;
CHAR ip[16];
INT r;
hwnd = create_ipaddress_control();
/* check text just after creation */
r = GetWindowText(hwnd, ip, sizeof(ip)/sizeof(CHAR));
expect(7, r);
ok(strcmp(ip, "0.0.0.0") == 0, "Expected null IP address, got %s\n", ip);
SendMessage(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(127, 0, 0, 1));
r = GetWindowText(hwnd, ip, sizeof(ip)/sizeof(CHAR));
expect(9, r);
ok(strcmp(ip, "127.0.0.1") == 0, "Expected 127.0.0.1, got %s\n", ip);
DestroyWindow(hwnd);
}
static int init(void)
{
HMODULE hComctl32;
BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
INITCOMMONCONTROLSEX iccex;
hComctl32 = GetModuleHandleA("comctl32.dll");
pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
if (!pInitCommonControlsEx)
{
skip("InitCommonControlsEx() is missing. Skipping the tests\n");
return 0;
}
iccex.dwSize = sizeof(iccex);
iccex.dwICC = ICC_USEREX_CLASSES;
pInitCommonControlsEx(&iccex);
return 1;
}
START_TEST(ipaddress)
{
if (!init())
return;
test_get_set_text();
}
......@@ -4459,7 +4459,7 @@ typedef struct tagNMIPADDRESS
#define MAKEIPRANGE(low,high) \
((LPARAM)(WORD)(((BYTE)(high)<<8)+(BYTE)(low)))
#define MAKEIPADDRESS(b1,b2,b3,b4) \
((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<16)+((DWORD)(b3)<<8)+((DWORD)(b4))))
((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4))))
#define FIRST_IPADDRESS(x) (((x)>>24)&0xff)
#define SECOND_IPADDRESS(x) (((x)>>16)&0xff)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment