Maybe usefull for someone....
Please leave comments/suggestions/flames/ideas!

Regards,
bAZiK



; SysIPAddress32 demo by bAZiK <bazik@win32asmcommunity.net>

.486
.model flat, stdcall
option casemap :none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comctl32.inc
include \masm32\include\gdi32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\gdi32.lib

ID_BUTTON1 equ 1
ID_BUTTON2 equ 2
ID_SYSIP equ 3

IPM_GETADDRESS equ WM_USER + 102 ; missing in windows.inc

.data
szClassName db "Demo_App", 0

wc WNDCLASSEX <sizeof wc, CS_HREDRAW \
or CS_VREDRAW or CS_BYTEALIGNWINDOW, \
offset WndProc, 0, 0, 400000h, \
0, 0, COLOR_BTNFACE + 1, 0, \
offset szClassName, 0>

szButtonClass db "BUTTON", 0
szSysIPClass db "SysIPAddress32", 0


szCaption db "SysIP Demo", 0
szcmdShow db "Show IP", 0
szcmdExit db "Exit", 0
szMissing db "One or more fields missing!", 0
szMask db "%lu.%lu.%lu.%lu", 0

.data?
hWnd dd ?
msg MSG <?>
icc INITCOMMONCONTROLSEX <?>
hFont dd ?
hSysIP dd ?
nIP dd ?
szBuffer db 32 dup (?)

.code

start:

push sizeof icc
pop icc.dwSize
mov icc.dwICC, ICC_INTERNET_CLASSES

invoke InitCommonControlsEx, addr icc

call WinMain
invoke ExitProcess, eax

WinMain proc
mov wc.hIcon, 0
invoke LoadCursor, 0, IDC_ARROW
mov wc.hCursor, eax
invoke RegisterClassEx, addr wc
invoke GetSystemMetrics, SM_CXSCREEN
mov esi,eax
invoke GetSystemMetrics, SM_CYSCREEN
shr esi, 1
shr eax, 1
sub eax, 165/2
sub esi, 80/2

invoke CreateWindowEx, WS_EX_TOPMOST,
addr szClassName,
addr szCaption,
WS_CAPTION or WS_MINIMIZEBOX or \
WS_SYSMENU or WS_VISIBLE,
esi, eax, 165, 80, 0, 0, 400000h, 0
mov hWnd, eax
invoke ShowWindow, hWnd, 1
invoke UpdateWindow, hWnd
mov esi, offset msg
@@:
invoke GetMessage, esi, 0, 0, 0
or eax, eax
je @F
invoke TranslateMessage, esi
invoke DispatchMessage, esi
jmp @B
@@:
mov eax, msg.wParam
ret
WinMain endp

WndProc proc hWin :DWORD,uMsg :DWORD, wParam :DWORD, lParam :DWORD

.if uMsg == WM_CREATE
invoke GetStockObject, DEFAULT_GUI_FONT
mov hFont, eax

invoke CreateWindowEx, 0, addr szButtonClass, addr szcmdShow,
WS_CHILD or WS_VISIBLE, 5, 30, 70, 20,
hWin, ID_BUTTON1, 400000h, 0
invoke SendMessage, eax, WM_SETFONT, hFont, 0

invoke CreateWindowEx, 0, addr szButtonClass, addr szcmdExit,
WS_CHILD or WS_VISIBLE, 85, 30, 70, 20,
hWin, ID_BUTTON2, 400000h, 0
invoke SendMessage, eax, WM_SETFONT, hFont, 0

invoke CreateWindowEx, 0, addr szSysIPClass, 0, WS_CHILD or WS_VISIBLE,
5, 5, 150, 20, hWin, ID_SYSIP, 400000h, 0
mov hSysIP, eax
invoke SendMessage, eax, WM_SETFONT, hFont, 0

.elseif uMsg == WM_COMMAND

.if wParam == ID_BUTTON1

invoke SendMessage, hSysIP, IPM_GETADDRESS, 0, addr nIP
cmp eax, 4 ; eax == number of nonzero fields
jl _1

mov eax, nIP

mov ebx, eax ; first part
shr ebx, 24
and ebx, 255
push ebx

