|
One might wonder why you're using WTL AND MFC...but anyway.
You need to put the MFC includes in before the ATL includes - MFC doesn't like Windows.h being included before it is (and ATL does that).
You may also need to add the line
#define _CSTRING_NS
so that WTL can see CString properly.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Sorry - is your app mainly MFC or mainly WTL?
It doesn't really matter, anyway - the code for reading Excel posted in that article is independent of WTL or MFC. WTL is only used to display the results of reading the Excel file - you could re-implement that in MFC very simply.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
its mainly MFC.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
As I said, the Excel reading code is independent of WTL or MFC. The important line is this one:
#import ".\EXCEL.EXE" \
rename( "DialogBox", "ExcelDialogBox" ) \
rename( "RGB", "ExcelRGB" ) \
rename( "CopyFile", "ExcelCopyFile" ) \
rename( "ReplaceText", "ExcelReplaceText" )
That imports the Excel type library into your C++ program, using smart pointers and managed variants and BSTRs.
Look for the string Excel:: in MainDlg.cpp from that article - that shows you the bits of code that are interfacing with Excel.
For example:
Start Excel
Excel::_ApplicationPtr pApplication;
if ( FAILED( pApplication.CreateInstance( _T("Excel.Application") ) ) )
{
Errorf( _T("Failed to initialize Excel::_Application!") );
return;
}
Load an Excel workbook
_variant_t varOption( (long) DISP_E_PARAMNOTFOUND, VT_ERROR );
Excel::_WorkbookPtr pBook = pApplication->Workbooks->Open( dlgFile.m_szFileName, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption );
Get the first worksheet
Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[ 1 ];
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
My 5 for your tolerance.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
In MFC the above can be done by using CListCtrl class.
but how to do the same in win32 ?
Please help.
|
|
|
|
|
There is no easy way. There is no "check" style for a listbox - there's an MFC class which does clever things for you.
Have a look at the code for CCheckListBox, and you'll see it actually does owner draw for the listbox. I can't remember how it stores the check state - either as item data, or an internal map.
So, you'll have to learn how to do owner draw in Win32 (just a case of setting the right styles and responding to a couple of messages) and implement the functionality yourself.
If I were you, I'd grab large sections of the work from CCheckListBox - but you'll still have quite a bit of effort to do.
Good luck!
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Thanks for the reply Iain.
I think we can use ListControl in place of listbox.
When I am using ListControl on the dialog, the dialog is not becoming visible.
Does anyone have some idea about it ? Can I use ListControl in a win32 application to show the checkbox.
Thanks in advance
|
|
|
|
|
A List View Control[^] with the LVS_REPORT style set and LVS_EX_CHECKBOXES extended style might be what you're after. Also remember, as with all common controls, you must call InitCommonControlsEx[^].
Steve
|
|
|
|
|
nbugalia wrote: When I am using ListControl on the dialog, the dialog is not becoming visible.
Can you elaborate, please?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i want to read html file usin c++ or vc++ help me please
thanks in advance
|
|
|
|
|
See here[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
The answer to your actual question is:
You do it the same way you'd read any other file: CreateFile, ReadFile, CFile, CFile::Read, etc.
If you mean a file on a webserver somewhere, that's different.
Lookup InternetReadFile, InternetOpenUrl, etc. Read the documentation for those very carefully.
But that will just give you a big bunch of html.
If you want your program to understand the html, that's different again. But "parser" is the right search term to use. There are articles on codeproject that do various amounts of it, it will just depend on how sophisticated you need to be.
If you want to display html to a user, it's easier - look at CHtmlView in MFC.
Good luck,
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
I have a application where data will get stored in SQL 2000 database. Now i have to retrive data from database & store it in the excel file.
I am using VC++ 6.0 version with MFC, SDI & database connectivity through ODBC.
Could any one guide me to achieve this? Kindly let me know if you would need more details to reply to my question.
Thanks in advance.
Regards,
Dipti
|
|
|
|
|
This link might help you.
http://www.codeproject.com/KB/database/simple_odbc.aspx
Being an Indian makes me feel proud.
|
|
|
|
|
Thanks for your reply. I am new to VC++. This example is without MFC. Could you send me details on how to retrive data from SQL & store it in Excel.
Could you guide me on how to go about this?
Regards,
Dipti
|
|
|
|
|
diptipanchal wrote: Could you guide me on how to go about this?
Break the problem down into more manageable parts. Can you extract data from the database (e.g., using CRecordset )? Can you use Excel Automation?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
No, I have neither read data from database nor used excel automation before.
Could you send me some link or literature on the above?
|
|
|
|
|
diptipanchal wrote: Could you send me some link or literature on the above?
I have 2 semi-related articles.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
How do we create a language pack?
Is there any tutorial available ?
Please provide the link.
Thanks
|
|
|
|
|
If you mean for windows? I strongly doubt you can.
If you mean you want to have multiple resources in different languages in your software, well, just go and add them! Just right click to get properties and set the language of your choice.
There are articles on CP about internationalization / internationalisation you can read for more information.
Good luck,
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Maybe it's "Resource Only Dlls" you are looking for.
...Plug & Pray...
|
|
|
|
|
I have created Resource only DLLs already but my system is not supporting all languages.
This will happen with the client also. So how can I support languages without installing language pack either through WIN XP CD or through microsoft site.
Where can I get free language pack which I can attach with my software.
Plz reply soon.
Thanks
|
|
|
|
|
Hi ,
I have a problem of memory leak when we call a function from win 32 DLL in our MFC program.
DLL is C type and return value of my DLL is Char* and it is locally defined in function of DLL. and size is 1024 byte.
when functon call four times then MFC application hold 4 KB Extra memory.
|
|
|
|