|
Create a hidden window with a fixed title, and go search it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That's a good idea, except (of course there's an "except", eh?) then how do i get the handle to the instance of MyApp that's running, so i can pass it the params i need to pass it?
|
|
|
|
|
Let the hidden window accept the parameters and (if necessary) forward them to the main window.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hey all,
How can I set IE's homepage using C++ code? (Like ICQ does when you install it)
Thanks!
Oz
|
|
|
|
|
This is stored in the registry key "Start Page", under HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you - but is this path correct for all versions of IE? (4+, actually) - and is it guranteed to remain correct for future versions?
Or - is there some (COM?) API I can call to do it for me?
|
|
|
|
|
In a dialog box if you hit the Enter key the OnOK function override gets called. Or more precisely, in a modal dialog box if you hit the Enter key the OnOK function override gets called.
Why doesn't this work for a modeless dialog box? And what do I need to do to make it happen?
I've used Spy++ to check what messages are being sent when I hit the Enter button, but there's nothing
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
The problem must lie somewhere else. OnOK should be gotten called both for modal and modeless dialogs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I've tried it out a couple of times (simplified and from scratch).
If the dialog is shown using DoModal then hitting the Enter button calls OnOK. If the dialog is created as modeless and shown using ShowWindow then OnOK doesn't get call, my PC just beeps
I'm writing a Messenger type app. The user types some text into an edit control. When they hit the enter key the message should be sent (Enter triggering the OnOK function to send the message). That way they 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.
|
|
|
|
|
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.
|
|
|
|