|
Antony M Kancidrowski wrote:
Doesn't this just state the obvious. If you are writing native code then C++ will be faster!?!
The impression I get from his statement is that for .NET tasks C++ is preferred too. A lot (most?) of the native code in Longhorn is .NET.
Kevin
|
|
|
|
|
I use SetItemText to store title,that's ok.but SetItemData store URL have some question.why result is often wrong?
how to use SetItemData?
very very thx poor english
insert an item to a tree
code:--------------------------------------------------------------------------------
for (int i = 0;...; i++)
{
....
htiChild = m_etc.InsertItem(m_strNewDir, hti, TVI_LAST);
CString strItemData= "www.aaa.com";
lpszItemData = new TCHAR[strItemData.GetLength()+1];
lpszItemData = (LPCTSTR)strItemData;
m_etc.SetItemData(htiChild, (DWORD)lpszItemData);
}
--------------------------------------------------------------------------------
save tree to a file
code:--------------------------------------------------------------------------------
for(..)
{LPCTSTR pItemData;
strTitle = GetItemText(hti);
pItemData = (LPCTSTR)GetItemData(hti);
CString strItemData(pItemData);
str = strTitle + strItemData;
save str
}
--------------------------------------------------------------------------------
lLoad the file to a tree
code:--------------------------------------------------------------------------------
for (iCount = 0; ...iCount++)
{
strItemText = strItem.Left(n);
lpszItemText = strItemText.GetBuffer();
strItemText.ReleaseBuffer();
strItemData = strItem.Right(strItem.GetLength() - n - 5);
lpszItemData = new TCHAR[strItemData.GetLength()+1];
lpszItemData = strItemData;
InsertItem(lpszItem, hParent, hInsertAfter);
SetItemData(htiSon, (DWORD)lpszItemData);
......
}
|
|
|
|
|
You need to study pointers a little more
lpszItemData = new TCHAR[strItemData.GetLength()+1];
lpszItemData = (LPCTSTR)strItemData;
That's not going to work. You must copy the memory from the source string to the target string not just assign the pointer. Also you have a memory leak since you lost the memory address that was allocated with "new".
Try this to start with http://www.codeproject.com/cpp/pointers.asp[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
I like to use greek letters and subcript indexes for mathematical expressions and formulas in dialog forms and output strings of my Visual C++ MFC programs. Can some one explain how to do that.
Thanks
|
|
|
|
|
You do this by selecting appropriate fonts when outputting. For editable text, you will want to use the Rich edit control. For captions, you'll need CStatics with font-setting capabilities.
For both types of controls, you'll find a multitude of articles on this site.
|
|
|
|
|
Hi
I have a simple question on where to put #include statements. Should I put them in .h file, or in .cpp file? For example, I have a class A in A.h and A.cpp. Class A uses STL vector, so is it better for me to #include <vector> in A.h or A.cpp? ANd how about using keyword? Should I write using std::vector in A.h or A.cpp?
Thanks!
|
|
|
|
|
normally you include A.h in A.cpp
if you need to declare eg a vector in your .h file you need to use the #include here, if not, you still can put it here (because you include your A.h in your .cpp) or put it in your .cpp.
I'm not sure of the reason of putting includes in the cpp files, but I think it's because of inheretence of other files from your .h.
hope this helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Indrawati wrote:
how about using keyword? Should I write using std::vector in A.h or A.cpp?
You should never use the using keyword in your .h files. This way, you pollute the global namespace. It may not result in disaster for using std::vector, but you never know...
If you really want to use the using keyword, put it in the .cpp file.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
The #includes can be in either. But a common approach is to put them in the .h.
So, in A.h
#include <vector>
// Use namespace qualifier std::
void foo(const std::vector& vec);
In the A.cpp
#include "A.h"
using namespace std;
void A::foo(const vector& vec)
{
}
But never put using namespace std;
in the header.
Kevin
|
|
|
|
|
If whatever you need to include also needs to be include in another file to work with your class (say for instance, one member returns a vector), then put the include in the header file.
Also, if your class (or whatever) encapsulates all dependencies then do not put the includes in the header file.
Jeremy Falcon
|
|
|
|
|
If the cpp uses the functions inside the h files put in the cpp otherwise put them somewhere where the functions could be used by the program.
It is advisable that you make a .h file that stores all the .h files you need.
for ex:
storing_h_files.cpp should be loking like this:
#include storing_h_files.h
storing_h_files.h should be loking like this:
#ifndef storing_h_files
#define storing_h_files
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#include <afxdtctl.h>
#include <afxcmn.h>
.
.
.
.
.
.
.
#endif
gabby
|
|
|
|
|
How can I display My Computer folder in a CFileDialog? I tried with SHGetSpecialFolderPath , but the path is empty, i believe because Ny Computer is a vitual folder, not a system one or a real one.Thank you.
|
|
|
|
|
you can set a default directory if your CFileDialog opens.
look into the ONF structure or something.
Don't know if it will work with Virtual Folders though.
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Only some CSIDLs are supported with SHGetFolderPath() , and CSIDL_DRIVES is not one of them. You can, however, use CSIDL_DRIVES in conjunction with SHBrowseForFolder() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
When I try to open .vcprj files which were created by converting c++ prjects I get this error: "The application for project '<project name="">.vcproj' is not installed. Make sure the application for the project type (.vcproj) is installed"
I have been expermenting with addins for the last couple of days, and handled the registry myself (for cleaning addin leftovers) so I probably erased one tto many registry entries.
Could you help me restore the right entry?
Thx
Naama
|
|
|
|
|
Hello everyone:
How to get back color of a dialog? Please help me.
Thank you.
-Freehawk
|
|
|
|
|
In OnInitInstance you can call SetBkDialogColour(i am not sure if the syntax is right) maybe there is a function also for getting the background color.
|
|
|
|
|
Have you looked at GetSysColor() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thank you for the reply.
I called GetSysColor(); It run good.
-Freehawk
|
|
|
|
|
Great! What COLOR_xxx value did you end up using?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi
I did as the following:
GetSysColor (COLOR_3DFACE)
I hope it can be useful for you.
-Freehawk
|
|
|
|
|
Question: It's required to make the simplified window
of preview goods. The window is consisted
of two parts - on the left it's the tree
of good's categories( only one level),on
the right side it's the list of goods co-
rresponding category.Attached to
the definite category in the tree in the list
on the right side the goods of this
category have been appeared.The window of
adding of goods is called by right click
of mouse in the right window and the window
of adding of category is called
by right click of mouse in the left window.
It's required to make the sql-scripts of
making of structure of database and for
inputing of data into database.
Igor Sidorov - 22th june 2004
|
|
|
|
|
Ok, so which part specifically of this overall design are you having trouble with?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello,
I created a class inherited from CBitmap to add some functionality like rotation, blur and so one.
Now I need to create a function that changes the color depth of the bitmap.
I need to convert the 24 bpp color bitmap into B/W, 8, 16, 256 Colors and 16 bpp I also need a function that converts from all the above color's depths to 24 bpp bitmap, the function perform save directly.
Any ideas
thanx in advance
Enjoy.
Ouss.
|
|
|
|
|
HI,
I wana to add tool bar , i not want to design then in Editor .. bcoz its diffcult .
I wanaa use BMP. how can i use BMP image on toolbar.
thanx
n if i wanna import A Toolbar .. wt extension it has ..
it only shows icon files to import.
thanx
|
|
|
|