News:

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

Main Menu

Color Button text

Started by ragdog, February 26, 2016, 05:50:23 AM

Previous topic - Next topic

ragdog

Under Xp and Win7 looks good
Try to delete the original button Text


TouEnMasm

Here a perfect result even with Windows 10 (even better look than the standard button):
The code is mine.


; .if uMsg == WM_CREATE
; mov ebx,lParam
; invoke CreateWindowEx,0,ADDR bouton,NULL,50010000h,
; 50,50,100,30,hwnd,NULL,hInstance,NULL
; mov xHcontrole,eax
; invoke SetWindowLong,xHcontrole,GWL_WNDPROC,Event_xHcontrole
; mov Prev_Event_xHcontrole, eax       ;retourne l'adresse de la premiere procédure
; ButtonState dd EDGE_RAISED
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Event_xHcontrole proc hwnd:DWORD, uMsg, wParam, lParam
Local retour:DWORD,hdc:DWORD,rect:RECT
Local Ps:PAINTSTRUCT
mov retour,0 ;la plus commune des valeurs de retour

.if uMsg == WM_PAINT
invoke BeginPaint,hwnd,ADDR Ps     
mov hdc, eax
INVOKE     GetClientRect, xHcontrole, addr rect
INVOKE     SetTextColor, hdc,00FF8000h ;blue
INVOKE     SetBkMode, hdc, TRANSPARENT  ; Set the text background to transparent
INVOKE     DrawText, hdc, TXT("BOUTON"), -1, addr rect, DT_CENTER or DT_VCENTER or DT_SINGLELINE
INVOKE     DrawEdge, hdc, addr rect, ButtonState,BF_RECT
invoke EndPaint,hwnd,ADDR Ps

.else
.if uMsg == WM_LBUTTONDOWN
mov ButtonState,EDGE_SUNKEN
.endif
.if uMsg == WM_LBUTTONUP
mov ButtonState,EDGE_RAISED
.endif
invoke CallWindowProc,Prev_Event_xHcontrole,hwnd,uMsg,wParam,lParam
mov retour,eax
.endif
mov eax,retour
ret
Event_xHcontrole endp

Fa is a musical note to play with CL

HSE

#17
Here a test of ragdog's last code, that look good in win7:

(this is compiled with MASM32 SDK, perhaps some difference with Yves' own SDK).
Equations in Assembly: SmplMath

ragdog

Hello i think my code have under windows 10 a calculate rect problem
I have only test under Xp and 7 and it works perfect and i have no windows 10 to test and find a result to works on
all windows.