Hi all!
In the following source code, I can't store the result of
GetDlgItem, hDlg, 2000
in the "hLabel" variable ("mov hLabel, eax"). The SendMessage in the WM_TIMER event doesn't display any text if
I use "addr hLabel" as hwnd. But, look at the code, and tell me, why it does not work, if I use "addr hLabel" instead of eax :D
; #########################################################################
.386
.model flat, stdcall
option casemap :none
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
; #########################################################################
DlgProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
; #########################################################################
.data
szTaskBar db "Shell_TrayWnd", 0 ; taskbar class
szSysTray db "TrayNotifyWnd", 0 ; systray class
szSysClock db "TrayClockWClass", 0 ; sysclock class
szTime db "00:00:00", 0
lpWidth dd 0
lpHeigth dd 0
; hLabel dd 0
rect RECT <> ; structure
hInstance EQU 400000h
.code
start:
invoke DialogBoxParam, hInstance, 1000, 0, addr DlgProc, 0
invoke ExitProcess, eax
; #########################################################################
DlgProc proc hDlg :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD
.if uMsg == WM_INITDIALOG
invoke SendMessage, hDlg, WM_TIMER, 0, 0 ; display time
invoke FindWindow, addr szTaskBar, 0
invoke FindWindowEx, eax, 0, addr szSysTray, 0
invoke FindWindowEx, eax, 0, addr szSysClock, 0
push eax ; handle of clock
invoke GetWindowRect, eax, addr rect ; get window size
mov eax, rect.right
sub eax, rect.left ; calculate width
mov lpWidth, eax
mov eax, rect.bottom
sub eax, rect.top
mov lpHeigth, eax ; calculate heigth
; invoke GetDlgItem, hDlg, 2000
; mov hLabel, eax
invoke SetTimer, hDlg, 3000, 1000, 0 ; start timer (1 sec)
invoke MoveWindow, hDlg, 0, 0, lpWidth, lpHeigth, 0 ; resize
invoke GetDlgItem, hDlg, 2000
invoke MoveWindow, eax, 0, 0, lpWidth, lpHeigth, 0 ; resize
pop eax ; handle of clock
invoke SetParent, hDlg, eax ; draw dialog over clock
.elseif uMsg == WM_TIMER
invoke GetTimeFormat, 0, TIME_FORCE24HOURFORMAT, 0, 0, \
addr szTime, 9 ; get current time
invoke GetDlgItem, hDlg, 2000
invoke SendMessage, eax, WM_SETTEXT, 0, addr szTime
.elseif uMsg == WM_CLOSE
invoke KillTimer, hDlg, 3000 ; to clean up
invoke EndDialog, hDlg, 0
.endif
xor eax, eax
ret
DlgProc endp
; #########################################################################
end start
rsrc.rc ------------------------
#include "resource.h"
1000 DIALOGEX 0, 0, 35, 8
STYLE WS_POPUP
EXSTYLE WS_EX_TOOLWINDOW
FONT 8, "MS Sans Serif"
BEGIN
CTEXT "",2000,0,0,35,8,SS_CENTERIMAGE
END
This message was edited by bAZiK, on 7/3/2001 7:41:43 PMyou shouldnt put addr infront of hLabel, it should be:
invoke SendMessage, hLabel, WM_SETTEXT, 0, addr szTime
using "addr hLabel" you would be pushing a pointer to the handle... when using just "hLabel" it pushes the handle.
Hmmm..... sounds good. I'll try this. Thanx!
edited:
works! :D
This message was edited by bAZiK, on 7/4/2001 6:45:34 AM