flat assembler
Message board for the users of flat assembler.

Index > Windows > Seems like a minor bug.

Author
Thread Post new topic Reply to topic
F9



Joined: 29 Sep 2006
Posts: 17
F9 07 Oct 2006, 13:40
This is in the code below and they both work ...

include 'include/macro/if.inc'
include 'include/macro\if.inc'

I just changed

include 'include/macro\if.inc'

to

include 'include/macro/if.inc'


Why doe it makes not make any differences which way these directory switches points to / and \

It will comply anyway which it shouldn't. Is this a fasm bug. I uesed the latest version (Fasm 1.67) which shows no version number under XP Pro and other .exe do.

Please check this code.

Thank you

Code:
;===========================================================================================
; Button_2.asm  Fasm Flat assembler
; Boutons: bitmap/icones
; Programmé par AsmGges France
;===========================================================================================

;  This is one of my choise of
;  examples for learning FASM




format PE GUI 4.0
entry start

  include       'include/win32a.inc'

;
;;;;;;  include 'include/macro/if.inc' ;  right
 include        'include/macro\if.inc' ;  worong but still works


  FLOODFILLSURFACE = 01h

section '.code' code readable executable

start:


    invoke GetModuleHandle,0

;push 0
;call GetModuleHandle
    mov [wc.hInstance],eax

;##############################################
;##############################################
;##############################################

    invoke LoadIcon,[wc.hInstance],ID_FRANCE
    mov [wc.hIcon],eax

    invoke LoadCursor,0,IDC_ARROW
    mov [wc.hCursor],eax

    invoke GetSystemMetrics,SM_CXSCREEN
    sub eax,[WinW]
    shr eax,1
    mov [WinX],eax

    invoke GetSystemMetrics,SM_CYSCREEN
    sub eax,[WinH]
    shr eax,1
    mov [WinY],eax
    sub [WinY],130

    invoke RegisterClass,wc

    invoke CreateWindowEx,WS_EX_LEFT,ClassName,Titre,WS_OVERLAPPED+WS_SYSMENU,\
                          [WinX],[WinY],[WinW],[WinH],0,0,[wc.hInstance],0
    mov [hWnd],eax

 
    invoke ShowWindow,[hWnd],SW_SHOWDEFAULT
    invoke UpdateWindow,[hWnd]

 MessageLoop:
    invoke GetMessage,msg,0,0,0
    or eax,eax
    jz ExitProgram

    invoke TranslateMessage,msg

    invoke DispatchMessage,msg

    jmp MessageLoop

 ExitProgram:

    invoke ExitProcess,[msg.wParam]


proc WindowProc uses ebx esi edi, @hWnd, @uMsg, @wParam, @lParam

    .if [@uMsg] = WM_CLOSE
        invoke MessageBox,[@hWnd],MsgEnd,ClassName,MB_OK+MB_ICONINFORMATION

        invoke PostQuitMessage,0

    .elseif [@uMsg] = WM_COMMAND
        .if [@wParam] = BN_CLICKED shl 16+ID_BUTTON_ICON1
            invoke MessageBox,[@hWnd],icoMsg1,ClassName,MB_OK

        .elseif [@wParam] = BN_CLICKED shl 16+ID_BUTTON_ICON2
            invoke MessageBox,[@hWnd],icoMsg2,ClassName,MB_OK

        .elseif [@wParam] = BN_CLICKED shl 16+ID_BUTTON_BMP1
            invoke MessageBox,[@hWnd],bmpMsg1,ClassName,MB_OK

        .elseif [@wParam] = BN_CLICKED shl 16+ID_BUTTON_BMP2
            invoke MessageBox,[@hWnd],bmpMsg2,ClassName,MB_OK

        .endif

    .elseif [@uMsg] = WM_CREATE
        stdcall DrawButton,[@hWnd],20,20,36,36,ID_BUTTON_ICON1,BS_ICON
        mov [hWndBtn1],eax

        invoke LoadIcon,[wc.hInstance],ID_ICON1

        invoke SendMessage,[hWndBtn1],BM_SETIMAGE,1,eax

        stdcall DrawButton,[@hWnd],20,70,36,36,ID_BUTTON_ICON2,BS_ICON
        mov [hWndBtn2],eax

        invoke SetWindowLong,[hWndBtn2],GWL_WNDPROC,BtnProc
        mov [lpBtnProc],eax

        invoke LoadIcon,[wc.hInstance],ID_ICON1

        invoke SendMessage,[hWndBtn2],BM_SETIMAGE,1,eax

        invoke LoadBitmap,[wc.hInstance],ID_BMP1
        mov [hBmp1],eax



