News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

maybe i catch a bug

Started by A-new, January 01, 2015, 09:32:20 PM

Previous topic - Next topic

dedndave

the manifest file is primarily for common controls
under XP, you can add a manifest and call InitCommonControlsEx to get later version buttons, etc

but - adding a manifest and a version control block also help prevent AV false positives   :P
i generally add them to all my projects

the value returned in EAX is critical
your code design should allow for different messages to return different values

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645469%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645417%28v=vs.85%29.aspx

what happens is - if you return some value other than a null brush handle, windows thinks it's a brush (or an indication to use the default brush) and draws a background on top of the image you just painted   :biggrin:

dedndave

    mov     eax,uMsg
    .if eax==WM_INITDIALOG

    .elseif eax==WM_CTLCOLORDLG

    .elseif eax==WM_SIZE

    .elseif eax==WM_COMMAND

    .elseif eax==WM_CLOSE

    .else
        mov     eax,FALSE
        ret                           ;bad design to use multiple RET's
    .endif
    mov     eax,TRUE     ;oops - overwrites any value in EAX
    ret


i prefer this method, although not all forum members agree with me - lol
    mov     eax,uMsg
    .if eax==WM_INITDIALOG
        ;init dialog code
        mov     eax,TRUE         ;return TRUE - see WM_INITDIALOG documentation
    .elseif eax==WM_CTLCOLORDLG
        ;paint background code
        mov     eax,hbrNull        ;null brush handle - see WM_CTLCOLORDLG documentation
    .elseif eax==WM_SIZE
        ;size code
        mov     eax,TRUE        ;standard for most handled messages - see DialogProc documentation
    .elseif eax==WM_COMMAND
        ;command code
        mov     eax,TRUE        ;standard for most handled messages - see DialogProc documentation
    .elseif eax==WM_CLOSE
        ;close code
        mov     eax,TRUE        ;standard for most handled messages - see DialogProc documentation
    .else
        mov     eax,FALSE        ;standard for un-handled messages - see DialogProc documentation
    .endif
    ret

A-new

I checked every line of code, and finally found the reason
At the end of the Dialog function

.else
xor eax,eax ;return FALSE
ret
.endif
; mov eax,TRUE ;I should comment the trip, but this is Radasm template code,so not notice before
ret
DlgProc endp

end start

maybe we should suggest KetilO modify the template code

A-new

I read the template code again, most Msg should return TRUE ,so add mov eax,TRUE in the end before  the last ret,we  will not need to add the same code in each message,when requires special return values add a retwell ok.and this can reduce the number of code volume and reducing program volume


dedndave

re-read my last 2 posts   :P