.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\comctl32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
.data
ClassName db "SimpleWinClass",0
AppName db "Programming Header Control",0
HeaderClassName db "SysHeader32",0
TheName db "Name",0
TheAge db "Age",0
Name1 db "Adam",0
Age1 db "26",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
Hheader1 HWND ?
Hheader2 HWND ?
.Const
header1ID equ 501
header2ID equ 502
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
invoke InitCommonControls
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 HDItem:HD_ITEM
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_CREATE
invoke CreateWindowEx,0, ADDR HeaderClassName,NULL,\
WS_CHILD or WS_BORDER or WS_VISIBLE or HDS_HORZ or HDS_BUTTONS,\
100,100,300,20,hWnd,header1ID, hInstance,NULL
mov Hheader1,eax
mov HDItem.imask,HDI_FORMAT or HDI_TEXT or HDI_WIDTH
mov HDItem.lxy,60
mov HDItem.pszText, offset TheName
mov HDItem.cchTextMax,sizeof TheName
mov HDItem.fmt,HDF_CENTER or HDF_STRING
invoke SendMessage,Hheader1,HDM_INSERTITEM,0,ADDR HDItem
mov HDItem.lxy,40
mov HDItem.pszText, offset TheAge
mov HDItem.cchTextMax,sizeof TheAge
invoke SendMessage,Hheader1,HDM_INSERTITEM,1,ADDR HDItem
invoke CreateWindowEx,0, ADDR HeaderClassName,NULL,\
WS_CHILD or WS_BORDER or WS_VISIBLE or HDS_HORZ ,\
100,140,300,20,hWnd,header1ID, hInstance,NULL
mov Hheader2,eax
mov HDItem.lxy,60
mov HDItem.pszText, offset Name1
mov HDItem.cchTextMax,sizeof Name1
invoke SendMessage,Hheader2,HDM_INSERTITEM,0,ADDR HDItem
mov HDItem.lxy,40
mov HDItem.pszText, offset Age1
mov HDItem.cchTextMax,sizeof Age1
invoke SendMessage,Hheader2,HDM_INSERTITEM,1,ADDR HDItem
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
end start
;##############################
As A beginner I found difficulty in writing
the proper code for creating header.I hope someone
will find it usefull, and the expert owners of this page
agree to this.
What is left is writing code for the message to and
from the Header Contr