|
Did you use CreateProcess() or ShellExecuteEx() to start Excel?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Then, how am I going to format the excel if I used ShellExecuteEx() or CreateProcess()?
the following way is to open the excel application. If I used ShellExecuteEx() how to get an app object? if I dont have app obj, I can't get workbooks, no workbooks there will not be no workbook, sheets or sheet. I thought about using ShellExecuteEx() but I don't know how to get workbooks back after that. Any suggestion please?
<br />
CApplication app; <br />
<br />
if(!app.CreateDispatch(TEXT("Excel.Application")))<br />
{<br />
AfxMessageBox(TEXT("Could not create Excel Application Object."));<br />
open = false;<br />
}<br />
else<br />
{<br />
app.put_Visible(TRUE);
app.put_WindowState(2);
app.put_UserControl(TRUE);
<br />
books = app.get_Workbooks();
book = books._Open(fileName, covOptional,covOptional, covOptional, covOptional, covOptional, covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional);
<br />
sheets = book.get_Sheets();<br />
<br />
int numofSheets =(int) sheets.get_Count(); <br />
int index=1;<br />
<br />
<br />
for( index=1;index <= numofSheets;index++)<br />
{<br />
lpDisp = sheets.get_Item(COleVariant ((short)(index)));
ASSERT(lpDisp);<br />
}<br />
}<br />
|
|
|
|
|
pnpfriend wrote:
If I used ShellExecuteEx() how to get an app object?
You couldn't, hence my reason for clarifying exactly how you were starting the Excel application.
When I use automation with any of the Office products or Internet Explorer, I do so with the intent of there being no user interaction. If I wanted user interaction, I would use CreateProcess() or ShellExecuteEx() . What you have here seems to be the need for both automation and user interaction. Is this a fair assessment?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
True.. I need both automation and user interaction to preview the file first then user print the file manually.
It is hard right?
|
|
|
|
|
I have a VC++ 6 MDI application using the conventional MFC Doc/View architecture. At any given time there can be several different views of several different document types open.
I want to be able to programmatically "activate" one of these Views, i.e. if it is hidden by other Views then I want it to become visible, just as if the User clicked on the relevent numbered item in the Windows menu (NB this does work correctly). The specific View that is to be activated does not directly depend on User input, e.g. it could be as a result of a message from another thread.
This seems to be an obvious thing to be able to do yet I cannot make it work. I am inside a message handler within my CMainFrame class; I have a CMyView* to the View I want to activate. MDIActivate(pMyView) seems to do nothing; I can't get CMDIChildWnd::MDIActivate() to work for me.
Perhaps it is something to do with me using the above functions with a CView* not a CWnd*. Can I deduce the latter from the former in a way that will make this work? What else may be wrong?
All assistance appreciated.
|
|
|
|
|
I want to run this file C:\gzip.exe like I do in the prompt:
gzip.exe -9 C:\myfile.wrl
How can I make the call with the parameters “-9” and “C:\myfile.wrl” ?
_____________________________
...and justice for all
APe
|
|
|
|
|
Either use ShellExecute() or CreateProcess() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
Hi,
i have a sub class of the CMDIChildWnd class and i would like to replace the minimize button with a button with the '*'-sign. This to have a consistent user interface. After a lot of searching I haven't found a way of doing that (Only to remove it with ModifyStyle)
Anyone have any ideas of how to do this?
thx alot
|
|
|
|
|
I think you need to repaint the captions.
have a look at WM_NCPAINT (CWnd::OnNcPaint and related messages and API )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I'm trying to beat a track and field type game. The game runs on a internet page and requires me to alternately press the 'B' and 'N' buttons :(to gain speed.
Is it possible to write an application that actually sends these characters to the game
|
|
|
|
|
tab1 wrote:
Is it possible to write an application that actually sends these characters to the game
Probably. Are the buttons just standard <input type = button> elements, are are they actually part of a Flash, Shockwave, or ActiveX control?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Haven't got a clue.
Here's the link to the game
http://news.bbc.co.uk/sport1/hi/olympics_2004/herculympics/default.stm
|
|
|
|
|
Notice the paragraph right below the movie:
Visit our Flash Help Page if you have any questions or problems about using the Flash plug-in.
Based on that, I would say to try using SendMessage(WM_CHAR, 'B', 0) to send the keys to that window.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes but.......
SendMessage will send the character to the application that i have written. How do i get it to go to the internet page with the flash game on instead?
|
|
|
|
|
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb = _T("open");
sei.lpFile = _T("http://news.bbc.co.uk/sport1/hi/olympics_2004/herculympics/default.stm");
sei.nShow = SW_SHOWNORMAL;
ShellExecuteEx(&sei);
WaitForInputIdle(sei.hProcess, INFINITE);
HWND hWnd = FindWindow("IEFrame", NULL);
ShowWindow(hWnd, SW_SHOW);
SetForegroundWindow(hWnd);
SendMessage(hWnd, ...);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
Thanks for your continued patience good ideas but......
It still doesn't work.
The SHELLEXECUTEINFO method certainly starts the web page but i couldn't figure out what to do next;
The FindWindow methods also works but it doesn't get my WM_CHAR messages
The method suggested by bdiamond is also not working. Here i created a sdi app with HTML view and used SetTimer is to fire the
SendMessage(WM_CHAR, 'B', 1)
Sleep(100)
SendMessage(WM_CHAR, 'N', 1)
As a check to ensure this was working i put an OnChar handler in there to see my messages working
The funny thing is that when you press charcaters in the view (ie the web page) the OnChar does not catch anything, but the man starts swimming if you pressing the B and N as you are supposed to
Again, thanks for any help
|
|
|
|
|
Or you can always put a webbrowser control in an app and set the address and open the page there. then have a button you can press that loops a million times (or whatever) and use a control variable of the ClassWizard-generated class for the browser control and do a sendmessage().
[insert witty comment here]
bdiamond
|
|
|
|
|
I am trying to Create a Directory with Path length > 260 Characters..
Windows is not allowing me to create when length exceds 260 characters..The function i used is CreateDirectory().. When I saw the SDK Documentation it said I need to Use Unicode Version of this function for a maximum path length of 32767.
I want to know wht is this Unicode version function is?? Also do i need to change any settings in Visual Studio if i want to use Unicode Functions..
If possible can any one explain me the above with an example..
Thanks
Sudhakar
|
|
|
|
|
Sudhakar Pasupunuri wrote:
Also do i need to change any settings in Visual Studio if i want to use Unicode Functions..
Yes, you will need to ensure that both UNICODE and _UNICODE are defined. I would do this at the top of stdafx.h before any files are included.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
If you don't want to change your whole app to be Unicode, you can call CreateDirectoryW() directly.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
If I want to right click on a file and open the file with my program MFC how can I do that?
Please heeeeeeelp.
|
|
|
|
|
Larsson wrote:
If I want to right click on a file...
From where, Windows Explorer?
Larsson wrote:
...and open the file with my program MFC how can I do that?
Is the file's type associated with your application?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
MFC code:
<br />
CRegKey *r=new CRegKey(HKEY_CLASSES_ROOT);<br />
<br />
r->RecurseDeleteKey(".xyz");<br />
r->RecurseDeleteKey("xyzfile");<br />
<br />
r->Create(HKEY_CLASSES_ROOT,".xyz");<br />
r->SetStringValue("","xyzfile");<br />
r->Close();<br />
<br />
r->Create(HKEY_CLASSES_ROOT,"xyzfile");<br />
r->SetStringValue("","file description");<br />
r->Close();<br />
<br />
r->Create(HKEY_CLASSES_ROOT,"xyzfile\\shell\\open\\command");<br />
r->SetStringValue("","c:\\YourApplication.exe \"%1\"");<br />
r->Close();<br />
<br />
r->Create(HKEY_CLASSES_ROOT,"xyzfile\\DefaultIcon");<br />
r->SetStringValue("","c:\\YourApplication.ico");<br />
r->Close();<br />
<br />
delete r;<br />
|
|
|
|
|
that was of course association code.
You can also use .reg files during installation.
Look also at this methods:
CWinApp::EnableShellOpen
CWinApp::ParseCommandLine
CWinApp::ProcessShellCommand
|
|
|
|