 |
|
 |
Is there any chance you could show how to resize the controls? or point towards an article which describes such things
|
|
|
|
 |
|
 |
I'm trying get the window messages of a given MFC program (like Acrobat Reader or the Program you obtain with the standard VS2005 MFC Wizard).
I subclass every window of the application, but I am not able to catch the messages that are sent to the window. Actually the messages don't go in my window procedure, and I don't know why. In Acrobat Reader, I can catch a few messages, but not WM_MOUSEMOVE or WM_PAINT.
I guess that these messages are getting into another windowproc before falling in mine. But I don't know which is this window proc and how I can override it.
Spy++ is able to catch these messages (It would be nice if someone had the source code of Spy++ ).
I'm rather efficient with subclassing and I really wonder why I am not able to catch the messages of an MFC app.
If you are able to write a program which able to get the messages of an existing MFC application, like Spy++ does, I think that my company would give you a lot of money!!!
Do you have any idea ?
I. Chollet
ivan.chollet -at- lynanda.com
|
|
|
|
 |
|
 |
You can not subclass windows accross process boundries that easily. I think you should load a DLL in the same process space of the same application to catch windows messages. I need to investigate it.
Ralph Varjabedian
Software Engineer
|
|
|
|
 |
|
 |
You are right.
You have to enter into the target process.
To do it my preferred way is to set up a global hook.
THEN you are allowed to subclass.
In fact, what I am not able to do is to get the WM_MOUSEMOVE messages of Acrobat Reader.
I am definitely able to subclass the HWNDs of Acrobat.
Actually, after a few investigations, I don't know if this problem is related to MFC. I would say this problem is specific to Acrobat.
Ivan
|
|
|
|
 |
|
 |
I have a controll subclassed from a STATIC, whever I step through the code in a debug session – MSVC 6.0 / The IDE “Knows the name of my derived class, but calling GetClassName or GetRunTimeClass returns the base class, NOT the one I am after – is there a way for me to test for it programatically?
Hope someone can give me a clue
Cheers
Alex
|
|
|
|
 |
|
 |
I need a code for ComboxBox, whose styles are to be changed during Runtime, with their options on the same Dialog.
Maharaj
|
|
|
|
 |
|
 |
Hi,
Excellent work, well done!! How can you resize controls with this class?
Cheers
Thomas
|
|
|
|
 |
|
 |
The caption said it works for VC++ 6.0. It doesn't!! It's a VC++ 7.0 sample.
How about providing one for VC++ 6.0?
Thanks.
William
Fortes in fide et opere!
|
|
|
|
 |
|
 |
Hi William
Adding the class itself to a visual c++ 6.0 project is straight forward. Try it yourself, if you still feel you need a full sample in VC 6, let me know. Take care.
Ralph Varjabedian
Software Engineer
|
|
|
|
 |
|
 |
How can I move & resize Group Boxes?
They don't react on WM_LBUTTONDOWN and so on..
|
|
|
|
 |
|
 |
You will have this problem with static controls as well.
By default, Static Controls and Group Boxes do not send notification
messages. For a static control, you need to add SS_NOTIFY to its style. I didn't have time to look into the Group Box style you should add (try the same one). Also you need to change the default ID of the GroupBox or the Static (for static, ID_STATIC will not work, change it).
Let me know when it works. if it doesn't work with you, then i will try it myself.
|
|
|
|
 |
|
 |
Hey, nice class. I tried setting the notify style and changing the ID but it didn't work.
--
Synetech
|
|
|
|
 |
|
 |
This can works for static controls. You should edit file DoubleSubclassDlg.cpp, function CDoubleSubclassDlg::PREDblSubclassFunction. Just after handling of WM_LBUTTONUP message:
if (nMsg == WM_LBUTTONUP)
{
if (::GetCapture() == m_hWndOfLButtonDown)
::ReleaseCapture();
m_hWndOfLButtonDown = NULL;
bDoReturn = true;
return 0L;
}
add the following lines:
if (nMsg == WM_NCHITTEST)
{
POINT ptMouseCursor;
RECT rcClient;
POINT ptClientUL; POINT ptClientLR;
::GetClientRect( hWnd, &rcClient );
ptClientUL.x = rcClient.left;
ptClientUL.y = rcClient.top;
ptClientLR.x = rcClient.right + 1;
ptClientLR.y = rcClient.bottom + 1;
::ClientToScreen(hWnd, &ptClientUL);
::ClientToScreen(hWnd, &ptClientLR);
::SetRect( &rcClient, ptClientUL.x, ptClientUL.y, ptClientLR.x, ptClientLR.y );
GetCursorPos(&ptMouseCursor);
if ( ::PtInRect( &rcClient, ptMouseCursor ) )
{
bDoReturn = true;
return HTCLIENT;
}
return 0L;
}
Works without changing the default ID of control.
Thank you for very good article
T. Lewandowski
|
|
|
|
 |
|
 |
Simple and effective! 5 points!
|
|
|
|
 |
|
 |
Thanks
Ralph Varjabedian
Software Engineer
|
|
|
|
 |
|
|
 |
|
 |
This also works in VC6 (remove the unneeded redefine _WIN32_WINDOWS in stdafx.h if you back-port it). Pretty neat trick. Now you need to show off how you save and restore the positions from run to run!!
"I was in a computer game. Funny as hell, it was the most horrible thing I could think of."
|
|
|
|
 |
|
 |
Actually the code I designed for my company, had a full fledged form editor.
You can resize, move, hide/show, add default text to text boxes, make default values for checkboxes and set whether some textboxes would be readonly. The form editor engine used to save settings directly to the database.
Of course, the code is owned by the company (except for the engine that I published here), i wish i could share the full code with other developers...
Ralph Varjabedian
Software Engineer
|
|
|
|
 |
|
 |
Actually to be fair, most of the form editing work was done by one of my highly appreciated co-workers , My work was the class engine and some helping out with the editor.
Ralph Varjabedian
Software Engineer
|
|
|
|
 |