|
unfortunately we cant use any MFC. But thanks for the link.
Its gotta be a c/c++ implementation.
Cheers
Skute
|
|
|
|
|
I fail to understand the logic behind "can't use any MFC". Why make yourself jump through all sorts of hoops to reinvent the wheel.
As for the CSMTPConnection class, all it uses are CString , CArray , and CStringArray . It should not be to difficult to go through the code and replace them with the string and array classes that fit your requirements.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
I fail to understand the logic behind "can't use any MFC". Why make yourself jump through all sorts of hoops to reinvent the wheel.
Because the project at work was started about 5 years ago by the MD of the project in standard C, therefore must use standard C.
And anyway, even if i didnt, i still prefer standard API calls, MFC is so bloated, yeah you can get small apps up and running really fast but when the project starts to grow it gets extremely difficult to stay in control of it all.
(Anyway, we should leave this as it isnt an MFC vs API thread :p)
PJ Arends wrote:
As for the CSMTPConnection class, all it uses are CString, CArray, and CStringArray. It should not be to difficult to go through the code and replace them with the string and array classes that fit your requirements.
Thanks, ill go through it and try to convert it,
Regards
Skute
|
|
|
|
|
Hmm, it appears that class actually sends the email itself via sockets etc. I was after a MAPI based solution that would open the default mail client's "New Message" window with the pre-written email. It would then be upto the mail client to send the message.
Cheers anyway tho.
Skute
|
|
|
|
|
Hello
I've got a file with reserved words and i want to load them to the heap memory. The problem is that i want to be able to work with the char **reservwords after loading it in the function loadreswords, i mean i want to see it in main.
The following code works for c++, as i pass it by reference (char **& reservwords in function header). But i need an ANSI C way of solving the problem.
Somebody said that i could use a char *reservwords[], but when i declare it the compiler says that the size is unknown, as i don't put anything between the [] as i want specify it's size after counting the number of words, and in c you must declare variables at the beginning of funtions.. thanks for helping!
<br />
<br />
void main (void)<br />
{<br />
char **reservwords;<br />
loadreswords (reservwords);<br />
}<br />
<br />
void loadreswords (char **& reservwords)<br />
{<br />
<br />
palres = (char**) malloc ((sizeof(char*))*(*count_of_words));<br />
<br />
<br />
palres[j] = (char*) malloc (strlen(word)+1);<br />
}<br />
<br />
|
|
|
|
|
I dont quite understand your thinking behind your structure there, but surely the *& at the end cancel each other out. Therefore youre just expecting a char*??
Anyway, try using a double pointer in the function:
(Note also, main should be declared as int main in c/c++)
<br />
int main()<br />
{<br />
char* pointer;<br />
dofunc(&pointer);<br />
<br />
free(pointer);<br />
return 0;<br />
}<br />
<br />
void dofunc(char** dblpointer)<br />
{<br />
*dblpointer = (char *)malloc(strlen(text) + 1);<br />
}<br />
Hope that helps ya
Skute
|
|
|
|
|
what i am expecting from the file is a list of words. Part of the file:
auto
asm
break
case
char
const
continue
default
.
(continues)
.
void
volatile
while
(eof)
with :
<br />
void dofunc(char** dblpointer)<br />
{<br />
*dblpointer = (char *)malloc(strlen(text) + 1);<br />
}<br />
i think you are loading one word and i need to load a list of words.
|
|
|
|
|
Do you really have to use C? This seems like an obvious application for something like std::set<std::string> to me.
Anyway.
void LoadReservedWords ( char *** pppc )
{
int i ;
int count = CountReservedWords () ;
char ** ppc ;
ppc = (char **) malloc (( count + 1 ) * sizeof ( char * )) ;
for ( i = 0; i < count; ++i )
{
ppc [ i ] = ( char * ) malloc ( sizeof ( char ) * ReservedWordSize ( i ));
strcpy ( ppc [ i ], ReservedWord ( i )) ;
}
ppc [ i ] = (char *) malloc ( sizeof ( char )) ;
*ppc [ i ] = '\0' ;
*pppc = ppc ;
}
void FreeReservedWords ( char ** ppc )
{
char ** ppc2 = ppc ;
while ( **ppc2 )
{
free ( *ppc2 ) ;
++ppc2 ;
}
free ( *ppc2 ) ;
free ( ppc ) ;
}
int main(int argc, char * argv[])
{
char ** ppc ;
int n ;
LoadReservedWords ( &ppc ) ;
for ( n = 0; *ppc [ n ]; ++n )
{
printf ( "%s\n", ppc [ n ]) ;
}
FreeReservedWords ( ppc ) ;
return 0 ;
}
I've obviously glossed the counting and accessing of your reserved words. Space is made for an empty string on the end of the array to use as a sentinel.
Paul
|
|
|
|
|
|
I placed a CListCtrl on my dialog form from the toolbox. WHen I go to use it in code, the hwnd ofthe associated variable m_list (I used class wizard) is 0x00. SO the code
int i = m_listInvisible.GetStringWidth(mainPath);
crashes in the debug version, but works fine in the release version!!!
Why is it zero? (Because I have a button too, and its hwnd isnt zero). Also why doesnt it crash in release?
Thanks,
ns
|
|
|
|
|
Where in your dialog code are you calling your variable?
You should also bear in mind that your control variable (if created using class wizard), will not be created until the base function, ::OnInitDialog(), has been called. If you attempt to access it before this, then it will crash!
<edit>This, may not explain why it runs in release mode though
I Dream of Absolute Zero
|
|
|
|
|
You're so right. I was calling it before the dlg->Create().
|
|
|
|
|
Hello all !
I'm using MFC in a SDI application and I want a toolbar with a single Slider control on it (just the slider, nothing else). I found some articles that describes how to add some controls on the toolbar but this doesn't work if I have just the slider...
Any idea ?
Thanks
|
|
|
|
|
What is the funktion to set the Data Source of a MS ADO DATAGRID Controll Object. A DB Grid will be set by Objekt.SetDataSet() but it did´t work for MSDG.
|
|
|
|
|
If you take, say, an Edit control or a Static control, and make it multi-line, and stuff a bunch of text into it, Windows somehow knows how to break that text up into words, and splits it nicely. It even takes the language of the machine into account - Chinese text will wrap differently than English text.
Is there a way to programmatically take advantage of this? For instance, if I have a string, and want to know where the breaks should be, taking into account locale, is there any kind of API or anything to get the proper places to break?
Thanks.
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Create a hidden edit control, add your text to it, and then read from the control.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
David,
I don't think that will work, since word breaking is an artifact of painting the control (using the DT_WORDBREAK flag in DrawText() ). Hyphenation and stemming libraries are available (for various languages) but aren't cheap.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
I don't think that will work...
Actually it does work. Try it for a full appreciation.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
How to change CFontDialog to allow color picker instead dropdown list of
system colors?
Putic A.
|
|
|
|
|
Who could explain to me how getline is working? I checked already a tutorial about it, but I didn't understand well.
THX
|
|
|
|
|
A "PLEASE" would have been highly appreciated.
istream::getline (member functions)
Declarations:
Form 1 istream& getline(signed char*, int, char = '\n');
Form 2 istream& getline(unsigned char*, int, char = '\n');
istream::getline, Form 1 (member function) Declaration:
istream& getline(signed char*, int, char = '\n');
Remarks:
This form of getline does the following:
_ extracts up to the delimiter,
_ puts the characters in the buffer
_ removes the delimiter from the input stream
_ does not put the delimiter into the buffer
istream::getline, Form 2 (member function)
Declaration:
istream& getline(unsigned char*, int, char = '\n');
Remarks:
Extracts characters into the given char * until one of the following occurs:
_ the delimiter (third parameter) is encountered
_ end-of-file is encountered
_ (len - 1) bytes have been read
>>A terminating null is always placed in the output string.
>>The delimiter is also extracted.
>>The delimiter is not placed into the destination string.
>>Fails only if no characters were extracted.
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
What exactly do you want?? Any specific things..
|
|
|
|
|
Hi !
If I have a list (from the STL) and want to reach the nth element, I'd like to use an iterator, set it to the beginning of the list and do something like It=It+index_to_reach.
It works for the vector, but not for the list. Could anyone tell me how I'm supposed to do ?
Here is how I do it now (with a loop incrementing the iterator) :
#include <iostream>
#include <list>
int main(int argc, char* argv[])
{
int ElementIndexToReach=2;
std::list<int> MyList;
MyList.push_back(1);
MyList.push_back(2);
MyList.push_back(3);
MyList.push_back(4);
std::list<int>::const_iterator It;
It=MyList.begin();
for (int i=0; i<ElementIndexToReach; ++i, ++It);
std::cout << "Expected value : 3. Value : " << (*It) << "\n";
return 1;
}
|
|
|
|
|
You probably want the advance() algorithm. There's a worked example in the VC online help...
// Advance.cpp
// compile with: /EHsc
#pragma warning (disable:4786)
#include <iostream>
#include <string>
#include <list>
using namespace std ;
typedef list<string> STRLIST;
int main() {
STRLIST List;
STRLIST::iterator iList;
STRLIST::difference_type dTheDiff;
List.push_back("A1");
List.push_back("B2");
List.push_back("C3");
List.push_back("D4");
List.push_back("E5");
List.push_back("F6");
List.push_back("G7");
// Print out the list
iList=List.begin();
cout << "The list is: ";
for (int i = 0; i < 7 ; i++, iList++)
cout << *iList << " ";
// Initialize to the first element"
iList=List.begin();
cout << "\n\nAdvance to the 3rd element." << endl;
advance(iList,2);
cout << "The element is " << *iList << endl;
dTheDiff = distance( List.begin(), iList);
}
Output
The list is: A1 B2 C3 D4 E5 F6 G7
Advance to the 3rd element.
The element is C3
Requirements
Header: <iterator>
Kevin
|
|
|
|
|
Like this
#include <iostream>
#include <list>#include <utility>
int main(int argc, char* argv[])
{
int ElementIndexToReach=2;
std::list<int> MyList;
MyList.push_back(1);
// First element
MyList.push_back(2);
MyList.push_back(3);
// Third element
MyList.push_back(4);
std::list<int>::iterator It;
It=MyList.begin(); // First element
std::advance(It, ElementIndexToReach);
std::cout << "Expected value : 3. Value : " << (*It) << "\n"; return 1;
}
This is needed because only random access iterators provide + and - operators. There is also a distance function which is used with non-random access iterators.
Internally, advance does just what you were doing with your for loop.
|
|
|
|