|
I don't think that is doing what you expect.
Take a look at contained windows and the ALT message maps if you want to handle messages sent to the controls in your dialog's message map.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
You dont have to say t dont do what i expect.
Anyway, what i am trying is to create some standard custom controls.
And then i would like to use them by subclassing the controls on the dialog.
So i want the controls to be what they are and not some CContainedWindow members.
Surely you must be able to do that someway or WTL looses *BIG* to MFC in that respect.
/Magnus
|
|
|
|
|
If you are trying to create standard custom controls then why are you trying to process the button down messages in dialog's main message map?
Either you use contained windows or you subclass CEdit for example and have the message map in the subclass.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I am processing the messages there because thats where they are sent.
I have subclassed the control and i have the messagemap in the subclass, but
WIN32 send messages to childwindows to the parent window.
So either i am missing a big part of the picture here or there is
not possible to create custom controls in WTL that can be reused easily.
/Magnus
|
|
|
|
|
????
You mentioned WM_LBUTTONDOWN which shouldn't be redirected to the parent. But if you are talking about notification message, then look at the reflect macros. This will allow you to reflect the messages back to the control.
MFC does handle this a bit better. But ATL/WTL gives the the macros to do the what you need to do.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Yes i got the messages mixed up with notifications there, but
in this case even the WM_LBUTTONUP is sent to the parent and not to my
subclassed window.
It's a static control, maybe they are a special?
I remember someting (but not what) about them being special if you use the default id for them. (which i dont do in this case)
/Magnus
|
|
|
|
|
Ok, then at this point you are getting into specifics I know nothing about.
So I can't honestly contribute.
But if you want me to, I can try to make up crap that sounds good.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
But if you want me to, I can try to make up crap that sounds good
Please do, can't be worse than the crap i written alreaday.
Thanks for the help anyway.
I think i leave this now, drown my sorrows in huge amounts of booze, and try again tomorrow.
/Magnus
|
|
|
|
|
Tim Smith wrote:
But if you want me to, I can try to make up crap that sounds good.
Your Dark side of Marketing that comes from selling your own product
(OK ! OK ! I admit , it was a nasty one )
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
You need to use Contained Windows and Alternate Message Maps.
The "CContainedWindow" documentation sums this up pretty good
1) Add a member CContainedWindow m_wnd1, m_wnd2 to your class
(could also be CContainedWindow<mybaseclass>)
2) in your dlg CTor, call the CContainedWindow's CTor with
1) Window Class String for the window to create
2) this
3) a dialog-unique number, e.g. 1 and 2
3) add a message map like this:
BEGIN_MSG_MAP(CMyDialog)
...
MESSAGE_HANDLER(WM_CREATE, OnCreate)
...
ALT_MSG_MAP(1)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLBDown_FirstControl)
ALT_MSG_MAP(2)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLBDown_SecondControl)
END_MSG_MAP()
that's it, pretty much.
The earth is not dying. It is being killed.
|
|
|
|
|
I dont want to use CContainedWindows, they are good if
you would like to do some special processing for controls without
creating a subclass class yourself, but for a control
you intend to reuse they are no good.
You cannot resue the code based on them. (not in any good way anyway)
Anyway i found out what the problem was, very easy just as long
as you look in the right place.
The statics have to have the SS_NOTIFY style set to recive the message.
/Magnus
|
|
|
|
|
ahhh... ok (I missed that it's just two statics)
If a parent window shall handle messages that go to a child window only, you need CContainedWindow (or some similar technique)
The earth is not dying. It is being killed.
|
|
|
|
|
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&app=50&select=188698#xx188698xx
plese enlighten me!
Thanks
|
|
|
|
|
Huh? What is the question. Your link just points back to the forum.
Good Luck,
Bill
|
|
|
|
|
Hi, i need to change the colour arrangement for an edit ctrl, i have managed to change the outlines but cannot change the background colour (the white bit) can someone help me plz.
Thanks.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
The Eclypse wrote:
When Your Mind Wonders...
Did you mean "wanders"?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
no i meant wonders....is wanders an actual word??
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
I think the original quote is "When your mind wanders, where does it go?". "wander" means "to go about from place to place usually without a plan or definite purpose".
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
i never knew that there was actually a saying.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
Ok,
In the OnCtlColor you also need
to set the BkColor of the Text.
ex for blue
pDC->SetBkColor(RGB(0,0,255)) ;
|
|
|
|
|
i did that but its still not working.
nb: This is a seperate class for the edit control.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
Ok,
In the Derived edit class override
OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
and do the same things.(Set the BkColor/TestColor/Brush).
And remember dont attach an instance of this to a edit
control placed on a dialog, rather create this dynamically
which will endure that the control will get a chance to
process the WM_CTLCOLOR msg.
Just try tinckering in this manner, it is bound to work!
|
|
|
|
|
I have tried what you suggested but it will not work, i even created a fresh class derived from CEdit, where the only thing I did was insert this code:
HBRUSH EditBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CEdit::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkColor(RGB(0, 0, 255));
return hbr;
}
and when i dynamically assigned an instance of the class to an edit box with this code:
EditBox EB;
EB.SubclassDlgItem(IDC_EDIT2, this);
the edit box did not appear, it had not been drawn.
Sorrt to be a bother but I am a newbie
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
Pleaese help me (and excuse my English)!
I have written a SDI Application which opens on start 2 (non modal) dialogs. When I now in a memer-function of Dialog 1 how can I access (member)functions on Dialog 2? Both Dialogs are instances of the Doc-Class.
In Dialog 1 an FlexGrid with an Array of Coordinates. In Dialog 2 should be paint the graph....
|
|
|
|
|
The recommended way is for dialog1 to post a command to dialog2. The handler for that command can execute the appropriate method. For example, when you click the "Show Graph In Dialog2" button in dialog1, its handler should do this:
pDialog2->PostMessage (WM_COMMAND, CMD_SHOW_GRAPH);
Dialog2's handler for the CMD_SHOW_GRAPH command should paint the graph.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|