News:

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

Main Menu

Draw Text with Button To show & Remove

Started by hfheatherfox07, August 18, 2012, 05:20:11 PM

Previous topic - Next topic

hfheatherfox07

Almost ....
The Only Problem Is that Pause .... any Ideas ?
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

It Looks A little  Better with a Base Colour  :biggrin:
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

qWord

hi,
you can design the program more flexible and efficiently by using tables for the colors:
.486
.model flat, stdcall
option casemap: none

; API functions
; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤
include  \masm32\include\windows.inc
include  \masm32\include\user32.inc
include  \masm32\include\kernel32.inc
include  \masm32\include\comctl32.inc
include  \masm32\include\masm32.inc
include  \masm32\include\gdi32.inc

includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\comctl32.lib
includelib  \masm32\lib\masm32.lib
includelib  \masm32\lib\gdi32.lib

; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤

; Prototype
; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤
DialogProc   PROTO : HWND, : UINT, : WPARAM, : LPARAM

.const

; Resource ids
; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤
IDD_DLG1        equ 101
IDI_ICON        equ 200

.data
    szTitle          db "Flashing Colours", 0
    szText           db "TextAnim Colours!", 0
    Font            LOGFONTA    <35,0,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,\
                            CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, 0,"Times New Roman">
    hFont  HANDLE 0
   
    i_state     DWORD 0
    colors      DWORD 0000FFFFh
                DWORD 000080FFh
                DWORD 000000FFh
    n_states    DWORD ($-colors)/4

.data?
    hInstance HINSTANCE ?
    hIcon     HICON     ?
.code

start:
INVOKE GetModuleHandle, NULL
mov hInstance, eax

INVOKE LoadIcon, eax, IDI_ICON
mov hIcon, eax
INVOKE InitCommonControls
INVOKE DialogBoxParam, hInstance, IDD_DLG1 , NULL, ADDR DialogProc, 0
INVOKE ExitProcess, 0

DialogProc proc uses ebx hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM
LOCAL ps:PAINTSTRUCT
LOCAL rc:RECT
LOCAL hdc:HDC

    .IF uMsg == WM_INITDIALOG
   
        INVOKE SetWindowText, hWnd, addr szTitle
        INVOKE SendMessage, hWnd, WM_SETICON,ICON_SMALL, hIcon
       
        ; CreateFont:
        INVOKE CreateFontIndirect,addr Font
        mov hFont,eax   
       
        invoke SetTimer,hWnd, 1, 300, NULL
       
        invoke InvalidateRect, hWnd, NULL, TRUE
        mov eax,1
        ret
    .ELSEIF uMsg == WM_TIMER
        .IF wParam ==1
            inc i_state
            mov eax,n_states
            .if i_state >= eax
                mov i_state,0
            .endif
            invoke InvalidateRect, hWnd, NULL, TRUE
            mov eax,1
            ret
        .ENDIF
    .ELSEIF uMsg ==  WM_PAINT
        invoke BeginPaint, hWnd, ADDR ps
       
        mov ebx,i_state
   
        invoke SetTextColor, ps.hdc, colors[ebx*4]
        invoke SelectObject, ps.hdc, hFont
        push eax
        invoke SetBkMode, ps.hdc, TRANSPARENT
        invoke TextOut, ps.hdc, 60, 30, ADDR szText, SIZEOF szText - 1
        pop eax
       
        invoke SelectObject, ps.hdc, eax
        invoke EndPaint, hWnd, ADDR ps
        mov eax,1
        ret
    .ELSEIF uMsg == WM_CLOSE
        INVOKE DeleteObject, hFont
        INVOKE KillTimer,hWnd,1
        INVOKE EndDialog, hWnd, 0
    .ENDIF

    xor eax,eax
    ret
   
DialogProc endp
end start

BTW:  you should indent your code proper.
MREAL macros - when you need floating point arithmetic while assembling!

hfheatherfox07

Thanks qWord !
Funny I was just looking at an old attachment of yours when you posted this...

Your old sintext- see if I can change the algo there to do the back and forth wavering ....
accept I need a another decade or so to understand what I am doing LOL
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

LMAO

Well qWord .....
This Is a problem the text is falling ....

This made me laugh  :biggrin:
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.