|
Hey all,
I have a program that basically searches a folder for excel spreadsheets and puts them into a list control.
On clicking in the list control, it is using ShellExecute() (simply passing the name of the file, not the excel executable) to launch the Excel and have it load the file.
It opens the file without a problem, however what is happening is the method that this shellexecute code is in will not go to the next line of code until Excel loads up, and loads the file. This is causing me problems because it is not hi-lighting the list control right away. Since Excel takes it's time to load up, and load the file, this is usually 30 seconds later.
I did a simple "MessageBox("FINISHED LAUNCHING");" directly after the ShellExecute call, and sure enough, the message box does not pop up until 30 seconds or more later when the spreadsheet is fully loaded.
I am wondering if there is another way around this, to get my program to launch excel, and move on w/out caring what Excel is doing, whether it loaded or not, etc. If I don't have to, I would like to avoid having to use some other method of launching the file that would cause me to have to specify the folder and executable name of excel.
Any help would be appreciated.
Shultas
|
|
|
|
|
You might try Thread. Search for "Thread" in CP. Good luck.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
In continuataion with Mr GoodMast3r,here is the code which help you out.
<font color=#008000>
UINT ThreadProc(LPVOID lpParam);
<font color=#008000>
ShellExecute(.....);
MessageBox("FINISHED LAUNCHING");"
<font color=#008000>
//now Code this way</font>
void CWindowNameDlg::OnButton4()
{
ShellExecute(.....);
MessageBox("FINISHED LAUNCHING");"
char strFileName[]="Alok Gupta";
AfxBeginThread(ThreadProc,(LPVOID)strFileName);
}
UINT ThreadProc(LPVOID lpParam)
{
char *strFileName=(char *)lpParam;
MessageBox(NULL,strFileName,"",MB_OK);
<font color=#008000>
ShellExecute(...);
return TRUE;
}
I hope this COde work well for you
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
I have an MDI application that I'm adding a web browing component to interact with a client's HTML. We want to have their pages opening and staying within our app. I have to open an HTA file which is currently opening the client's web page in a separate IE browser. Is there a way to force the HTA to launch inside my app or do I have to modify the HTA? I have tried going through different examples on MSDN, but am not having any luck with the OnNewWindow2() override.
Thanks,
KJ
|
|
|
|
|
I need your help!!!!
I don't know how use bitmaps with alpha blending under Visual c++
or if i can use it...
Please someone can help me???, i need it... i can load mormal bitmaps but, i need load alpha blended bitmaps into the treeview and toolbars
Please!!!!!
|
|
|
|
|
Hi,
I have a weird problem where if I set a value in HKLM\MS\Windows\CurrentVersion\Run in my code, my app won't be launched. But if I double click on MyApp key, select the value, do a cut-paste of the same string, reboot the computer then it will work!
HKLM\MS\Windows\CurrentVersion\Run
Key: MyApp,
Type: String,
Value: "C:\Program Files\MyApp\MyApp.exe" (quotes are included in the string since there's a space in there).
Here's my code:
<code>TCHAR szPath[MAX_PATH+1];
TCHAR szFullPath[MAX_PATH+1];
UTLGetAppPath( szPath, sizeof( szPath ) );
_tcscat( szPath, NTS_ISMGR_EXE );
memset( szFullPath, 0, sizeof( szFullPath ) );
_tcscpy( szFullPath, "\"" );
_tcscat( szFullPath, szPath );
_tcscat( szFullPath, "\"\0" );
lRes = RegSetValueEx( hKey, NTS_REG_STARTUP_NAME, 0, REG_SZ,
(BYTE*)szFullPath, sizeof( szFullPath ) );</code>
What is wrong???
Thanks!
|
|
|
|
|
You do realize that the Run key is only processed at login, right? Programs don't get run right away when added to the key. (Sorry, silly question, but I had to ask to be sure you understand how the key works.)
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
I know! This is how I've tested:
I use InnoSetup for my app and it creates the MyApp key when installing my app. I reboot, everything is fine, app is launched at startup.
Then, I let my code handle the key. First, it deletes the key with RegDeleteValue and then creates (or should I say sets it) it with RegSetValueEx (as shown above).
I then restart Windows and although the key is there (and apparently with the same value), the app won't be launched!
I thought the problem was that I didn't add a null character at the end of the string but it still doesn't work!
|
|
|
|
|
One thing I did notice is that when I set the key through the code, there's '...' at the end of the string! If I set the value manually, the '...' disapears!
|
|
|
|
|
I think I found the solution:
lRes = RegSetValueEx( hKey, NTS_REG_STARTUP_NAME, 0, REG_SZ,
(LPBYTE)szFullPath, _tcslen( szFullPath ) );
Replaced sizeof() with _tcslen()...
|
|
|
|
|
That's almost right, you need to pass the length of the string in bytes, including the final null. So it's:
sizeof(TCHAR) * (1+_tcslen(szFullPath))
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Are you a UNICODE program?
I ask this because you are doing a lot of TCHAR and _tcscpy.
If you are, then be careful when passing sizeof() into functions.
Check the API, see if it wants the buffer size in bytes or characters. If characters, then you should use (sizeof(buf)/sizeof(TCHAR))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
No it's not using UNICODE. It's in bytes, not characters, but I think I found the solution by replacing sizeof() with _tcslen(). Is this safe?
|
|
|
|
|
I'm having trouble sending some data from my SQL database over a socket connection. When I send it, I only receive 4 bytes. I tried memcpying it to a BYTE array but that also only sent 4 bytes. Here is my code:
<br />
CString mySelect;<br />
mySelect.Format("SELECT EMG1_E911_MSG FROM EMG1 WHERE EMG1_DEST_ID = '%s'", thdID);<br />
pCommand.CreateInstance(__uuidof(Command));<br />
pCommand->ActiveConnection = m_pConnection;<br />
pCommand->CommandText = _bstr_t(mySelect);<br />
pRecordset.CreateInstance(__uuidof(Recordset));<br />
pRecordset->CursorLocation = adUseClient;<br />
pRecordset->Open((IDispatch*) pCommand, <br />
vtMissing,<br />
adOpenStatic,<br />
adLockBatchOptimistic,<br />
adCmdUnknown);<br />
_variant_t E911_Msg;<br />
while (!pRecordset->adoEOF)<br />
{<br />
E911_Msg = pRecordset->GetCollect("EMG1_E911_MSG");<br />
if (E911_Msg.vt != VT_NULL)<br />
{<br />
m_sConnectSocket.Send((char*)_bstr_t(E911_Msg), sizeof(1500));<br />
}<br />
pRecordset->MoveNext();<br />
}<br />
I'm not sure it I'm setting something up wrong here. Could someone provide some suggestions.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
sizeof(1500)?
that evaluates to 4
is that what you intended?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
welll.....duh. just testing you. Good job you passed!
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
According the MSDN documentation there are some new advanced gdiplus functions in GDI+ 1.1. Functions like red eye correction:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusreference/classes/redeyecorrection.asp[^]
According the preliminary MSDN documentation the defintions are declared in gdipluseffects.h. However the documentation states: Note: This documentation is preliminary and is subject to change. I tried CodeProject, MSDN, Google and newsgroups. But the only hits I found were others searching for this header.
Has anyone seen these new headers (are they available in Studio 2005 beta?). And are these new functions implemented in the freely distributable gdiplus.dll? Or are these functions only implemented in the version of gdiplus.dll that ships with Office 2003?
Any help appreciated.
Regards Anne Jan
|
|
|
|
|
How would I detec if left mouse button is down in OnMouseMove while other key is down also?
nFlags == MK_LEFT works except if I press right button down also it wouldn't work anymore
I need to create a flag in OnLButtonDown?
|
|
|
|
|
Anonymous wrote:
I need to create a flag in OnLButtonDown?
yes. that's how i always handle it. set a flag when the button is pressed, and flip it when the button is released.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
|
well here is an another suggestion.....(but a longer one)
create a bool variable say "m_clickon"(and initialize it with the value=FALSE) and make it true when ever ur leftbotton os down by using the OnLButtonDown....
make sure u handle thiz variable when the OnlButtonup as well (to set it back to FALSE).....
so whenever u move ur mouse..
the movemove handle is called.....then just check the status of this variable to say wheter the leftbutton is clicked or not...
happy programmin.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Hi, i wish to use the CxImage libary in my project i am working on. Sadly due to me being a complete muppet and not knowing hardly any visual c++ or knowing how the compiler works properly, i can seem to get the libary to work.
Anyone know a decsent tut on how to use libaries as this would help me a lot.
Thanks a lot
|
|
|
|
|
Hi,
how do I find out how much free store (memory when you call new/delete) is available to my program? If that's not possible how can I tell how much RAM is installed on the machine?
Thanks.
|
|
|
|
|
One way would be to walk the application's heap using the Heap32First() /Heap32Next() pair. You could also use PdhOpenQuery() , PdhMakeCounterPath() and related functions to look at the Memory object. There's also the Win32_PhysicalMemory class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Wow. I thought there was some simple win32 function that I can just call to get the physical memory size.
The first set of functions looks like it returns the current free-store usage? I wanted to get the limit of the free store. The second set of functions I don't even understand. Finally Win32_PhysicalMemory looks insane. You need to use COM to query some Windows Management Instrumentation (which I don't think I have because none of the MSDN sample code works - missing headers).
I did some more searching and found GlobalMemoryStatus(). This one looked very easy to use and it works on my Win2k machine so far. As long as the computer doesn't have 4G+ of memory I should be covered for now. GlobalMemoryStatusEx() would be ideal but my compiler can't find it.
Thanks for your help.
|
|
|
|