|
Very same app created from scratch and just changing the modal/modeless aspect? This is weird. If the code is short enough you might want to post it here.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'd love to, but it's commercially sensitive and I'm contractually bound to keep it to myself.
It's not the whole app. It's just a dialog within it.
Is there any other way to trap when the enter button has been pressed while my edit control has focus?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Is there any other way to trap when the enter button has been pressed while my edit control has focus?
Yes, something like:
void CMyDlg::OnOK()
{
AfxMessageBox("OnOK called");
...
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That's the whole problem.
When my dialog is modeless and the focus is on (in this case) an edit control and the user hits the enter key, nothing happens. OnOK does not get called, the PC just beeps.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Are you somehow pretranslating messages / using accelerators in your app? That (maybe) could interact with the ENTER key processing.
Also, does this problem show if the focus is on some other control of the modeless dialog?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It's a dialog that is part of an ActiveX control. That shouldn't make a difference should it?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
That shouldn't make a difference should it?
Not sure... Try this (if you please): set the main window as the parent of the modeless dialog (instead of the ActiveX control window).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
For some reason I can't get it to work outside of my app. I have created a new dialog-based app and imported all of the resources. But Create always returns 0
I even tried it as a modal dialog and DoModal always returns -1 instantly.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I don't know. It beats me. I think nevertheless you should pursuit the approach of changing the parent of your modeless dialog. If you come up with something please tell us back
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Derek Lakin wrote:
It's a dialog that is part of an ActiveX control. That shouldn't make a difference should it?
It might... I believe there's a bug idiosyncrasy in how MFC routes messages between ActiveX controls and everything else that would cause this problem in some situations... But i can't find it mentioned in MSDN right now if i stumble onto it later, i'll let you know.
Meanwhile, have you tried using PreTranslateMessage() to intercept the enter key? This is sort of a brute-force method, but hey, if it works, it works.
Developers that like shiny objects also dig case mods and scratch-and-sniff stickers. Klaus Probst, The Lounge
|
|
|
|
|
Thanks for the tip. I'll look into it and alternatively the use of PreTranslateMessage.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I can't find anything in MSDN either
I've tried adding a PreTranslateMessage override to my dialog class but it doesn't get called for keyboard input when the edit control has focus
Any other ideas?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek Lakin wrote:
Any other ideas?
Nothing's coming to mind i'm afraid...
You say it's part of an ActiveX control. By this do you mean that the dialog itself is embedded into a non-modal ActiveX control, or that it is created with the ActiveX control as it's parent.
Is the edit control a normal edit control, or is it subclassed in some way?
Developers that like shiny objects also dig case mods and scratch-and-sniff stickers. Klaus Probst, The Lounge
|
|
|
|
|
The dialog itself is embedded inside an ActiveX control, which is derived from COleControl. In the case of my test app, the ActiveX control just sits inside a VB form.
The edit control was just a normal CEdit control, but to work around this problem I have created an extended CEdit control which handles WM_CHAR messages. When it get's one for VK_RETURN it justs calls the function I want in the parent.
Thanks for your help.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Well, at least you've found some solution then. I keep thinking i've read something about this, but no amount of searching on MSDN has produced results
The only other thing i can think of to try would be to override PreTranslateMessage() in the ActiveX control class itself.
Developers that like shiny objects also dig case mods and scratch-and-sniff stickers. Klaus Probst, The Lounge
|
|
|
|
|
Are you sure the edit control doesn't have the ES_WANTRETURN style set? If you are not sure, use Spy++ to find out.
|
|
|
|
|
ES_WANTRETURN is definately not set for the edit control.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
rather than finding out why not, why not just make a new button, label it "OK" and write your own OnOK function?
-c
Conscience is what hurts when everything else feels good.
Smaller Animals Software, Inc.
|
|
|
|
|
I need something to happen when the Enter button is pressed, but the focus is on a different control.
It's a messenger type app. When you type a message into an edit control, the message should be sent when you press the Enter button, so you don't have to use the mouse to click on the send button.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
i agree with chris
create a new button
create a click event for the button
in the button place the following code
CDialog::OnOK();
|
|
|
|
|
This doesn't solve the problem, because the BN_CLICKED notification handler will not be triggered when the Enter button is pressed, which is the behaviour I want.
It doesn't necessarily have to be the OnOK function that gets called, but it must be the Enter button being pressed (while the focus is on an edit control) that triggers a function call.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
sorry i misunderstood the problem.
what you want to do is goto the properties of the button and make it the default button. when enter key is pressed that button will click.
|
|
|
|
|
The button already has the default button style set
As I think mentioned earlier in the thread: if the dialog is loaded as modal it works fine, if it's shown as modeless the behaviour stops and pressing the enter key has no effect
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
In my application OnOK called correctly. Please, write some your code...
|
|
|
|
|
I have a problem with capturing an image from Windows media Player.
I have implemented CMediaplayer in my dialogbased app. and want to capture an image from the MediaPlayer window/control after I pause/stop the MediaPlayer.
Does anyone know how to do that?
I´m using MS Windows 98.
Thanks in advance
Jesper s.
|
|
|
|