|
Hello, the codegurs around the world.;)
I think that you use Crystal Report ActiveX control in VC++ project.
And after you insert Crystal Report ActiveX conrol by type library,
you can use its function to show the crystal report file.
I hope that you know how to insert Crystal Report ActiveX control to your project.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
go to the developer web site
http://www.crystaldecisions.com/products/dev_zone/
They have various VC++ samples that show you how to do this
|
|
|
|
|
I would like to be able to determine if a file or directory exists and then delete it.
File: I use CFileFind to determine if the file exists, but what function can I use to delete it?
Directory: Could use CFileFind but is there a function where I just give it the name and it tells me it exist's or it doesn't. I currently use ::SetCurrentDirectory and see if it succeeds or fails but I don't like this approach. _rmdir deletes the directory is there another function I should use instead?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
if i'm searching / deleting / copying files i usually use the API - functions, cause they work best for me...
::DeleteFile ... deletes a file
::RemoveDirectory ... removes a directory
::FindFirstFile & ::FindNextFile ...to watchup if there's such an directory / File
hope this can help
Bernhard
|
|
|
|
|
You can use SHFileOperation to delete multiple files
This is useful when a directory is not empty
Once you've emptied the directory you can again use SHFileOperation or
RemoveDirectory to delete that directory
Regards
Nish [BusterBoy]
|
|
|
|
|
Hello,
I am working on an appplication in which i need to open MS-EXCEL application on press of a button.
I am doing it as in the code below. I am using the MS-EXCEL type library classes for this purpose.
My problem is, though EXCEL is opened the menu items are not visible.
_Application app;
_Workbook book;
Workbooks boos;
COleVariant
covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
if(!AfxOleInit()){
AfxMessageBox("Could not intialize com dll");
return FALSE;
}
AfxEnableControlContainer();
if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Failed to create Excel.Application");
return FALSE;
}
app.SetVisible(TRUE);
books = app.GetWorkbooks();
And Then How can i use Excel menu items ?
May you help me?
Cheers
|
|
|
|
|
I have this in one of my applications...I get a Menu...take what you need out of it!
<br />
try<br />
{<br />
_Application app;
_Workbook book;<br />
_Worksheet sheet;<br />
_Chart chart;<br />
<br />
Workbooks books;<br />
Worksheets sheets;<br />
Range range;<br />
ChartObjects chartobjects;<br />
Charts charts;<br />
LPDISPATCH lpDisp;<br />
<br />
COleVariant<br />
covTrue((short)TRUE),<br />
covFalse((short)FALSE),<br />
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);<br />
<br />
if(!app.CreateDispatch("Excel.Application"))<br />
{<br />
AfxMessageBox("Couldn't CreateDispatch on Excel");<br />
return;<br />
}<br />
<br />
lpDisp = app.GetWorkbooks();
ASSERT(lpDisp);
books.AttachDispatch( lpDisp );
<br />
app.SetVisible(TRUE);<br />
<br />
lpDisp = books.Open(csFilename,<br />
covOptional, covOptional, covOptional, covOptional,<br />
covOptional, covOptional, covOptional, covOptional,<br />
covOptional, covOptional, covOptional, covOptional<br />
);<br />
ASSERT(lpDisp);
<br />
book.AttachDispatch( lpDisp );
<br />
lpDisp = book.GetSheets();<br />
ASSERT(lpDisp);<br />
sheets.AttachDispatch(lpDisp);<br />
<br />
lpDisp = sheets.GetItem( COleVariant((short)(1)) );<br />
ASSERT(lpDisp);<br />
sheet.AttachDispatch(lpDisp);<br />
<br />
sheet.Activate();<br />
<br />
lpDisp = sheet.GetRange(COleVariant("A3"), COleVariant("G10000"));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);
range.Clear();
<br />
CString csCellData = _T("");<br />
CString csCell = _T("");<br />
<br />
for(int n=0; n<lc.GetItemCount(); n++)<br />
{<br />
<br />
csCellData = lc.GetItemText(n,0);<br />
csCell.Format("C%i", n+3);<br />
lpDisp = sheet.GetRange(COleVariant(csCell), COleVariant(csCell));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);<br />
range.SetValue(COleVariant(csCellData));<br />
<br />
csCellData = lc.GetItemText(n,1);<br />
csCell.Format("A%i", n+3);<br />
lpDisp = sheet.GetRange(COleVariant(csCell), COleVariant(csCell));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);<br />
range.SetValue(COleVariant(csCellData));<br />
<br />
csCellData = lc.GetItemText(n,2);<br />
csCell.Format("B%i", n+3);<br />
lpDisp = sheet.GetRange(COleVariant(csCell), COleVariant(csCell));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);<br />
range.SetValue(COleVariant(csCellData));<br />
<br />
csCellData = lc.GetItemText(n,3);<br />
csCell.Format("D%i", n+3);<br />
lpDisp = sheet.GetRange(COleVariant(csCell), COleVariant(csCell));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);<br />
range.SetValue(COleVariant(csCellData));<br />
<br />
csCellData = lc.GetItemText(n,4);<br />
csCell.Format("E%i", n+3);<br />
lpDisp = sheet.GetRange(COleVariant(csCell), COleVariant(csCell));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);<br />
range.SetValue(COleVariant(csCellData));<br />
<br />
csCellData = lc.GetItemText(n,5);<br />
csCell.Format("F%i", n+3);<br />
lpDisp = sheet.GetRange(COleVariant(csCell), COleVariant(csCell));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);<br />
range.SetValue(COleVariant(csCellData));<br />
<br />
csCellData = lc.GetItemText(n,6);<br />
csCell.Format("G%i", n+3);<br />
lpDisp = sheet.GetRange(COleVariant(csCell), COleVariant(csCell));<br />
ASSERT(lpDisp);<br />
range.AttachDispatch(lpDisp);<br />
range.SetValue(COleVariant(csCellData));<br />
<br />
}
<br />
sheet.ReleaseDispatch();<br />
<br />
app.SetUserControl(TRUE);<br />
<br />
book.Save();<br />
<br />
}
catch(COleException *e)<br />
{<br />
char buf[1024];<br />
sprintf(buf, "COleException. SCODE: %08lx.", (long)e->m_sc);<br />
::MessageBox(NULL, buf, "COleException", MB_SETFOREGROUND | MB_OK);<br />
}<br />
catch(COleDispatchException *e)<br />
{<br />
char buf[1024];<br />
sprintf(buf, <br />
"COleDispatchException. SCODE: %08lx,Description: \"%s\".",<br />
(long)e->m_wCode, (LPSTR)e->m_strDescription.GetBuffer(1024));<br />
::MessageBox(NULL, buf, "COleDispatchException", MB_SETFOREGROUND | MB_OK);<br />
}<br />
catch(...)<br />
{<br />
::MessageBox(NULL, "General Exception caught.", "Catch-All", MB_SETFOREGROUND | MB_OK);<br />
}<br />
Thanks in advance,
Dan
|
|
|
|
|
I'm working on a namespace extension that represents documents in a repository. It allows the user to copy or cut the documents and paste them to the file system. I'm basically doing the cut/copy by creating an IDataObject instance on the clipboard which returns a reference to the files in CF_HDROP format.
BUT...in the case of a cut and paste, I need to get feedback that the paste was successful so I know whether or not to delete the document object from the repository. I get a "Paste Successful" via IDataObject::SetData(), but if the file already exists where I'm pasting it, I get a "File already exists - overwrite?" dialog box *AFTER* the "Paste Successful" has already been returned!
Is there a way to verify that the paste has actually occured?
Also, is there a way I can add a handler of some sort to the shell that will allow me to paste documents to the file system that are in a custom clipboard format?
Any help would be greatly appreciated.
Thanks,
Tim
Reverend Shoebox
|
|
|
|
|
Hi,
I'm a newbie to STL and have been on this stuff for all day long,
but failed to implement. Plz help!
---My Situation goes---
Say, there is a string like "SP_CALL(~1,~123,~09,455,21)".
I want to extract numbers after '~' character and store it to some container.
Some like MAP, LIST, ...anything that could be used to restore extracted numbers
for later comparison with other numbers.
I've tried with very basic knowledge of STL, but maybe I'm lack much knowledge.
So..If anyone can show some sample code fragments that implements this,
or can point me to similar code, plz help me.
Also, if there are any good books about STL for beginners, let me know.
Thanks a million.
Regards,
Ryan
|
|
|
|
|
if you want to stick with STL, take a look at std::string and its member functions (especially substr, find* and c_str). the std::find* functions can help you isolate chunks of characters between commas and std::string::substr will let you extract those chunks. then use something like atoi to convert those chunks to numbers.
this is one of those things where you have to make a loop that searches, extracts and converts.
here's a small sample that might help:
#include <string>
std::string str = "SP_CALL(~1,~123,~09,455,21)";
int iLeftParen = str.find_first_of('(');
int iCommaPos = str.find(',', iLeftParen);
std::string firstChunk = str.substr(iLeftParen, iCommaPos - (iLeftParen + 1));
-c
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
why don't you use strtok to get the delimitted numbers ?
probably easier !!
|
|
|
|
|
he asked how to do it with STL, not with strtok.
-c
|
|
|
|
|
Hi,
Thanks for your code.
Regards,
Ryan
|
|
|
|
|
The problem you are posing is very interesting: how to tokenize a string with the set of delimiter characters given in another string. I am giving a solution below. I implemented a more general function template to solve this kind of problems:
<class Pred> void Tokenize(/*...*/)
where you implement your delimiting criteria in a predicate class. When the set of delimiter characters are given in another string use the predicate CIsFromString(). After you get your strings in a vector container you can check your other ctiteria, like being a number after '~' the first character. I also give the function IsNumber() to check if a string is a number. Maybe all this solution deserves a separate article, I will think about it. The code (functions and a full testing program) is given bellow. It should compile without any problems with VC++. Good luck!
#pragma warning(disable:4786)
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <locale>
using namespace std;
//For the case the default is a space.
//This is the default predicate for the Tokenize() function.
class CIsSpace : public unary_function<char, bool>
{
public:
bool operator()(char c) const
{
//isspace<char> returns true if c is a white-space character (0x09-0x0D or 0x20)
return isspace<char>(c);
}
};
//For the case the separator is a comma
class CIsComma : public unary_function<char, bool>
{
public:
bool operator()(char c) const
{
return (',' == c);
}
};
//For the case the separator is a character from a set of characters given in a string
class CIsFromString : public unary_function<char, bool>
{
public:
//Constructor specifying the separators
CIsFromString(string const& rostr) : m_ostr(rostr) {}
bool operator()(char c) const
{
int iFind = m_ostr.find(c);
if(iFind != string::npos)
return true;
else
return false;
}
private:
string m_ostr;
};
//Takes a string and a predicate, and tokenizes the string according to the separators which are
//defined by the provided predicate. The predicate should evaluate to true when applied to a separator.
template <class Pred>
void Tokenize(string const& rostr, Pred const& roPred, vector<string>& roResult)
{
//First clear the results vector
roResult.clear();
string::const_iterator it = rostr.begin();
string::const_iterator itTokenEnd = rostr.begin();
while(it != rostr.end())
{
//Eat seperators
while(roPred(*it))
it++;
//Find next token
itTokenEnd = find_if(it, rostr.end(), roPred);
//Append token to result
if(it < itTokenEnd)
roResult.push_back(string(it, itTokenEnd));
it = itTokenEnd;
}
}
//Default Implementation - same as above, but uses CIsSpace as predicate
void Tokenize(string const& rostr, vector<string>& roResult)
{
//First clear the results vector
roResult.clear();
string::const_iterator it = rostr.begin();
string::const_iterator itTokenEnd = rostr.begin();
CIsSpace oIsSpace;
while(it != rostr.end())
{
//Eat seperators
while(oIsSpace(*it))
it++;
//Find next token
itTokenEnd = find_if(it, rostr.end(), oIsSpace);
//Append token to result
if(it < itTokenEnd)
roResult.push_back(string(it, itTokenEnd));
it = itTokenEnd;
}
}
//Simple and fast function to detect if a string is a number
bool IsNumber(string const & roStr)
{
char cFirst = roStr.at(0);
if('-' == cFirst || '+' == cFirst)
//find_first_not_of() if succeeds returns the position, otherwise returns npos.
return (string::npos == roStr.find_first_not_of("0123456789", 1));
else
return (string::npos == roStr.find_first_not_of("0123456789"));
}
//Testing the class
int main()
{
//Test CIsSpace() predicate
{
cout << "Test CIsSpace() predicate:" << endl;
//The Results Vector
vector<string> oResult;
//Call Tokeniker
Tokenize(" wqd \t hgwh \t sdhw \r\n kwqo \r\n dk ", oResult);
//Display Results
for(int i=0; i<oResult.size(); i++)
cout << oResult[i] << endl;
}
//Test CIsComma() predicate
{
cout << "Test CIsComma() predicate:" << endl;
//The Results Vector
vector<string> oResult;
//Call Tokeniker
Tokenize<CIsComma>("wqd,hgwh,sdhw,kwqo,dk", CIsComma(), oResult);
//Display Results
for(int i=0; i<oResult.size(); i++)
cout << oResult[i] << endl;
}
//Test CIsFromString predicate
{
//Problem: Keep in the container only the strings that contain integer numbers
//after '~' as the first character
cout << "Test CIsFromString() predicate:" << endl;
//The Results Vector
vector<string> oResult;
//Call Tokeniker
Tokenize<CIsFromString>("SP_CALL(~1,~123,~09,455,21)", CIsFromString(",()"), oResult);
//Keep only the string which contain numbers after the first character '~'
bool bKeep;
vector<string>::iterator it = oResult.begin();
while(it != oResult.end())
{
bKeep = true;
if('~' == (*it)[0])
{
string ostr = (*it).substr(1);
if(IsNumber(ostr))
//Keep but replace
*it = ostr;
else
bKeep = false;
}
else
bKeep = false;
if(false == bKeep)
it = oResult.erase(it);
else
it++;
}
//Display strings
cout << "Display strings:" << endl;
int i;
for(i=0; i<oResult.size(); i++)
cout << oResult[i] << endl;
//Now if you want an container with numbers is very easy
vector<int> oInts;
for(i=0; i<oResult.size(); i++)
oInts.push_back(atoi(oResult[i].c_str()));
cout << "Display integers:" << endl;
//Display integers
for(i=0; i<oInts.size(); i++)
cout << oInts[i] << endl;
}
return 0;
}
|
|
|
|
|
Hi,
I didn't test or look into your code, but I thought that I should thank you
first. Thank you very much for kind instruction.
I expected a simple fragment of sample code or pointing to similar code,
but you surprised me.
Thanks again for your time on this code and I guess this would be very helpful
to those have problems with string manipulation with STL.
Regards,
Ryan
|
|
|
|
|
Hi!
I'm using the new function, SetLayeredWindowAttributes in my program...
I want to make the background, transparent...
Well, the problem is...
The compilation, Linking, everything is well done with no errors,
no warnings, but NO EFFECT appears...
there are no problems for building the execution file, but
no effect appears...
I don't know what the problem is...
Demo projects work fine after compiling on my machine, but my project doesn't !
Could anyone help me?
Thanks a lot... ^^
Always be happy!
|
|
|
|
|
Well, it looks like you've got a comma in the wrong place.
Post your code.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Which windows are You using?
Some graphic cards do not respond similary to the settings. I think that Matrox cards have problems with that. For example settings value 1 - 200 can cause no effect, but effect will appear in range 201 - 255. <-- but I'm not really sure about this.
|
|
|
|
|
Hmmm
I guess I found the problem but still not the answer...
I got an idea for the handle.
Maybe I set the wrong window handle to the 'SetWindowLong'.
So, I used the 'GetLastError' and got the problem...
There was a problem with the handle.
The 'SetWindowLong' function couldn't get the correct handle of the window,
and it replied the error code #, 1400.
Error code 1400 means 'Wrong window handle(???)'.
Well, How should I set/get the right handle.
I know that the SetLayeredWindowAttributes function can only be used for
parent windows, and not able for the child windows.
I still don't have it done to use the Attach(), but would it work?
Should I use this function to give the right handle to the 'SetWindowLong'?
Thanks a lot for your help all of you!!!
Always be happy!
|
|
|
|
|
I have a struct that looks like this:
struct ViewportPos
{
RECT rcPos;
long Index;
};
I have a list of these in my class, and I am trying to sort them so that they sort first by the left element in the RECT, then by the top. I've got to the point of trying to specify my own function for sorting ( i.e. at this point I've not done the trivial bit of comparing two RECTs ).
inline bool RectSort(ViewportPos vpi1, ViewportPos vpi2)
{
RECT rc1 = vpi1.rcPos;
RECT rc2 = vpi2.rcPos;
return FALSE;
}
then in my function below this:
std::stable_sort(m_Viewports.begin(), m_Viewports.end(), RectSort);
I get a bajillion template errors relating to basic_string, like this:
C:\My Code\VBScene\VBWindow.cpp(860) : warning C4101: 'rc1' : unreferenced local variable
C:\My Code\VBScene\VBWindow.cpp(861) : warning C4101: 'rc2' : unreferenced local variable
C:\Microsoft Visual Studio\VC98\INCLUDE\algorithm(629) : error C2784: 'class std::basic_string<_E,_Tr,_A> __cdecl std::operator +(const class std::basic_string<_E,_Tr,_A> &,const _E)' : could not deduce template argument for 'const class std::basic_
string<_E,_Tr,_A> &' from 'class std::list<struct viewportpos,class="" std::allocator<struct="" viewportpos=""> >::iterator'
C:\Microsoft Visual Studio\VC98\INCLUDE\algorithm(620) : see reference to function template instantiation 'void __cdecl std::_Insertion_sort_1(class std::list<struct viewportpos,class="" std::allocator<struct="" viewportpos=""> >::iterator,class std:
:list<struct viewportpos,class="" std::allocator<struct="" viewportpos=""> >::iterator,bool (__cdecl *)(struct ViewportPos,struct ViewportPos),struct ViewportPos *)' being compiled &tc
and then this at the bottom
C:\Microsoft Visual Studio\VC98\INCLUDE\algorithm(620) : see reference to function template instantiation 'void __cdecl std::_Insertion_sort_1(class std::list<struct viewportpos,class="" std::allocator<struct="" viewportpos=""> >::iterator,class std:
:list<struct viewportpos,class="" std::allocator<struct="" viewportpos=""> >::iterator,bool (__cdecl *)(struct ViewportPos,struct ViewportPos),struct ViewportPos *)' being compiled
Am I right in thinking I cannot create a functor that accepts my own struct ? OR am I just doing something wrong ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
From Stroustrup p 539: The standard list does not provide random access iterators, so lists should be sorted using the specific list operators (17.2.2.1)
Let's never tell anyone about this, OK ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hi all,
Please explain to me about _StreamPtr ...
About performance, functions and ...
Thanks
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
depends on what you want to do with it ?
|
|
|
|
|
I wanna load and save bitmap in Access 2000 database, please help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi all!
I made an simple application on my computer which uses "small font"; When I bring this program to a computer that uses large font, some buttons are missing. and some buttons with long caption does not display the caption correctly. Is there a way to avoid this problem.
I am thinking of choosing a font that is not true type, so it won't grow or shrink with windows, but not sure if it will work.
Can we detect windows' font size and change dynamically?
Thanks
Vu
vucsuf
|
|
|
|
|