### Author Topic: Draw Text with Button To show & Remove  (Read 17135 times)

#### MichaelW

• Global Moderator
• Member
• Posts: 1209
##### Re: Draw Text with Button To show & Remove
« Reply #15 on: August 23, 2012, 12:17:43 PM »
In general, everything that is supposed to show in the client area of the window must be redrawn on each WM_PAINT cycle. The controls in the client area, other than owner-draw controls, will normally be redrawn automatically and this is one of the advantages of using controls. In this case you are drawing directly on the client area of the window, and because one of the first steps in repainting the client area is to erase the background, for what you draw to stay visible you must redraw it on each  cycle.
Code: [Select]
`;==============================================================================    include \masm32\include\masm32rt.inc;==============================================================================IDC_SHOW equ 1000IDC_HIDE equ 1001;==============================================================================    .data        hFont dd 0        fShow dd 0        fOn1  dd 0        fOn2  dd 0        fOn3  dd 0        str1  db "my other brother darryl",0    .code;==============================================================================;------------------------------------------------------------------; This is a modification of the MakeFont procedure from the MASM32; examples, with the height and width specifications replaced with; a point size specification.;------------------------------------------------------------------MakeFont proc pointSize:dword,weight:dword,italic:dword,lpFontName:dword    invoke GetDC, 0    invoke GetDeviceCaps, eax, LOGPIXELSY    mul   pointSize    xor   edx, edx    mov   ecx, 72    div   ecx    invoke CreateFont,eax,0,NULL,NULL,weight,italic,NULL,NULL,                      DEFAULT_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,                      PROOF_QUALITY,DEFAULT_PITCH or FF_DONTCARE,                      lpFontName    retMakeFont endp;==============================================================================PaintProc1 proc p:PTR PAINTSTRUCT    push ebx    mov ebx, p    ASSUME ebx:PTR PAINTSTRUCT    invoke SetTextColor, [ebx].hdc, 000000ffh    invoke SelectObject, [ebx].hdc, hFont    push eax    .IF fShow && fOn1        invoke SetBkMode, [ebx].hdc, TRANSPARENT        invoke TextOut, [ebx].hdc, 42, 25, ADDR str1, SIZEOF str1 - 1    .ENDIF    pop eax    invoke SelectObject, [ebx].hdc, eax    ASSUME ebx:NOTHING    pop ebx    retPaintProc1 endpPaintProc2 proc p:PTR PAINTSTRUCT    push ebx    mov ebx, p    ASSUME ebx:PTR PAINTSTRUCT    invoke SetTextColor, [ebx].hdc, 00ff0000h    invoke SelectObject, [ebx].hdc, hFont    push eax    .IF fShow && fOn2        invoke SetBkMode, [ebx].hdc, TRANSPARENT        invoke TextOut, [ebx].hdc, 42, 55, ADDR str1, SIZEOF str1 - 1    .ENDIF    pop eax    invoke SelectObject, [ebx].hdc, eax    ASSUME ebx:NOTHING    pop ebx    retPaintProc2 endpPaintProc3 proc p:PTR PAINTSTRUCT    push ebx    mov ebx, p    ASSUME ebx:PTR PAINTSTRUCT    invoke SetTextColor, [ebx].hdc, 0000ff00h    invoke SelectObject, [ebx].hdc, hFont    push eax    .IF fShow && fOn3        invoke SetBkMode, [ebx].hdc, TRANSPARENT        invoke TextOut, [ebx].hdc, 42, 85, ADDR str1, SIZEOF str1 - 1    .ENDIF    pop eax    invoke SelectObject, [ebx].hdc, eax    ASSUME ebx:NOTHING    pop ebx    retPaintProc3 endp;==============================================================================IDC_SHOW  equ 1000IDC_CLEAR equ 1001;==============================================================================DlgProc proc uses ebx hwndDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM    LOCAL ps:PAINTSTRUCT    SWITCH uMsg        CASE WM_INITDIALOG            invoke MakeFont, 24, FW_NORMAL, TRUE, chr\$("Arial Narrow")            mov hFont, eax            invoke SetTimer, hwndDlg, 1, 900, NULL            invoke Sleep, 300            invoke SetTimer, hwndDlg, 2, 900, NULL            invoke Sleep, 300            invoke SetTimer, hwndDlg, 3, 900, NULL        CASE WM_TIMER            SWITCH wParam                CASE 1                    not fOn1                CASE 2                    not fOn2                CASE 3                    not fOn3            ENDSW            invoke InvalidateRect, hwndDlg, NULL, TRUE        CASE WM_PAINT            invoke BeginPaint, hwndDlg, ADDR ps            invoke PaintProc1, ADDR ps            invoke PaintProc2, ADDR ps            invoke PaintProc3, ADDR ps            invoke EndPaint, hwndDlg, ADDR ps        CASE WM_COMMAND            SWITCH wParam                CASE IDC_SHOW                    mov fShow, -1                    invoke InvalidateRect, hwndDlg, NULL, TRUE                CASE IDC_HIDE                    mov fShow, 0                    invoke InvalidateRect, hwndDlg, NULL, TRUE                CASE IDCANCEL                    invoke EndDialog, hwndDlg, 0            ENDSW        CASE WM_CLOSE            invoke DeleteObject, hFont            invoke KillTimer, hwndDlg, 1            invoke KillTimer, hwndDlg, 2            invoke KillTimer, hwndDlg, 3            invoke EndDialog, hwndDlg, 0    ENDSW    return 0DlgProc endp;==============================================================================start:;==============================================================================    Dialog "Test", "MS Sans Serif",10, \           WS_OVERLAPPED or WS_SYSMENU or WS_CLIPCHILDREN or DS_CENTER, \           2,0,0,150,100,1024    DlgButton "&Show",WS_TABSTOP,35,60,25,10,IDC_SHOW    DlgButton "&Hide",WS_TABSTOP,85,60,25,10,IDC_HIDE    CallModalDialog 0,0,DlgProc,0    exit;==============================================================================end start`
Note that I added the WS_CLIPCHILDREN style to the dialog so the buttons would be excluded from the background erase, as otherwise the frequent redraws would make them flicker.

