|
Hi,
I wanna access data of excel sheet through my mfc application.Can anybody please let me know if it is possible to do so and if yes then please let me know the procedure.
Regards,
Pritam
|
|
|
|
|
Google.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
There are at least 4 ways to do this. The easy way, the less easy way, the COM way and the really hard way.
The easy way is to save your spreadsheet as a .csv (Comma Separated Value) file and then open it and read in the data. Parsing the comma separated fields is then pretty trivial.
The less easy way is to use ODBC/OLE DB to read the original Excel file as a database. Microsoft publishes a driver/provider for this so you can execute SQL queries against the spreadsheet. Unfortunately the last time I used it it was rubbish and had more gotchas than the Sun newspaper archive.
The COM way is to instance Excel itself as a COM server and use the interfaces it exposes to access the data. If you're into COM this is not actually very difficult because it's all IDispatch based, designed to be used from VB.
The really hard way would be to attempt to read Excel native files directly. This, while technically possible, could prove to be really difficult and is almost certainly not worth the effort.
There's your options, enjoy
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi Friends,
I have difficulties in getting handle of EditBox when I get the value of edit box.
Following code is execute correctly when i set value to edit box
CEdit *pOpenEdit = (CEdit *) GetDlgItem(IDC_FOLDER_PATH);
if( NULL != pOpenEdit->GetSafeHwnd() )
{
if( strOpenPath != "" )
pOpenEdit->SetWindowText(strOpenPath);
}
But when I want to get value of edit box , i did not get the
handle of edit box. so it did not entered in if Block.
CEdit *pOpenEdit = (CEdit *)GetDlgItem(IDC_FOLDER_PATH);
if( NULL != pOpenEdit->GetSafeHwnd() )
{
char buff[500];
pOpenEdit->GetWindowText(buff,256);
strOpenLocation = buff;
}
So please let me know what is wrong in this code.
Thanks in Advance
Atul
|
|
|
|
|
Your error is not in the block of code you are showing me.
I would assume that at the time that you are "getting" the value -- your dialog has been closed...
When are you calling this "get"?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
|
hi all,
i created a new tool bar in my application with 5 buttons. when i click second button the 5th button should be disable .can u please tell me how to disable in coding.
for a normal dialog item we use this code
GetDlgItem(IDC_BUTTON)->EnableWindow(FALSE);
but how to do this for tool bar button.
thanks
panthal
|
|
|
|
|
Have a look at TB_ENABLEBUTTON in MSDN.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
hi please tell
How i can change custom level of security (for example ActiveX control and plugins) of trusted sites , programmatically?
Is it possible by using IInternetSecurityManager interface?
Thanks.
-- modified at 0:43 Monday 19th November, 2007
-- modified at 5:02 Monday 19th November, 2007
destined to win
|
|
|
|
|
I took the code form http://www.gdcl.co.uk/downloads.htm for mpeg1 parser filter and registered the sample parser with the help of regsvr32. then i wrote the following program to create an exe file to play the sample parser.
here CLSID_SampleWaveParser is the guid that is used for samplewave parser in the mpeg1 file.
When i execute the following code it executes successifully untill the end of the file which ever i have selected but after completion of the file it give the following error.
4 objects left active. in 316 line of dllentry.cpp.
can u tell me how can i remove this error.
or is there any other method to create an executable file for the dll which is created by the mpeg1 wave parser.
#include <InitGuid.h>
#include <DShow.h>
//0xD84E3EC9, 0x3233, 0x4177, 0xA3, 0xAF, 0x13, 0xB6, 0xF9,0x33, 0x49, 0x8D);
// our own definition of Wave Parser based on CLSID we found in registry
#define INITGUID // have to define this so next line actually creates GUID structure
DEFINE_GUID(CLSID_SampleWaveParser,0xD84E3EC9, 0x3233, 0x4177, 0xA3, 0xAF, 0x13, 0xB6, 0xF9,0x33, 0x49, 0x8D);
void main(void)
{
HRESULT hr;
IGraphBuilder* g_pGraphBuilder = NULL; // assume graph builder already created
IBaseFilter* g_pSource = NULL;
IBaseFilter* g_pWaveParser = NULL;
IBaseFilter* g_pSoundRender = NULL;
IFileSourceFilter *pFileSourceInt = NULL;
IMediaControl *gControl = NULL;
IMediaEvent *gEvent = NULL;
IEnumPins* EnumPins = NULL;
IPin* OutPin = NULL;
IPin* InPin = NULL;
ULONG fetched;
PIN_INFO pinfo;
long evCode=10;
CoInitialize(NULL);
CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void **)&g_pGraphBuilder);
CoCreateInstance(CLSID_SampleWaveParser, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pWaveParser);
CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pSource);
CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pSoundRender);
g_pGraphBuilder->AddFilter(g_pSource,NULL);
g_pGraphBuilder->AddFilter(g_pWaveParser, NULL);
g_pGraphBuilder->AddFilter(g_pSoundRender,NULL);
hr = g_pSource->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSourceInt);
hr = pFileSourceInt->Load(L"D:\\test.rpm",NULL);
if( hr == E_FAIL)
printf("\n Failed to open the file\n");
// find source output
g_pSource->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &OutPin, &fetched); // only 1 pin for source, so we know this is the one we need
EnumPins->Release();
// find wave parser input
g_pWaveParser->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &InPin, &fetched);
InPin->QueryPinInfo(&pinfo);
pinfo.pFilter->Release(); // make sure you release the returned IBaseFilter interface
if (pinfo.dir == PINDIR_OUTPUT) // check if we have wrong pin (not input pin)
{
InPin->Release();
EnumPins->Next(1, &InPin, &fetched); // if so, get next pin
}
// connect
g_pGraphBuilder->Connect(OutPin, InPin);
InPin->Release();
// OutPin->Release();
// find wave parser audio output pin
EnumPins->Next(1, &OutPin, &fetched);
EnumPins->Next(1, &OutPin, &fetched);
OutPin->QueryPinInfo(&pinfo);
if (pinfo.dir == PINDIR_INPUT)
{
OutPin->Release();
EnumPins->Next(1, &OutPin, &fetched);
OutPin->QueryPinInfo(&pinfo);
}
EnumPins->Release();
OutPin->Release();
// find renderer input
g_pSoundRender->EnumPins(&EnumPins);
EnumPins->Reset();
EnumPins->Next(1, &InPin, &fetched); // renderer has only 1 pin, so this is the pin we need
EnumPins->Release();
// connect
g_pGraphBuilder->Connect(OutPin, InPin);
InPin->Release();
OutPin->Release();
hr = g_pGraphBuilder->QueryInterface(IID_IMediaControl, (void **)&gControl);
hr = g_pGraphBuilder->QueryInterface(IID_IMediaEvent, (void **)&gEvent);
hr = gControl->Run();
gEvent->WaitForCompletion(INFINITE,&evCode);
hr = gControl->Stop();
gControl->Release();
gEvent->Release();
g_pWaveParser->Release();
g_pSoundRender->Release();
g_pSource->Release();
g_pGraphBuilder->Release();
CoUninitialize();
}
amiya kumar das
|
|
|
|
|
here CSharpHelloWorld.netmodule is in the bin folder of the managed c++ project
#include <mscorlib.dll>
#include "CSharpHelloWorld.netmodule"
#include namespace System;
public __gc class HelloWorldC
{
public:
CSharpHelloWorld __gc *t; // Provide .NET interop and garbage collecting to the pointer.
HelloWorldC() {
t = new CSharpHelloWorld(); // Assign the reference a new instance of the object
}
// This inline function is called from the C++ Code
void callCSharpHelloWorld() {
t->displayHelloWorld();
}
};
thanks in advance
|
|
|
|
|
Mmmm, what about if you ask in the correct forum? Maybe you get a better answer.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Which should I use to delete the instance of class CLadder? OPTION1 or OPTION2? Or something else? CLadder is a dialog class.
//OPTION 1
CLadder* pLD;
pLD = new CLadder:
...
...
...
delete pLD;
//OPTION 2
CLadder* pLD;
pLD = new CLadder:
...
...
...
pLD->DestroyWindow();
|
|
|
|
|
DestroyWindow before delete it.
|
|
|
|
|
It's my understanding that DestroyWindow really just destroy's the HWND (releases the window handle).
The window object should still be intact.
It's very handy to step into that code with the debugger.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
DestroyWindow is the counterpart to Create and is about the windows-window, the thing you see on screen.
delete is the counterpart of new and is about C++ classes and memory management.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hi all,
I want to create a data connection in my MFC application, as follows
ADODB::_ConnectionPtr pConn;
Import the dll,
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \<br />
no_namespace \<br />
rename( "EOF", "adoEOF" )
in the stdafx.h header file. But it gives the compile error,
'ADODB' : is not a class or namespace name
Can you tell me why is that. I do the same thing on my early projects and work fine. I can't find where I'm going wrong.
I appreciate your help all the time...
Eranga
|
|
|
|
|
|
Thanks,
actually I do it in much more this way.
HRESULT hr;<br />
ADODB::_ConnectionPtr connection;<br />
hr = connection.CreateInstance(__uuidof(ADODB::Connection));
But still got the same error.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hi all,
I want to pass parameter from one exe to another using ShellExecute (parameter is a CString variable). Can anybody please tell me how to pass the parameter through ShellExecute and how to recieve this parameter in second exe file(i.e the file we are opening through ShellExecute)
Thanks in advance
|
|
|
|
|
You can pass the null terminated string using lpParameters parameter of ShellExecute function. The destination EXE should process the command line arguments using GetCommandLine and CommandLineToArgvW functions. Please check MSDN for more information.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
CString is an MFC class. What is the executable that you're trying to run built with? Will it be able to understand a CString?
Last modified: 11mins after originally posted --
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
Both the applications are mfc dialog based application
in first application i have passed parameter through ShellExecute like this:
CString index_File = "C:\\Documents and Settings\\Mayank\\My Documents\\ppnam\\Debug\\ppnam.exe";
CString pass_val = "neha";
ShellExecute(NULL,"open",index_File,pass_val,NULL,SW_SHOW);
<\pre>
and in second application i have done this
<pre>
LPSTR wtr = GetCommandLine();
AfxMessageBox(wtr);
it gives output as
"C:\\Documents and Settings\\Mayank\\My Documents\\ppnam\\Debug\\ppnam.exe"neha
but i want only passed value....How to get it???
|
|
|
|
|
Instead of GetCommandLine() , try the following:
AfxMessageBox(m_lpCmdLine);
|
|
|
|
|
Its giving this error:
error C2065: 'm_lpCmdLine' : undeclared identifier
|
|
|
|
|