PUSH [hBmp1]
CALL SetBmpColor

;       stdcall SetBmpColor,[hBmp1]
;       mov [hBmp1],eax
;##############################################
;##############################################
;##############################################

        invoke LoadBitmap,[wc.hInstance],ID_BMP2
        mov [hBmp2],eax

        stdcall SetBmpColor,[hBmp2]
        mov [hBmp2],eax

        stdcall DrawButton,[@hWnd],120,20,100,36,ID_BUTTON_BMP1,BS_BITMAP
        mov [hWndBtn3],eax

        invoke SendMessage,[hWndBtn3],BM_SETIMAGE,0,[hBmp1]

        stdcall DrawButton,[@hWnd],120,70,100,36,ID_BUTTON_BMP2,BS_BITMAP
        mov [hWndBtn4],eax

        invoke SendMessage,[hWndBtn4],BM_SETIMAGE,0,[hBmp1]

        invoke SetWindowLong,[hWndBtn4],GWL_WNDPROC,bmpProc
        mov [lpfnbmpProc], eax

    .elseif [@uMsg] = WM_PAINT
        invoke BeginPaint,[@hWnd],ps
        mov [ps.hdc],eax

        stdcall PaintProc,[@hWnd],[ps.hdc]

        invoke EndPaint,[@hWnd],ps

    .else

        invoke DefWindowProc,[@hWnd],[@uMsg],[@wParam],[@lParam]
        ret

    .endif

    mov eax,0
    ret
endp

;===========================================================================================
proc PaintProc @hWnd, @hDC
    local .btn_hi:DWORD, .btn_lo:DWORD

    invoke GetSysColor,COLOR_BTNHIGHLIGHT
    mov [.btn_hi],eax

    invoke GetSysColor,COLOR_BTNSHADOW
    mov [.btn_lo],eax

    mov eax,0
    ret
endp

;===========================================================================================
proc BtnProc @hCtl, @uMsg, @wParam, @lParam

    .if [@uMsg] = WM_LBUTTONDOWN | [@uMsg] = WM_KEYDOWN
        invoke LoadIcon,[wc.hInstance],ID_ICON2
        invoke SendMessage,[hWndBtn2],BM_SETIMAGE,1,eax

    .elseif [@uMsg] = WM_LBUTTONUP | [@uMsg] = WM_KEYUP
        invoke LoadIcon,[wc.hInstance],ID_ICON1
        invoke SendMessage,[hWndBtn2],BM_SETIMAGE,1,eax

    .endif

    invoke CallWindowProc,[lpBtnProc],[@hCtl],[@uMsg],[@wParam],[@lParam]

    ret
endp

;===========================================================================================
proc bmpProc @hCtl, @uMsg, @wParam, @lParam

    .if [@uMsg] = WM_LBUTTONDOWN | [@uMsg] = WM_KEYDOWN
        invoke SendMessage,[hWndBtn4],BM_SETIMAGE,0,[hBmp2]

    .elseif [@uMsg] = WM_LBUTTONUP | [@uMsg] = WM_KEYUP
        invoke SendMessage,[hWndBtn4],BM_SETIMAGE,0,[hBmp1]

    .endif

    invoke CallWindowProc,[lpfnbmpProc],[@hCtl],[@uMsg],[@wParam],[@lParam]

    ret
endp


proc DrawButton @hParent, @X, @Y, @wX, @hY, @Id, @ButtonStyle

    mov eax,WS_CHILD+WS_VISIBLE
    add eax,[@ButtonStyle]
    invoke CreateWindowEx,0,Button,noTitre,eax,[@X],[@Y],[@wX],[@hY],\
                                [@hParent],[@Id],[wc.hInstance],NULL
    ret
endp