Well Microsoft, here’s another nice mess you’ve gotten us into.

#### dedndave

• Member
• Posts: 8827
• Still using Abacus 2.0
##### Re: Draw Text with Button To show & Remove
« Reply #16 on: August 23, 2012, 12:20:33 PM »
:t

except.....
how many brothers named Daryl do you have, Michael ?
that must be the 50th time i have seen you use that - lol

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #17 on: August 23, 2012, 12:31:41 PM »
Note that I added the WS_CLIPCHILDREN style to the dialog so the buttons would be excluded from the background erase, as otherwise the frequent redraws would make them flicker.

Funny , In one of my examples that I was trying that happened to me , my buttons just disappeared LOL

Nice example :t
We are the ASM Borg and you will become part of us. Compile and be assembled.

#### MichaelW

• Global Moderator
• Member
• Posts: 1209
##### Re: Draw Text with Button To show & Remove
« Reply #18 on: August 23, 2012, 01:10:35 PM »
how many brothers named Daryl do you have, Michael ?

None, that I know of

The phrase was part of an often repeated line in the series Newhart.
Well Microsoft, here’s another nice mess you’ve gotten us into.

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #19 on: August 23, 2012, 01:18:26 PM »
Wont work for me when I try to use this method to do the " Draw 2 text with buttons Example"
what am I missing ?
I keep getting errors:

