Hi
I am Trying To draw Text with show text and Remove Text Buttons ...I am using a thread instead of invoking the proc and no timer
It is not working :( any ideas ?
Thank you!
ARG!!!!
What is the handle of the drawn text ???
I thought of drawing it out than use "INVOKE ShowWindow ,hText,SW_HIDE"
and toggle between show and hide Buttons
EDIT:
I am trying to draw this without a static!!! how do I go about doing it this way?
I can't see any point to using a timer or a thread, so I created a simple MASM32 In Memory dialog example that draws text on the client are of the dialog window.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
IDC_SHOW equ 1000
IDC_HIDE equ 1001
;==============================================================================
.data
hFont dd 0
fShow 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
ret
MakeFont endp
;==============================================================================
IDC_SHOW equ 1000
IDC_CLEAR equ 1001
;==============================================================================
DlgProc proc uses ebx hwndDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL ps:PAINTSTRUCT, rc:RECT, hdc:HDC
SWITCH uMsg
CASE WM_INITDIALOG
invoke MakeFont, 24, FW_NORMAL, TRUE, chr$("Arial Narrow")
mov hFont, eax
CASE WM_PAINT
invoke BeginPaint, hwndDlg, ADDR ps
invoke SetTextColor, ps.hdc, 000000ffh
invoke SelectObject, ps.hdc, hFont
push eax
.IF fShow
invoke SetBkMode, ps.hdc, TRANSPARENT
invoke TextOut, ps.hdc, 42, 50, ADDR str1, SIZEOF str1 - 1
.ENDIF
pop eax
invoke SelectObject, ps.hdc, eax
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 EndDialog, hwndDlg, 0
ENDSW
return 0
DlgProc endp
;==============================================================================
start:
;==============================================================================
Dialog "Test", "MS Sans Serif",10, \
WS_OVERLAPPED or WS_SYSMENU 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
Thank You MichaelW ! :biggrin:
That is so elegant....
Here is another version of that , using CreateFontIndirect
I just have to figure out how to have the WM_PAINT in it's own separate proc......
I am already using WM_PAINT for something else so I need a separate proc
OK ...
Here is a version with a Proc ....
Why am I losing the text when I minimize ...Not catching it now :(
EDIT
Attachment removed see Last post
I cleaned it up a bit and it is worse ... Why?
what does minimize have to do with text?
:(
Attachment removed see Last post
and yet another try with ebx as hdc
same results, I Feel Like I am losing my mind :(
Attachment removed see Last post
if you want to modify Michael's code to use a seperate proc for WM_PAINT...
wmPaint PROTO :HWND
;
;
;
CASE WM_PAINT
invoke wmPaint, hwndDlg
;
;
;
wmPaint PROC hWnd:HWND
LOCAL ps:PAINTSTRUCT
invoke BeginPaint, hWnd, ADDR ps
invoke SetTextColor, ps.hdc, 000000ffh
invoke SelectObject, ps.hdc, hFont
push eax
.IF fShow
invoke SetBkMode, ps.hdc, TRANSPARENT
invoke TextOut, ps.hdc, 42, 50, ADDR str1, SIZEOF str1 - 1
.ENDIF
pop eax
invoke SelectObject, ps.hdc, eax
invoke EndPaint, hWnd, ADDR ps
ret
wmPaint ENDP
notice that you no longer need the local PAINTSTRUCT in DlgProc
if you want to change to a different proc, use a dword variable to hold the address of wmPaint
That Worked Great!!!!
:greenclp:
I uploaded a copy of a working example in case any body ever runs into this....
P.S
Also removed the bad attachments ...I noticed when hutch collected all the attachments from the old forum to archive ....the examples that are not working got also posted ...people who download those would think they are good examples
Here is a Good example .....Thank You dedndave!!!! :t
OK ....
I decided to swap out one of the buttons to draw other text instead of just removing it ......
Why am I losing the 2nd text after it is drawn ?
i am not sure exactly what you are trying to do - lol
i guess it's hard to describe, sometimes
i think you want to try...
INVOKE SetBkMode,hdc,TRANSPARENT
before drawing the text
Quote from: dedndave on August 22, 2012, 07:56:23 PM
i am not sure exactly what you are trying to do - lol
i guess it's hard to describe, sometimes
What I am trying to do is instead of just removing the text with button 2 I figure draw another text :biggrin:
Quote from: dedndave on August 22, 2012, 07:56:23 PM
i think you want to try...
INVOKE SetBkMode,hdc,TRANSPARENT
before drawing the text
Were ?
All that does is remove the transparent back ground ?
I have tried numerous other (Combining the two in one Draw Text proc but could not do it ) ways but no success :(
I know the problem is with WM_PAINT ...
I need to be able to initiate both drawtext procs there is that possible?
:dazzled:
Solved :greenclp:
MichaelW was right about Drawing both from The WM_PAINT handler :icon_redface:
I Got hung up with this proc thing ....... :icon_redface:
Here is a copy if any body wants to use it
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.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
IDC_SHOW equ 1000
IDC_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
ret
MakeFont 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
ret
PaintProc1 endp
PaintProc2 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
ret
PaintProc2 endp
PaintProc3 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
ret
PaintProc3 endp
;==============================================================================
IDC_SHOW equ 1000
IDC_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 0
DlgProc 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.
:t
except.....
how many brothers named Daryl do you have, Michael ?
that must be the 50th time i have seen you use that - lol
Quote from: MichaelW on August 23, 2012, 12:17:43 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
Quote from: dedndave on August 23, 2012, 12:20:33 PM
how many brothers named Daryl do you have, Michael ?
None, that I know of :biggrin:
The phrase was part of an often repeated line in the series Newhart.
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:
: error A2131: VARARG parameter requires C calling convention
: error A2005: symbol redefinition : p
: error A2006: undefined symbol : p
: error A2006: undefined symbol : p
This is crazy ....
Why is it when I try to use that example and I use :
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
There is a problem with your macros and your prototypes.
invokeC macro DrawTextProc2:REQ,vars:VARARG
LOCAL ivars
ivars=0
FOR var, <vars>
ivars=ivars+4
ENDM
invoke DrawTextProc2,vars
add esp,ivars
ENDM
invokeC macro DrawTextProc:REQ,vars:VARARG
LOCAL ivars
ivars=0
FOR var, <vars>
ivars=ivars+4
ENDM
invoke DrawTextProc,vars
add esp,ivars
ENDM
; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤
; Prototype
; ¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤*¤
DialogProc PROTO : HWND, : UINT, : WPARAM, : LPARAM
DrawTextProc PROTO C :VARARG
DrawTextProc2 PROTO C :VARARG
I tried with out and I still Get that same Error :(
That is why I added those
I can not seem to use DrawTextProc proc p: PTR PAINTSTRUCT
I still have MASM10 is that it?
NOP
That is not it ....Just tried masm11
It says that it is too far for the jumps in the text area
The macros are never being used. Your code needs this:
DrawTextProc proc C p:VARARG
DrawTextProc2 proc C p:VARARG
@ jj2007
Yap that solved that .....
Thank You ! :t
LOL That did that ...... :icon_redface: :icon_redface:
Thanks Again all .....
And Here is MichaelW's 3 Text example with Proc and with out with rsrc.rc
:biggrin:
Quote from: MichaelW on August 23, 2012, 01:10:35 PMThe 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
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
Almost ....
The Only Problem Is that Pause .... any Ideas ?
It Looks A little Better with a Base Colour :biggrin:
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.
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
LMAO
Well qWord .....
This Is a problem the text is falling ....
This made me laugh :biggrin: