|
I'd like to have my MFC app run a separate console app and have its output redirected to an edit box inside of it -- sort of how Visual C++ works when you tell it to run a tool and it sends the output to the Output window.
How is that done?
Thanks,
Alvaro
|
|
|
|
|
Use hStdInput/hStdOutput/hStdError members of the strSTARTUPINFO structure. Don't forget about adding STARTF_USESTDHANDLES to dwFlags.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I have a window1. On some event, I create a message box using AfxMessageBox(). When the user enters ENTER or ESC in the latter one, it closes and the key is sent to the window1. As I need to handle these keys inside window1 for some other purposes, I would like to know if there is any way to prevent this sending.
Thank you in advance,
Andrei
|
|
|
|
|
I'm not sure if I've understood this right. Do you want to handle the returned result from the message box in window1 (the IDOK, IDCANCEL)? Or do you want the actual key press returned to the window. (VK_ESC, VK_ENTER)
The IDOK cancel is handled like below
int nResult = AfxMessageBox("My question here", MB_OK | MB_CANCEL");
if(nResult == IDOK)
{
// okay clicked
}
else
{
// cancel pressed
}
|
|
|
|
|
Sorry, it was my mistake. Now, I guess, question is more clear.
Actually, I need to prevent this sending a message to window1.
Now program operates like this:
1. some event;
2. message box;
3. user presses ESC or ENTER;
4. window1 operates like this key was pressed in it.
5. user gets not what he expected to see.
Andrei the Adroit
|
|
|
|
|
Thank you for reply.
I guess, my question was not so clear. Actually, I would like to have following results. I have ESC and ENTER keys handled in window1 for some purposes (say, events to draw something or not). When I call MessageBox the user answers it with a keyboard. The MB is closed AND the ESC or ENTER are then sent to my window1. As a result, user makes some changes in window1 even if he didn't want them. That's why I would like to prevent this sending.
|
|
|
|
|
Has anyone figured out how to properly and completely handle changing the app's displayed language on changes to the user's keyboard input locale? This message is supposed to be sent to notify the app, BUT I am not always getting it (only when you click on the taskbar keyboard input locale icon, not when you use the keyboard shortcut to do it). AND I only seem to get it when I set a breakpoint on the message handler.(!) AND when I DON'T get it, the app AND the keyboard input locale selector AND the debugger all lock up. Seems to have something to do with the way you pass the message on, via DefWindowProc(). I have tried a few different ways with no success.
I am using NT 4.0, SP6. (Is THIS the source of the problem? I have heard it may be...)
TIA!
|
|
|
|
|
Yes, it *is* bad form to reply to one's own post, sorry! This was not a setup for self-glorification.
The message IS coming thru in all cases, just that for the keyboard shortcut, the message gets sent to the MDICLIENT, not the frame. This code in the frame does the trick, it apparently just needs to be handled in the MDICLIENT as well:
(header)
afx_msg LRESULT OnInputLangChangeRequest( WPARAM wParam, LPARAM lParam );
(message map)
ON_MESSAGE( WM_INPUTLANGCHANGEREQUEST, OnInputLangChangeRequest )
(implementation)
LRESULT MainFrame::OnInputLangChangeRequest(
WPARAM wParam,
LPARAM lParam
) {
TRACE( _T("Input language change request, Lang = %X, Sublang = %X\n"), HIWORD( lParam ), LOWORD( lParam ) );
// You must call this for the request to get passed on.
// "When the DefWindowProc function receives the WM_INPUTLANGCHANGEREQUEST
// message, it activates the new input locale and notifies the application
// of the change by sending the WM_INPUTLANGCHANGE message."
LRESULT lResult = DefWindowProc( WM_INPUTLANGCHANGEREQUEST, wParam, lParam );
// Extract the language from the message and select the locale.
LCID lcidNew = MAKELCID( lParam, SORT_DEFAULT );
::SetThreadLocale( lcidNew );
// **Reload display**
return lResult;
}
|
|
|
|
|
Also handle the message in the MDI child frame as needed. Oh brother!
|
|
|
|
|
Ok this is it! You won't get another post on this outta me in THIS LIFETIME! :>
Here is where you need to trap WM_INPUTLANGCHANGEREQUEST in MFC MDI apps:
1) your CWnd-derived class used to subclass MDIClient
2) your CView-derived class(es)
Over and out!
|
|
|
|
|
I would like to create an automation which could use excel. I need excel to catch values for functions which are implemented with vc++.
I believe that I could use GetValue function like that: range.GetValue which return a VARIANT. It's at this step I have a problem, because, for example if my function need of a double parameter, and this parameter is given by the value catched on excel. How my function could recognize it?
thank for your help
gerald;P
|
|
|
|
|
I would like to create an automation which could use excel. I need excel to catch values for functions which are implemented with vc++.
I believe that I could use GetValue function like that: range.GetValue which return a VARIANT. It's at this step I have a problem, because, for example if my function need of a double parameter, and this parameter is given by the value catched on excel. How my function could recognize it?
thank for your help
|
|
|
|
|
Does anyone know how you can create a virtial directory using C++ or MFC. Sample code would be appreciated
|
|
|
|
|
Depends on what you mean by "virtual directory". Do you want to create an actual file system extension? Or a Shell extension? Shell extensions are things like the Printer folder, the Control Panel Folder, the Dial-up networking folder, etc...
File system extensions are directories you can go to from a command line and appear to be real directories, even though they're not.
If you want a shell namespace extension, then check this article:
http://www.codeproject.com/shell/shlext.asp
If you want the file system extension, then good luck, I don't know of an example for that.
|
|
|
|
|
Hi
i am trying to use this function to retrieve multiple key values
it returns always an error
can anybody tell me how to fill the VALENT structure specified
thanks
|
|
|
|
|
I have created an menu dynamicly and set as ownerdraw to add icons and bitmaps.
But when I click on a popup item in the menu, and move to another popup item the menu closes
i.e.
popup_item1
-->menu_item1
-->menu_item2
-->menu_item3
popup_item2
-->menu_item1
-->menu_item2
above: If I click popup_item1 the menu items are displayed in a popup , if i move the mouse to popup_item2 the menu disapears.
Any ideas???
regards,
pgudge
NOTE:::
I forgot to mention, when I have the menu poping up on a Dialog box it doesn't do this it is fine, it only closes the menu when it's opens on the system tray.
|
|
|
|
|
If no one is no the wiser it was a little error on my part.
When the SystemTray icon is clicked and a popup / menu item is selected it focus on the Dialog box which is open, and closing the menu.
All I need now is a invisible dialog, or even better a message pump outside the dialog.
regards,
pgudge
|
|
|
|
|
Hi!
Does anyone know, how to determine (until preprocessor defines) the app use MFC or not, if included support MFC in static library ?
|
|
|
|
|
can anybody tell me how i would retrieve the cursor position (the text cursor in an edit control....)
thanks in advance!
|
|
|
|
|
Take a look at the EM_* messages, I think you can do what you want with EM_LINEFROMCHAR and EM_GETSEL
BTW,
In an edit control it's not called a cursor, but a caret...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Where can I find a C++/MFC source code example about how to add the OLE Drag Drop events (OLEStartDrag, ...) to an ActiveX control.
|
|
|
|
|
Anyone know how to read the page count from a multipage tif image.
|
|
|
|
|
I would also be interested in tips on how to access this information - I am often asked to provide an index of a directory including the file name and number of pages for group 4 fax encoded TIFFs. Any info or tips would be appreciated
|
|
|
|
|
Hi,
My app uses a context menu in one of its views, which works fine on its own!
The problem comes when i try to add other functionality to the WM_RBUTTONDBLCLK.
The context menu appears on the double click!
Is it posible, or even worth it, to get them working together?
|
|
|
|
|
You need to use a timer.
1) In WM_RBUTTONDOWN handler, create the timer with a timeout period of 2 * ::GetDoubleClickTime(). Do not display popup menu here - you don't know if this is a double-click or single-click.
2) Insert KillTimer in WM_RBUTTONDBLCLK.
3) Add WM_TIMER handler - you'll get this message if somebody right-clicks once and second click doesn't come. The code with popup menu should reside here.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|