Code: [Select]
`: error A2131: VARARG parameter requires C calling convention: error A2005: symbol redefinition : p: error A2006: undefined symbol : p: error A2006: undefined symbol : p`
We are the ASM Borg and you will become part of us. Compile and be assembled.

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #20 on: August 23, 2012, 02:23:41 PM »
This is crazy ....
Why is it when I try to use that example and I use :
Code: [Select]
`DrawTextProc  proc p: PTR PAINTSTRUCT`  I get the

VARARG parameter requires C calling convention   ERROR ????

http://www.masmforum.com/board/index.php?PHPSESSID=786dd40408172108b65a5a36b09c88c0&topic=10673.0
We are the ASM Borg and you will become part of us. Compile and be assembled.

#### MichaelW

• Global Moderator
• Member
• Posts: 1209
##### Re: Draw Text with Button To show & Remove
« Reply #21 on: August 23, 2012, 02:33:49 PM »
Code: [Select]
`invokeC macro DrawTextProc2:REQ,vars:VARARG LOCAL ivars ivars=0 FOR var, <vars> ivars=ivars+4 ENDM invoke DrawTextProc2,vars add esp,ivarsENDMinvokeC macro DrawTextProc:REQ,vars:VARARG LOCAL ivars ivars=0 FOR var, <vars> ivars=ivars+4 ENDM invoke DrawTextProc,vars add esp,ivarsENDM; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤; Prototype ; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤DialogProc      PROTO : HWND, : UINT, : WPARAM, : LPARAMDrawTextProc    PROTO C :VARARGDrawTextProc2   PROTO C :VARARG`
Well Microsoft, here’s another nice mess you’ve gotten us into.

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #22 on: August 23, 2012, 02:38:42 PM »
I tried with out and I still Get that same Error  :(
That is why I added those

I can not seem to use
Code: [Select]
`DrawTextProc  proc p: PTR PAINTSTRUCT`
I still have MASM10 is that it?
We are the ASM Borg and you will become part of us. Compile and be assembled.

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #23 on: August 23, 2012, 02:47:56 PM »
NOP
That is not it ....Just tried masm11
It says that it is too far for the jumps in the text area
We are the ASM Borg and you will become part of us. Compile and be assembled.

#### jj2007

• Member
• Posts: 10443
• Assembler is fun ;-)
##### Re: Draw Text with Button To show & Remove
« Reply #24 on: August 23, 2012, 03:28:50 PM »
The macros are never being used. Your code needs this:

DrawTextProc  proc C p:VARARG
DrawTextProc2  proc C p:VARARG

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #25 on: August 23, 2012, 03:34:50 PM »
@ jj2007
Yap that solved that .....
Thank You !  :t

We are the ASM Borg and you will become part of us. Compile and be assembled.

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #26 on: August 23, 2012, 03:45:26 PM »
LOL That did that ......  :icon_redface: :icon_redface:

We are the ASM Borg and you will become part of us. Compile and be assembled.

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #27 on: August 23, 2012, 04:25:00 PM »
Thanks Again all .....
And Here is  MichaelW's 3 Text example with Proc and with out with rsrc.rc

We are the ASM Borg and you will become part of us. Compile and be assembled.

#### dedndave

• Member
• Posts: 8827
• Still using Abacus 2.0
##### Re: Draw Text with Button To show & Remove
« Reply #28 on: August 23, 2012, 10:37:37 PM »
The phrase was part of an often repeated line in the series Newhart.

oh yes - i remember it well
probably the best part of the show - lol
when i watch "Blade Runner", i am always reminded of the Daryls

#### hfheatherfox07

• Member
• Posts: 464
##### Re: Draw Text with Button To show & Remove
« Reply #29 on: August 24, 2012, 12:51:53 AM »
All of this 3 Flashing text ... Reminds me of that Delphi Nervous text that I tried To convert To masm.....( I think I will have to Bit Bit this)

Am I Blind or all that this Does (From a colour point of view) is flash 3 colours ?
IS there any Blending or just 3 text colours flashing ?

May be I need to screen record this and slow it down