|
See Here[^] and here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
What's wrong with these code: a new field named "Field19" is created. i wanna set all the values in Field19 are "abc:
CDaoDatabase db;
CDaoTableDef tableDef(&db);
db.Open("C:\\ktt.mdb");
tableDef.Open("Table3");
CDaoRecordset recset( &db );
tableDef.CreateField("Field19",dbText,255,dbUpdatableField | dbVariableField);
if ( !recset.IsEOF() )
recset.MoveLast();
while( !recset.IsEOF() )
{
recset.SetFieldValue("Field19","abc");
recset.MovePrev();
}
|
|
|
|
|
Hi,
Well it depends on the recset.SetFieldValue("Field19","abc"); function.
Is everything operating corrcetly inside the function?Have you tried to use GetLastError() What is the debugger informing you?Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi.
In the MDI program that I've created, after I have "save as..", the title bar changed to the filename that I put in the save as dialog. How can I retain the old filename in the title bar?
|
|
|
|
|
The title bar is set with SetWindowText. It's set by the framework, you'd need to change it after this occurs, but the thing is, the filename is obviously being saved in a member variable, if you change the frame text without changing this value, clicking save won't do what you'd expect. So, I'd recommend stepping into the MFC code to work out the stuff that happens in a save as that you want to reverse.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Aint,
You can overwrite SetTitle() in your CDocument derived class. This Method will be called after Sav'ing and Save As'ing.
|
|
|
|
|
This is because after "saving as" you have your new file as active file/document in your app. One solution is already above, but you can make another thing (only if the old file was already saved, if new document won't be possible). You can override messages to save as.. a file, and just after the file is saved call OnCloseDoc () and OpenDocument () with the name of the old file. Then you will have the new copy of your file "saved as" but still continue working with the original file.
If the project is a new project... you can make a call to Serialize first to save the things in a default file, then call the save as and then the same as before.
But the fact is that 95% of the applications/programms work in that way. You always have active the file with the last save. I mean... if you open file1 and do some changes, then save as file2. You will have the file1 without changes in the HD, you will see the changes made in the file2 (and this one will be the active document automatically) and any posterior change will go automatically to file2, as long you don't open specifically the file1 another time.
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?
|
|
|
|
|
This is because after "saving as" you have your new file as active file/document in your app. One solution is already above, but you can make another thing. You can override messages of "save as.." in a file, and just after the file is saved call OnCloseDoc () and OpenDocument () with the name of the old file. Then you will have the new copy of your file "saved as" but still continue working with the original file.
If the project is a new project... you can make a call to Serialize first to save the things in a default file, then call the save as and then the same as before.
But the fact is that 95% of the applications/programms work in that way. You always have active the file with the last save. I mean... if you open file1 and do some changes, then save as file2. You will have the file1 without changes in the HD, you will see the changes made in the file2 (and this one will be the active document automatically) and any posterior change will go automatically to file2, as long you don't open specifically the file1 another time.
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?
|
|
|
|
|
I use the method supplied by http://www.codeproject.com/system/MultiCPUUsage.asp in my project. It works fine in all platform except vista.
Anybody knows?
|
|
|
|
|
Mmmm, I don't know... but it seems that Vista is having a lot of problems. There are some Laptop providers that have returned all equipments with Vista and continued with XP. Just be patient until MS patches Vista's failures.
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?
|
|
|
|
|
I'm developing an application which can display some item with a thumbnail to show it is a file or folder. So I declare a variation as CImageList which include some image and a CListCtrl variation. Then attach them together. After those, I add item and image in CListCtrl and CImageList. But the image can't be display. I hope someone can help me. Thx!
The code is following.
clsImage=new CImageList();
clsImage->Create(32,32,ILC_COLOR8,0,2);
lsFile.SetImageList(clsImage,LVSIL_SMALL);
lsFile.SetRedraw(FALSE);
for(i=0;i<ItemCount;i++)
{
memcpy(&name_len,p,sizeof(int));
p+=4;
pName=new BYTE[name_len+2];
memcpy(pName,p,name_len);
pName[name_len]='\0';
pName[name_len+1]='\0';
p+=name_len;
kind=*p;
p++;
memcpy(time_str,p,16);
CBitmap *bmp=new CBitmap;
if(kind==1)
bmp->LoadBitmapW(IDB_FILE);
else
bmp->LoadBitmapW(IDB_FOLDER);
clsImage->Add(bmp,RGB(0,0,0));
lsFile.InsertItem(i,(LPCTSTR)pName,i);
delete bmp;
delete pName;
p+=16;
}
lsFile.SetRedraw(TRUE);
lsFile.Invalidate();
lsFile.UpdateWindow();
To be simplicated, I ommit some code to declare local variation.
whiteclouds
|
|
|
|
|
which view are you using in list control( Thumbnail,List, Report ... )?
|
|
|
|
|
Are you sure bmp->LoadBitmapW(IDB_FOLDER/or IDB_FILE); is valid?
|
|
|
|
|
I'd found the reason. I hadn't set the control's property of view. If I set it to small icon, the code can display the image as I wanted. Thanks to two above. I hope I can get more help from u in the future.
|
|
|
|
|
Hi all:
Below is my problem:
I declared a class called "WordTable" in a .h file.:
<code>class WordTable
{
public:
typedef vector<streampos> OccurrenceList;
private:
......
public:
OccurrenceList& getOccurrences(string word);
};</code>
later in a .cpp file.
I defined the function "getOccurrences()" as following:
<code>OccurrenceList& WordTable::getOccurrences(string word)
{
OccurrenceList list;
return list;
}</code>
But it seems that the complier does not recognize "OccurrenceList" at all. I am sure that I have included the proper header file.
I tried to fix the errors by explicitly declare "typedef vector<streampos> OccurrenceList;" at the top of the .cpp file, it worked.
Can anyone help?
Thank you
|
|
|
|
|
I believe that you need to do the typedef outside the class. Better yet, don't do it, those things are nasty, they just make your code unreadable.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: I believe that you need to do the typedef outside the class. Better yet, don't do it, those things are nasty, they just make your code unreadable.
Nothing's wrong with typedef s; they make code more readable not less so. Nothing's wrong with typedef s inside class definitions either: in fact in some cases it's just good encapsulations and is exactly where they should go. The OP’s problem was simply that the use of a member typedef needs to be qualified with the containing class name if used outside the containing class, just like for any other member.
Steve
|
|
|
|
|
Stephen Hewitt wrote: they make code more readable not less so.
That's a matter of opinion. I've worked on code that contained a ton of STL containers, all typedefed, and it was plain illegible.
Stephen Hewitt wrote: The OP’s problem was simply that the use of a member typedef needs to be qualified with the containing class name if used outside the containing class, just like for any other member.
Yes, I realised that, but pulling it out seemed the simplest solution.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: That's a matter of opinion. I've worked on code that contained a ton of STL containers, all typedefed, and it was plain illegible.
In the end almost anything can be considered a matter of opinion, but I’ll explain some instances in which typedef s can be useful. A STL std::set looks something like this:
template <class _K, class _Pr = less<_K>, class _A = allocator<_K> >
class set;
If we have one of these beasts where we’ve made explicit use of all three template arguments we’d have to specify the whole long type in every use. A simple typedef with a descriptive name eliminates all this. Surely this is a simplification, especially since some of the arguments are implementation details. Say, at a later stage, we make a design decision to change the allocator used: we would have to go through the code and change all uses of the type. If a typedef is used we can make the change in one place. This is an example of the general design principle that, if possible, a single design decision should be expressed in a single place (or as few places as possible). Another example is generic programming; STL containers use typedef s with standard names to expose implementation dependent types in a standard manner which enables uniform usage despite the differences.
Steve
|
|
|
|
|
If you must (against Christian's advice) nest the typedef you need to use a scope resolution
operator to reference the nested class/type from outside the class:
WordTable::OccurrenceList& WordTable::getOccurrences(string word)
{
WordTable::OccurrenceList list;
return list;
}
A template defines a class. If you nest the class in another class then you need to resolve the
scope anywhere outside of the class, as shown above.
Plus there's a bug, noted above
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark:
Thank you for your solution. This is EXACTLY what my problem was!!!!
So happy to get it solved.
Thank you again.
|
|
|
|
|
Hi C_Zealot,
Try a forward declaration (in the h file, or the cpp file):
class OccurrenceList;
Jeff
|
|
|
|
|
Please help me find a simple example of CTreeCtrl (view not dialog) actually using TVN_SELCHANGED message and GetSelectedItem function. My code always returns first item in the tree and the MS CmnCtrl1 sample code refuses to give me the whole text of the selected item. I get only first character. It should return CString.
Thanks for reading
Vaclav
I got it!
I have neglected to bypass first TVN_SELCHANGED message which gets posted on initial drawing of first node of the tree! Hence I always see first node "selected".
-- modified at 21:57 Thursday 31st May, 2007
|
|
|
|
|
Vaclav_Sal wrote: refuses to give me the whole text of the selected item
How did you verify that? Through debugging? Try putting a message box. If _UNICODE is define in your project, you must set some settings of MSDEV.
tools->options->Debug-> Now tick the "Display UNICODE string check box".
|
|
|
|