|
My guess is that your hook gets called before the program actuyally routes the message towards any window. I don't know by heart how keyboard events are routed but my guess would be that they are targeted at the window owning the input focus. So try experimenting with the window returned by GetFocus[^], or try a different hook, like WH_GETMESSAGE, at this point i believe you can check weather the message is WM_KEYDOWN, WM_KEYUP or somesuch and hande it as you like.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
ok.. thanks a lot.. 'll try tat n get back to u..
|
|
|
|
|
You don't need to export the hook function. Just say'n.
Steve
|
|
|
|
|
I have a simple toolbar with two icons on it Icon_1 and Icon_2, I want to be able to replace Icon_2 by another Icon_3 when pushed. How can I do this? Do I have to make a new toolbar with new icons and kinda reload the new toolbar?
|
|
|
|
|
Try this function[^]
class AnyBody
{
protected:
AnyBody();
virtual void BeHappy() = 0;
public:
virtual ~AnyBody();
friend class Air;
friend class Water;
friend class Fire;
friend class Earth;
};
|
|
|
|
|
I tried that with no change at all in my toolbar.
Thanks
|
|
|
|
|
Did you call RedrawWindow() for the bar after its modification ?
class AnyBody
{
protected:
AnyBody();
virtual void BeHappy() = 0;
public:
virtual ~AnyBody();
friend class Air;
friend class Water;
friend class Fire;
friend class Earth;
};
|
|
|
|
|
I did, but not sure if its done right.
I have something like this:
m_WndToolbar.AddBitmap(1,IDB_Bitmap1);
RedrawWindow();
Not sure how or if I have to specify the rect structure for the RedrawWindow() function?
|
|
|
|
|
Try it :
m_WndToolbar.SetButtonInfo(1 ,
IDC_COMMAND2 ,
TBBS_BUTTON,
0 );
m_WndToolbar.RedrawWindow();
class AnyBody
{
protected:
AnyBody();
virtual void BeHappy() = 0;
public:
virtual ~AnyBody();
friend class Air;
friend class Water;
friend class Fire;
friend class Earth;
};
|
|
|
|
|
It didn't work for me. Does it work for you?
|
|
|
|
|
I'm using CMFCToolBar now...
...but you could debug the SetButtonInfo(..) by F11
to verify that the old button will be deleted and the new inserted
(or set a breakpoint at
bartool.cpp :<br />
void CToolBar::_SetButton(int nIndex, TBBUTTON* pButton) )
class AnyBody
{
protected:
AnyBody();
virtual void BeHappy() = 0;
public:
virtual ~AnyBody();
friend class Air;
friend class Water;
friend class Fire;
friend class Earth;
};
|
|
|
|
|
Hi,
if we use cstring like,
CString errorDescription;
errorDescription.Format(L"Connected to %s\\%ld", m_hostAddress(/*cstring type*/),Literals::CONFIGURATION_SERVER_PORT(/*int type*/));
here,instead of cstring if i use std::string errorDescription,
then how the above format can be done?
thanx.
|
|
|
|
|
|
You can use ostringstreams as described in the previous reply, or you could use Boost.Format[^], which gives you an interface more like CString::Format .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hello,
I want to find the handle of same windows currently opened.
E.g: I have started 2 notepads and I want to get handle of both notepads using some windows APIs.
I tried FindWindow(). But its only return the first notepad window handle.
Any other APIs available for getting the handle of second Window?
Please help.
-Cvaji
|
|
|
|
|
Maybe try EnumWindows[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Code-o-mat wrote: Maybe try EnumWindows[^].
But this will enumerate all the top level windows right?
I have the window name/window class of my required window.
I need to get only that specific windows.
-Cvaji
|
|
|
|
|
You can implement the filtering in the callback function, you can get the window's "name" by calling GetWindowText[^] and the class name by calling GetClassName[^], althorough i am not sure that GetClassName works on windows in different processes...
If you know the Process ID's of the notepad apps you started you can also use GetWindowthreadProcessId[^] to recognize them.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
If there is no other simple way, i have to go with this option.
Thank you for the reply.
|
|
|
|
|
You could also try using FindWindow as you did, and once you find a window, do whatever you want with it and then add a space at the end of its name (title) and then use FindWindow again until it does not find any such windows anymore, you might want to remove the extra added space when you are done, of course this would be quite an unelegant and ugly solution...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
You mean the below code will return the handle for second notepad ?
hWnd = ::FindWindow( 0, L"Untitled - Notepad " );
-Cvaji
|
|
|
|
|
No, i mean something like this:
HWND hWnd;
while ((hWnd = ::FindWindow(0, L"Untitled - Notepad")) != NULL)
{
::SetWindowText(hWnd, L"Untitled - Notepad ");
}
Since you add a space at the end of the window text, the next time you call FindWindow, it will not find this window you already used (since it's title does not mach your search string anymore) and go on looking for the next one, if you find that next one, you add a space to that one too and so on untill you get no more windows...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Wow.
Hats off you man
even though its an ugly method, i congratulate your brilliancy
But I got another method.
HWND hWnd = ::FindWindow( L"Notepad", 0 );
hWnd = ::FindWindowEx( 0, hWnd, L"Notepad", 0 );
-Cvaji
|
|
|
|
|
Gee, thanks FindWindowEx, i better rememeber that for the next time
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
If FindwindowEx was not provided by MS, i would go for your suggestion.
|
|
|
|