proc SetBmpColor @hBitmap
    local .hMemDC:DWORD, .hBrush:DWORD, .hOldBmp:DWORD, .hReturn:DWORD, .hOldBrush:DWORD

    invoke CreateCompatibleDC,NULL
    mov [.hMemDC],eax

    invoke SelectObject,[.hMemDC],[@hBitmap]
    mov [.hOldBmp],eax

    invoke GetSysColor,COLOR_BTNFACE
    invoke CreateSolidBrush,eax
    mov [.hBrush],eax

    invoke SelectObject,[.hMemDC],[.hBrush]
    mov [.hOldBrush],eax

    invoke GetPixel,[.hMemDC],1,1
    invoke ExtFloodFill,[.hMemDC],1,1,eax,FLOODFILLSURFACE

    invoke SelectObject,[.hMemDC],[.hOldBrush]
    invoke DeleteObject,[.hBrush]

    invoke SelectObject,[.hMemDC],[@hBitmap]
    mov [.hReturn],eax

    invoke DeleteDC,[.hMemDC]

    mov eax,[.hReturn]

    ret
endp


section '.data' data readable writeable

  Titre       db ' Boutons: Bitmap / Icône ',0
  ClassName   db ' AsmGges Win32',0
  MsgEnd      db ' AsmGges France @2006  ',0
  Button      db 'BUTTON',0
  noTitre     db '',0

  icoMsg1     db 'Bouton: 1 icône ',0
  icoMsg2     db 'Bouton: 2 icônes ',0
  bmpMsg1     db 'Bouton: 1 bitmap ',0
  bmpMsg2     db 'Bouton: 2 Bitmap ',0
  align 4

  WinX        dd 0
  WinY        dd 0
  WinW        dd 248
  WinH        dd 156

  hWnd        dd ?
  hWndBtn1    dd ?
  hWndBtn2    dd ?
  hWndBtn3    dd ?
  hWndBtn4    dd ?
  hBmp1       dd ?
  hBmp2       dd ?
  lpBtnProc   dd ?
  lpfnbmpProc dd ?

  wc          WNDCLASS  0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,0,ClassName
  msg         MSG
  ps          PAINTSTRUCT


section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
            user32,'USER32.DLL',\
             gdi32,'GDI32.DLL'

  ; -------------------------------
  include 'include/apia\kernel32.inc'
  include 'include/apia\user32.inc'
  include 'include/apia\gdi32.inc'


section '.rsrc' resource data readable

  directory RT_ICON,icons,\
            RT_GROUP_ICON,group_icons,\
            RT_BITMAP,appBmp

  ID_FRANCE = 1
  ID_ICON1  = 2
  ID_ICON2  = 3
  ID_BMP1   = 10
  ID_BMP2   = 11

  ID_BUTTON_ICON1 = 400
  ID_BUTTON_ICON2 = 401
  ID_BUTTON_BMP1  = 402
  ID_BUTTON_BMP2  = 403

  resource icons,\
           1,LANG_NEUTRAL,france_data,\
           2,LANG_NEUTRAL,icon1_data,\
           3,LANG_NEUTRAL,icon2_data

  resource group_icons,\
           ID_FRANCE,LANG_NEUTRAL,france,\
           ID_ICON1, LANG_NEUTRAL,icon1,\
           ID_ICON2, LANG_NEUTRAL,icon2
  resource appBmp,\
           ID_BMP1,LANG_NEUTRAL,bmp1,\
           ID_BMP2,LANG_NEUTRAL,bmp2

  icon france,france_data,'res\france.ico'
  icon icon1, icon1_data, 'res\icon1.ico'
  icon icon2, icon2_data, 'res\icon2.ico'

  bitmap bmp1,'res\bmp1.bmp'
  bitmap bmp2,'res\bmp2.bmp'

;==========================================================================================
     


Last edited by F9 on 07 Oct 2006, 19:48; edited 2 times in total
Post 07 Oct 2006, 13:40
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 07 Oct 2006, 13:45
F9: don't mix topics please.

Quote:
Btw, vid your info about call [MessageBoxA] with [] around it seems incorrect according to the Fasm doc's and it will not assemble at lease on my machine.

it has nothing to do with your machine.
i said that "invoke a, b, c" becomes
Code:
push c
push b
call [a]    

and not
Code:
push c
push b
call a    
Post 07 Oct 2006, 13:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
F9



Joined: 29 Sep 2006
Posts: 17
F9 07 Oct 2006, 19:50
Now I get it.... If it working, don't fix-it. And since it's full-source you can try to fix it yourself and that's why there is no version number. javascript:emoticon('Embarassed')
Embarassed

Sorry for the waste of space, and thank vid for explaining the [] thing.
Post 07 Oct 2006, 19:50
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.