.386
.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
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comctl32.lib
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
EditBox proto :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
EditListView PROTO :DWORD,:DWORD
FillEditBox PROTO :DWORD,:DWORD
InsertColumn MACRO handle,txt,width
LOCAL lbl
LOCAL strng
jmp lbl
strng db txt,0
lbl:
mov col.imask,LVCF_TEXT or LVCF_WIDTH
mov col.fmt,0
mov col.lx,width
mov col.pszText,offset strng
invoke lstrlen,offset strng
mov col.cchTextMax,eax
invoke SendMessage,handle,LVM_INSERTCOLUMN,0,addr col
ENDM
InsertItem MACRO handle,txt
LOCAL lbl
LOCAL strng
jmp lbl
strng db txt,0
lbl:
mov item.imask,LVIF_TEXT
mov item.iItem,0
mov item.iSubItem,0
mov item.pszText,offset strng
invoke lstrlen,offset strng
mov item.cchTextMax,eax
invoke SendMessage,handle,LVM_INSERTITEM,0,addr item
ENDM
SetItemText MACRO handle,txt,itemnumber,subitemnumber
LOCAL lbl
LOCAL strng
jmp lbl
strng db txt,0
lbl:
mov item.imask,LVIF_TEXT
mov item.iItem,itemnumber
mov item.iSubItem,subitemnumber
mov item.pszText,offset strng
invoke lstrlen,offset strng
mov item.cchTextMax,eax
invoke SendMessage,handle,LVM_SETITEMTEXT,0,addr item
ENDM
RGB macro red,green,blue
xor eax,eax
mov ah,blue
shl eax,8
mov ah,green
mov al,red
endm
.data
ClassName db "SimpleWinClass",0
AppName db "Our First Window",0
hListView dd 0
szListViewClass db "SysListView32",0
EditClasName db "EDIT",0
ButtonClassName db "BUTTON",0
ButtonCaption db "Edit The Item",0
Message1 db "No item Selected",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
buffer db 512 dup(?)
col LVCOLUMN >
item LVITEM >
ItemEdited dd ?
HwndEditBox1 HWND ?
HwndEditBox2 HWND ?
HwndEditBox3 HWND ?
HwndEditBox4 HWND ?
HwndEditBox5 HWND ?
.Const
EditBox1ID equ 701
EditBox2ID equ 702
EditBox3ID equ 703
EditBox4ID equ 704
EditBox5ID equ 705
ButtonID equ 501
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke InitCommonControls
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hEditBox:HWND
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_CREATE
invoke EditBox,NULL,0,220,20,20,hWnd,EditBox1ID
mov HwndEditBox1,eax
nice work. im now able to move foward with my program im tring to work on.
smurf
;To SMURF,I improved the code.Sorry for long writing.
.386
.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
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
EditBox proto :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
EditWndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
EditListView PROTO :DWORD,:DWORD
FillEditBox PROTO :DWORD,:DWORD
PutEditBoxesOverItem PROTO
HideEditBoxes PROTO
InsertColumn MACRO handle,txt,width
LOCAL lbl
LOCAL strng
jmp lbl
strng db txt,0
lbl:
mov col.imask,LVCF_TEXT or LVCF_WIDTH
mov col.fmt,0
mov col.lx,width
mov col.pszText,offset strng
invoke lstrlen,offset strng
mov col.cchTextMax,eax
invoke SendMessage,handle,LVM_INSERTCOLUMN,0,addr col
ENDM
InsertItem MACRO handle,txt
LOCAL lbl
LOCAL strng
jmp lbl
strng db txt,0
lbl:
mov item.imask,LVIF_TEXT
mov item.iItem,0
mov item.iSubItem,0
mov item.pszText,offset strng
invoke lstrlen,offset strng
mov item.cchTextMax,eax
invoke SendMessage,handle,LVM_INSERTITEM,0,addr item
ENDM
SetItemText MACRO handle,txt,itemnumber,subitemnumber
LOCAL lbl
LOCAL strng
jmp lbl
strng db txt,0
lbl:
mov item.imask,LVIF_TEXT
mov item.iItem,itemnumber
mov item.iSubItem,subitemnumber
mov item.pszText,offset strng
invoke lstrlen,offset strng
mov item.cchTextMax,eax
invoke SendMessage,handle,LVM_SETITEMTEXT,0,addr item
ENDM
RGB macro red,green,blue
xor eax,eax
mov ah,blue
shl eax,8
mov ah,green
mov al,red
endm
.data
ClassName db "SimpleWinClass",0
AppName db "Our First Window",0
hListView dd 0
szListViewClass db "SysListView32",0
EditClasName db "EDIT",0
ButtonClassName db "BUTTON",0
ButtonCaption db "Ok",0
FontName db "Times New Roman TrueType Font",0
hFont dd 0
OurClass db "SUPEREDITCLASS",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
buffer db 512 dup(?)
col LVCOLUMN >
item LVITEM >
lf LOGFONT >
ItemEdited dd ?
HwndButton HWND ?
HwndEditBox HWND 5 dup(?)
OldWndProc dd ?
.Const
ButtonID equ 501
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke InitCommonControls
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hEditBox:HWND
LOCAL wc:WNDCLASSEX
.IF uMsg==WM_DESTROY
invoke Pos
pretty neat trick thanks for the code.
im not able to access iczelions site either.
here are some api's that might help with the resizing of the headers:
HDN_BEGINTRACK
Notifies a header control's parent window that the user has begun dragging a divider in the control (that is, the user has pressed the left mouse button while the mouse cursor is on a divider in the header control). This notification message is sent in the form of a WM_NOTIFY message.
HDN_ENDTRACK
Notifies a header control's parent window that the user has finished dragging a divider. This notification message sent in the form of a WM_NOTIFY message.
LVM_GETHEADER - get the header handle
HDM_LAYOUT - retrieves the size and position of the header
HDMLAYOUT Structure - info used to set the size of the header
WINDOWPOS Structure
NMHEADER
NMHDR
smurf
This message was edited by smurf, on 5/12/2001 12:36:01 AM
This message was edited by smurf, on 5/12/2001 12:41:46 AM
Thanks for reply & help.
I donot mean header control,I mean the head of
the column of a listview control,i.e the 1st row
which the user can drag to change the widths of columns
when the mouse is over a divider & changes to cross like.
What is the notification send by the listview to the window.
Also I have a bug,when mouse click is over subitem and
not over item I see strange text in the edit boxes,??
Thanks for reply.