dancho
Joined: 06 Mar 2011
Posts: 74
|
So this is small code snipet that creates standard window with header control,
you will notice that program is processing WM_NOTIFY message and that is checking for HDN_BEGINTRACK notification message,( int3 at that point ).
All this is working fine and as expected but only when assembled as ANSI set,
( notice win32ax.inc ).
Including 'win32wx.inc' for the UNICODE support program still work but header control does not print item string as it should and int3 is never reached...
If anyone could clarify this mistery for me I would be really appreciated...
thx
format PE GUI 5.0
entry wmain
include 'win32ax.inc' ; <---
section '.code' code readable executable
wmain:
invoke InitCommonControlsEx,ccx
invoke GetModuleHandle,0
mov [wcx.hInstance],eax
invoke LoadIcon,0,IDI_APPLICATION
mov [wcx.hIcon],eax
invoke LoadCursor,0,IDC_ARROW
mov [wcx.hCursor],eax
invoke RegisterClassEx,wcx
invoke CreateWindowEx,0,wClass,wName,(WS_OVERLAPPEDWINDOW or WS_VISIBLE or WS_CLIPCHILDREN),400,200,400,200,0,0,[wcx.hInstance],0
.loop:
invoke GetMessage,msg,0,0,0
cmp eax,1
jb .out
invoke TranslateMessage,msg
invoke DispatchMessage,msg
jmp .loop
.out:
invoke ExitProcess,0
proc WndProc uses ebx esi edi,hWnd,Msg,wParam,lParam
locals
rect RECT ?
hdl HD_LAYOUT ?
wp WINDOWPOS ?
endl
cmp [Msg],WM_CREATE
je .wm_create
cmp [Msg],WM_NOTIFY
je .wm_notify
cmp [Msg],WM_SIZE
je .wm_size
cmp [Msg],WM_DESTROY
je .wm_destroy
invoke DefWindowProc,[hWnd],[Msg],[wParam],[lParam]
ret
;
.wm_create:
; header control
invoke CreateWindowEx,0,hcClass,hcName,(WS_CHILD or WS_BORDER or HDS_HOTTRACK),0,0,0,0,[hWnd],0,[wcx.hInstance],0
mov [hHC],eax
;
stdcall InsertHeaderConItem,0,60,text1 ; <-----
stdcall InsertHeaderConItem,1,60,text2 ; <-----
jmp .processed
;
.wm_notify:
mov ebx,[lParam]
cmp dword[ebx+HD_NOTIFY.hdr.code],HDN_BEGINTRACK
jne .processed
int3 ; <----------
jmp .processed
;
.wm_size:
invoke GetClientRect,[hWnd],addr rect
lea esi,[rect]
mov [hdl.prc],esi
lea edi,[wp]
mov [hdl.pwpos],edi
invoke SendMessage,[hHC],HDM_LAYOUT,0,addr hdl
or [wp.flags],SWP_SHOWWINDOW
invoke SetWindowPos,[hHC],[wp.hwndInsertAfter],[wp.x],[wp.y],[wp.cx],[wp.cy],[wp.flags]
jmp .processed
;
.wm_destroy:
invoke PostQuitMessage,0
.processed:
xor eax,eax
ret
endp
proc InsertHeaderConItem uses esi edi ebx,insertAfter,_width,_text
locals
hdi HD_ITEM ?
endl
mov [hdi.mask],HDI_FORMAT or HDI_TEXT or HDI_WIDTH
mov eax,[_width]
mov [hdi.cxy],eax
mov edx,[_text]
mov [hdi.pszText],edx
mov [hdi.cchTextMax],12
mov [hdi.fmt],HDF_CENTER + HDF_STRING
invoke SendMessage,[hHC],HDM_INSERTITEM,[insertAfter],addr hdi
ret
endp
section '.data' data readable writeable
wClass TCHAR 'TEST',0
wName TCHAR 'Test',0
hcClass TCHAR 'SysHeader32',0
hcName TCHAR '',0
text1 TCHAR 'hello',0
text2 TCHAR 'world',0
wcx WNDCLASSEX sizeof.WNDCLASSEX,0,WndProc,0,0,0,0,0,COLOR_BTNFACE+1,0,wClass,0
ccx INITCOMMONCONTROLSEX sizeof.INITCOMMONCONTROLSEX,ICC_LISTVIEW_CLASSES
msg rb sizeof.MSG
hHC rd 1
section '.idata' data import readable
library kernel32,'kernel32.dll',\
user32,'user32.dll',\
comctl32,'comctl32.dll'
include 'api\kernel32.inc'
include 'api\user32.inc'
include 'api\comctl32.inc'
|