|
I think that question is answered by the fact that he's using CString
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom Archer wrote:
I think that question is answered by the fact that he's using CString
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
You know I'm playing with you Nish
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom Archer wrote:
You know I'm playing with you Nish
Yup, I do know that Tom
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
By the way, I know it would be a pain to program and not a high-priority item, but wouldn't it be great if when someone posted a "smart app" took parameters that were specifid to a given forum so that it would make helping others easier? How many times do we see questions and the first follow-up is "Are you using MFC?". Therefore, in this forum, the Ask a Question dialog would be defined to require the answering of questions like Are you MFC (y/n), What version of VC++ are you using, etc. What do you think?
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Hey Tom,
Good idea. Maybe, people who post questions can use a header as :-
Platform :- XP
Dev Tool :- VC++ 6.0
Libraries :- MFC
That might help.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Didn't this site once state that the discussion board software was open source? If so, where can the source be found?
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Tom Archer wrote:
Didn't this site once state that the discussion board software was open source? If so, where can the source be found?
Yeah there is a CP article by I think Uwe Keim with the source code, but it's long since it has been updated.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
Yeah I was hoping that the link would always be kept to point to the current build
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
Yep, I'm using MFC and Visual c++ 6.0
But the main problem is the autocomplete. After you've typed a "." or a "->" a box comes up with the member functions, well that doesn't work anymore for the mfc classes (it works for my own) in a certain project. Autocomplete is "on" in the prefs.
and that messagebox?
Bluute tette!
|
|
|
|
|
frisco wrote:
and that messagebox?
The MFC MessageBox wrapper is available only inside CWnd derived classes. Which class are you trying to call MessageBox from? Not CWinApp derived I hope. There you can either use the API MessageBox call or AfxMessageBox.
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
does anyone know how i can do the following as i am quite new to this language. all help greatly Appreciated.
i want to be able to create a text file, then through C++ i want to be able to add records to this text file, for example
create a new customer record, add to text file 'customer', add surname, first name etc. how do i do this
then i want to be able to search for a record within a text file. also how can i search for a record and copy it to another text file.
Cheers Si
SI
|
|
|
|
|
You want to use iostreams. There are several articles in the STL section which show you how.
Essentially:
#include <iostream>
using std::ofstream;
using std::endl;
int main()
{
ofstream file("c:\\MyFile.txt");
file << count << endl;
for (int i = 0; i < count; ++i)
{
file << customer[i].surname << endl;
file << customer[i].firstname << endl;
file << customer[i].whatever << endl;
}
file.close();
}
I have an article on how you could write a handler to stream the customer struct all in one go as well.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
<i>And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned.</i> - <b>Christopher Duncan - 18/04/2002</b>
|
|
|
|
|
Hi all,
Just wondering, after subclassing a combo-box or list-box,
What is the trick for painting a bmp as background on which
to write our text?
Making a more exciting control,
Thanks!
Orlanda
Coding is a family business
|
|
|
|
|
Never done it, but i'd try implementing a handler for WM_ERASEBKGND (MFC OnEraseBkgnd() and drawing the bitmap to the provided device context.
--------
all the modern things
have always existed
they've just been waiting
to come out
and multiply
and take over Björk, The Modern Things
|
|
|
|
|
hi,
Could you detail your explanation?
I grasp your idea.
Just that I'm kinda new to MFC...
Thanks!
Orlanda
Coding is a family business
|
|
|
|
|
Alright, so you've got this custom listbox class... Add a member variable of type HBITMAP . Call it m_pbmpPattern . Initialize it to NULL . Add the line ON_WM_ERASEBKGND() to it's message map. Add the function BOOL OnEraseBkgnd(CDC* pDC) to the class. Use this code for the implementation:
BOOL CMyListBox::OnEraseBkgnd(CDC* pDC)
{
CRect rectClient;
GetClientRect(&rectClient);
if ( NULL == m_pbmpPattern )
m_pbmpPattern = static_cast<HBITMAP>(::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_BACKGROUND), IMAGE_BITMAP, 0,0, LR_SHARED));
if ( NULL == m_pbmpPattern )
return FALSE;
CDC dcPat;
dcPat.CreateCompatibleDC(pDC);
CBitmap* pbmpOld = dcPat.SelectObject(m_pbmpPattern);
BITMAP bitmap;
if ( m_pbmpPattern->GetBitmap(&bitmap) && bitmap.bmWidth > 0 && bitmap.bmHeight > 0 )
{
for (int y=0; y<rectClient.bottom+bitmap.bmHeight; y += bitmap.bmHeight)
{
for (int x=0; x<rectClient.right+bitmap.bmWidth; x += bitmap.bmWidth)
{
pDC->BitBlt(x,y, bitmap.bmWidth, bitmap.bmHeight, &dcPat, 0,0, SRCCOPY);
}
}
}
dcPat.SelectObject(pbmpOld);
return TRUE;
} Note, this is not the best way of accomplishing this; but it is a start. Read the articles on writing custom controls here at CP to get a better grip of the basics.
--------
all the modern things
have always existed
they've just been waiting
to come out
and multiply
and take over Björk, The Modern Things
|
|
|
|
|
Hey Guys
Just a quick question about good programming practice should i delete all variables i use in a function and program or just deallocate memory i have pointed to an initalise the pointers to null and let the rest be deallocated when the function/program drops out.
Peter
|
|
|
|
|
What do you mean by "deleting variables" in opposition to "deallocating memory"?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
delete everything you allocate. don't let the lazy people tell you different.
-c
<font size=-2>
o(int O){putchar(O);}main(){float _[8],O,I=.05;char l;for(_[6]=15;_[6]<':';o
(10),_[5]=-'$'*I+_[6]++*I)for(_[7]=-5;_[7]<'@';_[4]=-'('*I+_[7]++*I,o(l?'?':':'))
for(*_=O=0,l=1;++l&&((_[2]=*_**_)+(_[3]=O*O)<4);O=*_*O+_[5]+O**_,*_=_[2]-_[3]+_[4]);}</font>
|
|
|
|
|
Cheers Chris thats what i needed to know
Peter
|
|
|
|
|
Chris, the way I read his question, he knows to delete pointers, but wants to try and delete variables where he has not allocated any memory dynamically.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
sure. but i did say "delete everything you allocate". which excludes things he didn't allocate. i suppose i'm assuming he knows that "allocate" means "things you had to use 'new', 'malloc', 'GlobalAlloc' and friends to get".
maybe i'm wrong. i hope so. i'd like to see what it's like.
-c
<font size=-2>
o(int O){putchar(O);}main(){float _[8],O,I=.05;char l;for(_[6]=15;_[6]<':';o
(10),_[5]=-'$'*I+_[6]++*I)for(_[7]=-5;_[7]<'@';_[4]=-'('*I+_[7]++*I,o(l?'?':':'))
for(*_=O=0,l=1;++l&&((_[2]=*_**_)+(_[3]=O*O)<4);O=*_*O+_[5]+O**_,*_=_[2]-_[3]+_[4]);}</font>
|
|
|
|
|
Chris Losinger wrote:
maybe i'm wrong. i hope so. i'd like to see what it's like.
*grin*
Well, I'd just presume that someone who asks if they need to delete something they did not allocate probably won't understand what 'allocate' means.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
You can only delete the variables you initialised in pointers. This won't work:
int i;
i = 0;
ExternalFunction(i);
delete i; // WONT WORK !!!
non pointers are deleted for you when they go out of scope.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|