flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem with the character set

Author
Thread Post new topic Reply to topic
dancho



Joined: 06 Mar 2011
Posts: 74
dancho 01 Oct 2011, 21:20
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


Code:
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'
               

    
Post 01 Oct 2011, 21:20
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 02 Oct 2011, 01:35
Code:
  include 'win32wx.inc' or 'win32ax.inc'

                text1           db   'hello',0
                text2           db   'world',0
    
Post 02 Oct 2011, 01:35
View user's profile Send private message Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho 02 Oct 2011, 07:03
no,
it doesn't catch breakpoint with win32wp.inc ...
Post 02 Oct 2011, 07:03
View user's profile Send private message Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho 03 Oct 2011, 17:51
ok people,
the SOLUTION is ( if you think about it its logic one Laughing )

HDN_BEGINTRACKW

see the bold part ,heh... Rolling Eyes
Post 03 Oct 2011, 17:51
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 03 Oct 2011, 21:22
dancho wrote:
no,
it doesn't catch breakpoint with win32wp.inc ...

What are you talking about ? Shocked
Post 03 Oct 2011, 21:22
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.