|
-
Oct 3rd, 2000, 01:36 PM
#1
Thread Starter
New Member
Okay, here's the problem in a nutshell. Is it possible to have one program running in the background on a PC that will actually output to other applications. I don't believe this can be done, but my boss seems to think it can be.
Specifics are: A card swipe is hooked into a terminal and controlled through Active-X Controls. He wants the information received from that swipe to be displayed on the active window, whatever window may be active at the time. This could be anything from an emulation program to an MS-DOS window to another Windows application.
Any help would be greatly appreciated.
Thanks,
Dave C
-
Oct 3rd, 2000, 03:26 PM
#2
Lively Member
All things are possible to programmers that believe!
Well almost anyway. Doesn't sound at all praticle and it
certainly does not comply with standard Windows functionality.
Tell your boss that the app should never interfere with another app in that way unless it was planned so.
But, this can be done. If your app can grab the info from
the controls that retrieve it then all you need to do is
get the handle of the active window.
Once you have the handle to that window you could (if the
info is short)change it's title bar caption to display the
info if the info is more than 255 chars then you also need the handle to the active windows client area.
You can draw to the active win's client area with something like this:
Code:
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Sub Command1_Click()
Dim ret, hWnd, hdc As Long
Dim s As String
hWnd = GetActiveWindow() ' window handle
hdc = GetWindowDC(hWnd) ' window hdc
s = "testing"
ret = TextOut(hdc, 10, 50, s, Len(s)) ' draw in the window
ret = SetWindowText(hWnd, s) ' set the caption
End Sub
However, the boss should also be warned that even if you
can draw the info the active window that doesn't mean it
will be readable because that window just might have loads
of text, controls, or other stuff cluttering up the active window!
hope it helps
C/C++,Delphi, VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
I love deadlines. I like the whooshing sound they make as they fly by.
—Douglas Adams
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|