|
i downloaded the program aimster, and has an interesting feature, as it interacts with AOL IM, it gets the buddy list, and if u click on it, it opens a AOL im window. It basically sends messages to the AOL IM application. How does it do this, does it use, FindWindow, then SendMessage, and sendtext to the AOL instant messanger app? How does it know AOL IM is running. Does anyone know how this works.
|
|
|
|
|
You've got some reading to do
Sending messages to another Window isn't a problem, you just have to figure out which messages you need to send. I don't know aimster, and I've not dug into the AOL's IM, but it should be pretty straightforward to figure out if a) AOL IM offers an API to automate the use of its messaging (which I think would be a good move for them), or b) which message ID's trigger which functions.
Problem with mapping to undocumented stuff is that it can change, which makes for unstable software. What I'm getting at here is that you might be able to 'hack' AOL IM for the current version, but there's no guarantee that all versions of AOL IM use the same messages, or that they will use the same messages in the future.
In any event, there are a few ways to enumerate the applications running on your system, depending on whether you are interested in Windowed and/or Windowless applications. A good place to start however is with the EnumWindows() Win32 API function, and you'll see links to Process and Thread functions that preform similar functions.
|
|
|
|
|
I am in trouble with hooks. I have entered the following code to my programs main view's .cpp file:
<br />
HHOOK m_hhk;<br />
static LRESULT CALLBACK KeyboardProc(int code,WPARAM wParam,LPARAM lParam);<br />
<br />
void CWinSchedulerView::OnInitialUpdate() <br />
{<br />
CFormView::OnInitialUpdate();<br />
m_hhk = SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardProc,NULL,GetCurrentThreadId());<br />
}<br />
<br />
static LRESULT CALLBACK KeyboardProc(<br />
int code,
WPARAM wParam,
LPARAM lParam)
{<br />
if (code < 0 || code != HC_ACTION)<br />
return CallNextHookEx(m_hhk, code, wParam, lParam);<br />
if (wParam == VK_F1)<br />
{<br />
AfxMessageBox("F1");<br />
}<br />
return CallNextHookEx(m_hhk, code, wParam, lParam);<br />
}<br />
<br />
void CWinSchedulerView::OnDestroy() <br />
{<br />
CFormView::OnDestroy();<br />
<br />
UnhookWindowsHookEx(m_hhk); <br />
}<br />
Well, this works well if i press F1 wheh the active window is my window. However, when i press F1 on another window it does not work. If someone tell me the problem, i will be very glad.
Thanks in advance for any helps
Mustafa Demirhan
|
|
|
|
|
Becuase you're only installing the hook for your app's thread (see the last param of SetWindowsHookEx() ).
If you want a system-wide hook, pass 0 for the thread ID. However, for system-wide hooks, the hook proc must be in a DLL. MSDN goes into depth on this - check out the docs.
|
|
|
|
|
I looked at your question in the CodeGuru web site and I tried to look at it closely. I saw no evidence there that you wanted a system-wide hook, sorry. If I had known you are trying to do a system-wide hook I would have said something there.
For best results, though, you will need to spend more time reading.
|
|
|
|
|
I guess it was not the CodeGuru web site; I guess it was your other question in this web site.
|
|
|
|
|
i have no idea but i wanna create a site with frames i used dreamweaver and like 10 other html programs, no luck yet i have no idea what to do
|
|
|
|
|
see http://planetwebdesign.com/frames.htm for samples
you can also do a internet search for
html frames
many examples should come up
|
|
|
|
|
I have tried to add a cstatic control to display a bitmap.
the background is made transparent (by using the grey color). it really appears to be transparent in my computer. But when i deploy the program in another person's computer, the background becomes not transaprent (becomes darker). Why is that?
Thanks all!
|
|
|
|
|
Hello,
I am trying to use hooks to get all keyboard events but i could not achieve to compile my code. Here is the code:
<br />
LRESULT CALLBACK CWinSchedulerView::KeyboardProc(<br />
int code,
WPARAM wParam,
LPARAM lParam)
{<br />
if (code < 0 || code != HC_ACTION)<br />
return CallNextHookEx(m_hhk, code, wParam, lParam);<br />
if (wParam == VK_F1)<br />
{<br />
MessageBox("F1 is pressed!");<br />
}<br />
return CallNextHookEx(m_hhk, code, wParam, lParam);<br />
}<br />
<br />
void CWinSchedulerView::OnDestroy() <br />
{<br />
CFormView::OnDestroy();<br />
UnhookWindowsHookEx(m_hhk); <br />
}<br />
This code is compiled with no errors. However at InitDialog() the following code gives error:
<br />
HOOKPROC lpfn = MakeProcInstance(KeyboardProc, hInst);<br />
m_hhk = SetWindowsHookEx(WH_KEYBOARD,lpfn,NULL, GetCurrentThreadId());<br />
I know that MakeProcInstance is obselete in Win32. So I tried the following:
<br />
m_hhk = SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardProc,NULL, GetCurrentThreadId());<br />
But, this cannot be compiled to. The error is same:
<br />
D:\Visual C++ Projects\WinScheduler\WinSchedulerView.cpp(216) : error C2440: 'initializing' : cannot convert from '' to 'long (__stdcall *)(int,unsigned int,long)'<br />
None of the functions with this name in scope match the target type<br />
I think i cannot give the function pointer correctly. How can i correct this error?
Thanks in advance for any help.
Mustafa Demirhan
|
|
|
|
|
Is KeyboardProc a static member of CWinSchedulerView? It must be.
|
|
|
|
|
I got this error message too. Instead of using the KeyboardProc function as a member
function of your CWinSchedulerView class, you should define it as:
static LRESULT CALLBACK KeyboardProc (int code, WPARAM wParam, LPARAM lParam);
-------------------------------------------
Marcelo Guerra
|
|
|
|
|
Using VC++ 6 ?
How can i create user interface like MS Money.
Thanks in advance
Pankaj
|
|
|
|
|
I only used MS Money 2000 for a few days a while back, but I seem to remember it using an interface that looked very much like it was written in HTML. InstallSheild for windows installer(r) uses the same technique.
You could use the CHtmlView (or a WebBrowser based class of your own) to do this, and intercept all OnBeforeNavigate2(...) calls to see if you need to display an application-specific task (i.e. exit the program, or show a dialog) not available in HTML.
You can look through the MSJ archives (http://msdn.microsoft.com/msj) for an article by Paul DiLascia, that showed you how to intercept calls using the CHTMLView to close an about dialog. Try searching for 'DiLascia CHtmlView about' and you'll get it.
You could then use framesets, exactly the same way as you would with a web site, to create your UI, with Javascript menus and such like. Then just assign commands such as 'app:createnewdocument' to 'a href=' tags (see the article mentioned above to understand this) to create a new document in a certain frame.
You could use ActiveX controls if the standard html controls don't provide what you want.
This is just one suggestion.
Yours,
David Wulff
|
|
|
|
|
OK, next question. I know how to subclass a window using SetWindowLong. No prob. However, the only way that I can find to do it, is to define a function outside of any class. Is there a way to use a function belonging to a class as the callback procedure, and if so, how do I declare it? Would it be:
m_OldWndProc=(WNDPROC)::SetWindowLong(m_ControlToSubclass.GetSafeHwnd(), GWL_WNDPROC, (LONG)CMyClass::NewWndProc);
Or, would it be
m_OldWndProc=(WNDPROC)::SetWindowLong(m_ControlToSubclass.GetSafeHwnd(), GWL_WNDPROC, (LONG)NewWndProc);
And, how do I properly cast the function point to the LONG that SetWindowLong requires for its 3rd parameter?
Also, what's the proper method of UN subclassing the window?
Thanks in advance for any help.
|
|
|
|
|
I infer from your GetSafeHwnd() calls that you're using MFC. If so, there's an easier way to do this - CWnd::SubclassWindow() .
But to answer your questions, you can't use CMyClass::NewWndProc() as the callback because that function has this as the first parameter (even though you don't write the function that way) which makes it not match the required prototype. If you make that member function static it will work, because static methods do not have a this pointer.
Also, to undo the subclassing, call SetWindowLong() again and set the wnd proc to m_OldWndProc .
|
|
|
|
|
Thanks. That makes sense. The only problem is that now I can't seem to access any members of the class, private, protected, or public (I assume that it's due to the lack of the 'this' pointer). I've never really played with CWnd::SubclassWindow, but I'll give it a go. Thanks.
|
|
|
|
|
Right, static functions can only access static members and other static functions of the class.
|
|
|
|
|
That is what the documentation says, but this is an example where the documentation is totally misleading. Just as a static function can access members of other classes, a static function is entirely capable of accessing members of it's own class.
Now I can hear you saying that I am quack or something like that, but I do it all the time. The thing that most people just do not realize is that you simply must provide to the static function (that does not have the "this" pointer) the pointer that it does not have. Very simple, yet it seems that many people overlook this and take the documentation too literally.
The trick of course is passing the pointer. Most callbacks and such have a parameter and the pointer can be passed as a parameter or part of a parameter. In the case of the situation being discussed, the solution is probably not so easy. It might be possible to use a solution simialr to MFC's solution to the equivalent problem. It is possible to create a mapping from the window handle to the pointer for the class. Right?
|
|
|
|
|
I'm using a Rich Edit control in my app to display output from a host.
I initially format the Rich Edit to use a black backgroud, white text, courier font etc... so that it looks like a terminal
windos. After that, I just dump the host messages to the control without formating.
Now for the question...
I have done this my associating a CString var with the Rich Edit. I write the host output to the CString and then update.
It seems to work fine.
However, I have read in several places that this is not a good idea. Why not?
Should I be using StreamIn with a callback? It seems like overkill for my needs.
Thanks!
Lori Mihalcik
|
|
|
|
|
Here's a question that I'm sure is going to be easy to answer. If I have an MDI application, how do I set up that first child window to be maximized on application start up? I'm sure I'm going to kick myself when I see the answer, but right now, I'm drawing a blank.
Thanks in advance.
|
|
|
|
|
Using MFC?
Well, that probably does not matter. If it is something you want to do only for the first child window, then InitInstance is probably a good possibility. You could just do a ShowWindow(SW_SHOWMAXIMIZED) for the the child, right?
|
|
|
|
|
Using ShowWindow works, except that when the application starts up, I can actually see the child being maximized. I'd like it to already be maximized on app start up (like when you start Word, the child window is already maximized). Thanks for the tip, though. Any ideas on how to get it maximized before you even see the app?
Again, thanks in advance.
|
|
|
|
|
Aha! Figured it out. Modify InitInstance as follows:
// The main window has been initialized, so show and update it.
CChildFrame *child=(CChildFrame *)pMainFrame->MDIGetActive();
child->ShowWindow(SW_MAXIMIZE);
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
Using ShowWindow was INDEED the correct way. I just stuck it in the wrong spot. Danke Zhen(Thank you)!
|
|
|
|
|
I knew you could. I knew that the positioning would make a difference and I considered whether to say something but I decided to assume you would figure it out.
|
|
|
|
|