flat assembler
Message board for the users of flat assembler.
Index
> Windows > How to change label text color at runtime? |
Author |
|
metalfishx 25 Oct 2004, 13:54
Hello Vasilev.
Well, if you take the Handle of the device content (HDC) you can use the api SetTextColor to do that. WinApi Help In C: -------------------------------------------------------------------------------- LIB: GDI32 COLORREF SetTextColor( HDC hdc, // handle of device context COLORREF crColor // text color ); Parameters hdc: Identifies the device context. crColor: Specifies the color of the text. Return Values If the function succeeds, the return value is a color reference for the previous text color. If the function fails, the return value is CLR_INVALID. To get extended error information, call GetLastError. Remarks The text color is used to draw the face of each character written by the TextOut and ExtTextOut functions. The text color is also used in converting bitmaps from color to monochrome and vice versa. -------------------------------------------------------------------------------- Even, i think you can use GetDC to obtain the HDC... LIB: USER32 HDC GetWindowDC( HWND hWnd // handle of window ); -------------------------------------------------------------------------------- I hope this can help you. Also, i know theres in the icelion tutorials you can find the way to do this, but im at the office now and i dont have these material here, mave later (if some one dont let you something more) i look at these code. Cheers. _________________ --------------------------------------- Roberto A. Berrospe Machin Ruta Internet, Florida Uruguay --------------------------------------- |
|||
25 Oct 2004, 13:54 |
|
Vasilev Vjacheslav 25 Oct 2004, 14:20
thanks for answer
i'll try it _________________ [not enough memory] |
|||
25 Oct 2004, 14:20 |
|
Matrix 25 Oct 2004, 14:59
please,
give a more specific thread topic posting rules are just about finished, its kinda shame to write this in to the posting rules, but ... this thread should have had a name like: "how to change label text color at runtime?" |
|||
25 Oct 2004, 14:59 |
|
Vasilev Vjacheslav 26 Oct 2004, 05:47
metalfishx, your method wont works
i think the best method is SS_OWNERDRAW and super-subclassing, i was played around it - works perfect, who knows other methods? _________________ [not enough memory] |
|||
26 Oct 2004, 05:47 |
|
mike.dld 26 Oct 2004, 10:42
Code: format PE GUI 4.0 entry start include '%fasminc%\win32a.inc' section '.data' data readable writeable _title db 'Win32 program template',0 _class db 'FASMWIN32',0 _title2 db 'Label',0 _class2 db 'STATIC',0 mainhwnd dd ? hinstance dd ? hlabel dd ? color dd ? msg MSG wc WNDCLASS section '.code' code readable executable start: invoke GetModuleHandle,0 mov [hinstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax mov [wc.style],0 mov [wc.lpfnWndProc],WindowProc mov [wc.cbClsExtra],0 mov [wc.cbWndExtra],0 mov eax,[hinstance] mov [wc.hInstance],eax mov [wc.hbrBackground],COLOR_BTNFACE+1 mov [wc.lpszMenuName],0 mov [wc.lpszClassName],_class invoke RegisterClass,wc invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,\ 128,128,150,70,NULL,NULL,[hinstance],NULL mov [mainhwnd],eax invoke CreateWindowEx,0,_class2,_title2,WS_VISIBLE+WS_CHILD+SS_CENTER,\ 5,5,135,35,eax,NULL,[hinstance],NULL mov [hlabel],eax invoke SetTimer,[mainhwnd],123,50,NULL msg_loop: invoke GetMessage,msg,NULL,0,0 or eax,eax jz end_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke KillTimer,[mainhwnd],123 invoke ExitProcess,[msg.wParam] proc WindowProc, hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_TIMER je wmtimer cmp [wmsg],WM_CTLCOLORSTATIC je wmctlcolorstatic cmp [wmsg],WM_DESTROY je wmdestroy defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp finish wmtimer: invoke InvalidateRect,[hlabel],NULL,FALSE jmp finish wmctlcolorstatic: invoke SetBkColor,[wparam],$00000000 invoke SetTextColor,[wparam],[color] add [color],1234567890 and [color],$00FFFFFF invoke GetStockObject,BLACK_BRUSH jmp finish wmdestroy: invoke PostQuitMessage,0 xor eax,eax finish: pop edi esi ebx return endp section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL',\ gdi,'GDI32.DLL' import kernel,\ GetModuleHandle,'GetModuleHandleA',\ ExitProcess,'ExitProcess' import user,\ RegisterClass,'RegisterClassA',\ CreateWindowEx,'CreateWindowExA',\ DefWindowProc,'DefWindowProcA',\ GetMessage,'GetMessageA',\ TranslateMessage,'TranslateMessage',\ DispatchMessage,'DispatchMessageA',\ LoadCursor,'LoadCursorA',\ LoadIcon,'LoadIconA',\ PostQuitMessage,'PostQuitMessage',\ SetTimer,'SetTimer',\ KillTimer,'KillTimer',\ InvalidateRect,'InvalidateRect' import gdi,\ SetBkColor,'SetBkColor',\ SetTextColor,'SetTextColor',\ GetStockObject,'GetStockObject' |
|||
26 Oct 2004, 10:42 |
|
metalfishx 26 Oct 2004, 14:03
Yep, this works
GetDC or GetWindowDC works only with the whole window |
|||
26 Oct 2004, 14:03 |
|
Vasilev Vjacheslav 27 Oct 2004, 06:21
mike.dld, your method like my method, but i use whole WM_PAINT for paint color, thanks
_________________ [not enough memory] |
|||
27 Oct 2004, 06:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.