mov ebx, eax ; second part
shr ebx, 16
and ebx, 255
push ebx

mov ebx, eax ; third part
shr ebx, 8
and ebx, 255

and eax, 255 ; fourth part

pop ecx
pop edx

invoke wsprintf, addr szBuffer, addr szMask, edx, ecx, ebx, eax
invoke MessageBox, hWin, addr szBuffer, 0, 0

jmp _2
_1:
invoke MessageBox, hWin, addr szMissing, 0, 0
_2:

.elseif wParam == ID_BUTTON2

jmp @F

.endif

.elseif uMsg == WM_DESTROY
@@:
invoke PostQuitMessage, 0
xor eax, eax
ret

.endif

invoke DefWindowProc, hWin, uMsg, wParam, lParam

ret

WndProc endp

end start


EDIT: - bug fixed, works in all Windows versions now
Posted on 2002-07-16 13:48:38 by bazik
.
Posted on 2002-07-16 14:28:12 by bazik
uhhh! It would be cool if it worked on win2k. I can't see the SysIPAddress32 control. :( Screw my win2k... :grin:

::edit::

BTW, what's fehler??? Sorry, can't speak/understood german :tongue:
Posted on 2002-07-16 15:10:00 by stryker
It doesnt work on Win2K ????
I developed it under WinXP... strange!

Fehler == Error
Posted on 2002-07-16 15:45:00 by bazik
'Fehler' means 'error'.

The app doesn't work on my win98 either.
Posted on 2002-07-16 15:48:04 by nyook
Thanks for testing!

I fixed the bug by replacing InitCommonControls with InitCommonControlsEx and using ICC_INTERNET_CLASSES flag :)
Posted on 2002-07-16 16:24:50 by bazik
Nice!!! :alright:
Posted on 2002-07-16 16:36:06 by stryker
Next time just upgrade to WinXP instead of blaming me for not working Applications :tongue:
Posted on 2002-07-17 01:55:03 by bazik
bAZiK,

unlike you, were not that rich to just go and buy XP when we want to. :(
Posted on 2002-07-17 03:01:31 by stryker
Argh, that control is so annoying :). I sincerely prefer a normal editbox
for that stuff, it's annoying to navigate the dotted control...
Posted on 2002-07-17 07:52:03 by f0dder

Argh, that control is so annoying :). I sincerely prefer a normal editbox
for that stuff, it's annoying to navigate the dotted control...


I know :) Navigating with Arrow keys really sucks.
But I will subclass it today and add navigation with TAB key :grin:

I like this control, because you dont need to validate if the user entered a positive number <= 255 :) Also it looks quite nice :tongue:

Edit: Another advantage is, that you can enter the IP without typing the dot. But as you said, its only good for a IP with 4x3 digits. With less digits, I automatically hit the TAB key instead of the Arrow key to get to the next field.

BTW, is there a programm available, wich replaces the comma with a dot on the Keypad? I already broke out the keys with a screwdriver and changed them, but this didnt work?!

Posted on 2002-07-17 08:30:09 by bazik

But I will subclass it today and add navigation with TAB key

Great, tab and shift+tab would make this control useable!
Posted on 2002-07-17 08:34:25 by f0dder
Arrow keys are enough, imo...
Posted on 2002-07-17 20:57:55 by comrade
Arrow keys enough? Not for lazy sobs llke me ;). Lazyness is a virtue these days...
Posted on 2002-07-17 21:01:24 by f0dder
Tell me about it. :(
Posted on 2002-07-17 21:08:04 by comrade
Lazyness *is* sometimes a good thing - when done in the user interface and not by the programmer.
Whi should I alt+f+s+enter when I can ctrl+s ?
Posted on 2002-07-17 21:14:55 by f0dder
So you can burn more calories and exercise your finger muscles? :)
Posted on 2002-07-18 00:47:14 by comrade
There's so much information on this board.  It's amazing.

I realise how old this thread is and I don't really have any reason to bump it back up, except to remind everyone using IP controls that you can use the dot instead of the arrows to move between octets.  It's not quite as annoying as people seem to think.
Posted on 2005-12-15 11:44:30 by Will