How to draw on topmost windows
Hi to all vb programmers,
I am developing a solution for cybercafe. I have to display service time on bottom of any topmost windows like internet explorer,Microsoft word or any current 3D Game. I have got succeeded in displaying service time on topmost winodws by using getforegroundwindows, CreateDC,and DrawText. But Incase of 3D Applications, display of service time is flickered. Is there any way to draw text on topmost windows with clear display of text. Plz Help me
Re: How to draw on topmost windows
I'm using C++ and am interested in playing with this. How do you hook the system so you know when the Foreground Window has changed?
Re: How to draw on topmost windows
Quote:
Originally Posted by Chazwazza
I'm using C++ and am interested in playing with this. How do you hook the system so you know when the Foreground Window has changed?
By using Getforegroundwindow API with timer control, i can track changes in foreground window.
Re: How to draw on topmost windows
I realise it can be done with a timer, but that is a bit resource intensive because in my case it would have to be called very frequently (every 10ms probably), just hoping there was some kind of hook I could use, but if I have to use a timer I will.
Re: How to draw on topmost windows
Quote:
Originally Posted by Chazwazza
I realise it can be done with a timer, but that is a bit resource intensive because in my case it would have to be called very frequently (every 10ms probably), just hoping there was some kind of hook I could use, but if I have to use a timer I will.
So Anybody have any idea how to draw text on foreground window with clear display. Plz Reply me
Re: How to draw on topmost windows
Please Help me if any vb expert is here???????????????
Re: How to draw on topmost windows
I'd need to see the code, but off the top of my head try, LockWindowUpdate API, before and after a change, ie Lock,... Update the time,... then unlock.
Here are some related API functions to use:
VB Code:
Public Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function apiLockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Integer) As Integer
Public Declare Function apiGetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer
Public Declare Function apiGetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Integer) As Integer
Public Declare Function apiWindowFromDC Lib "user32" Alias "WindowFromDC" (ByVal hdc As Integer) As Integer 'Retrieves the handle of the window associated with a device context
Public Declare Function apiGetTopWindow Lib "user32" Alias "GetTopWindow" (ByVal hwnd As Integer) As Integer
VB Code:
apiLockWindowUpdate(apiFindWindow(vbNullString, "Form1"))
'Refresh time here
apiLockWindowUpdate(False)
'Where Form1 is the caption of the window your updating
'Or try GetDeskTopwindow, to lock the entire desktop for that split second