|
Hi,
I am working VC++ on VC6.0 IDE
I am using lot of CString constants in my program
I am using #define to replace strings instead of USING string table and loading stings;
like:
#define ID_NAME _T("Krishna")
#define ID_PROFILE_PATH _T("\\Folder11\\Krish")
like above i have 10 t0 12 strings.
To work with this which way is the best way
using #defines or using string table?
If any methos is best, why?
Thanks in advance
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
krishnakumartm wrote: If any methos is best, why?
doesnt it depend on what the program does, and what its future prospects are ... if its just a one-off console mode program, then, maybe you dont need to think beyond #define
But if it is a serious program, and you may want to (for example) localise the strings for different languages later, then you should consider resource/string tables, or, even keeping the strings in an external file (possibly xml) .. maintenance will be way easier then if a little work is doen up-front.
'g'
|
|
|
|
|
Are you concerned about memory usage? Even so, you would need a bunch of string constants in order for that to be an issue.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
i want to show browse button on a dialog box application and i want to select a folder not file.
how can i implement for browse control for selecting folder? thanks in advance.
|
|
|
|
|
You can use of SHBrowseForFolder .
|
|
|
|
|
thanks Hamid for replying me.
Could u plz tell me whether i can get some sample code or sample project for browse control?
|
|
|
|
|
|
hi Hamid,
thanks a lot for replying me.
i want to make implementation simple so what i have done is:
i have taken 1 button, on click event i have implemented as below:
void Logfilepath::OnBrowse()
{
// TODO: Add your control notification handler code here
{
CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this);
if(FileDialog.DoModal() == IDOK)
{
CString PathName = FileDialog.GetPathName();
// CString PathName1 =FileDialog.GetFolderPath();
m_ctrledit.SetWindowText(PathName);
}
}
}
now with this implementation i am able to select files but i want to select only folder.
what other implementation i should do so that i will be able to select folder and not file?
|
|
|
|
|
Why you dont use of SHBrowseForFolder it simple to use.
|
|
|
|
|
thanks Hamid,
yaa i could implement that using SHBrowseForFolder.
|
|
|
|
|
I hope this little sample code will help you if you want to select the folder,
void CFolderSelectionDlg::OnBrowseClick()
{
BROWSEINFO brwsInfo;
ZeroMemory(&brwsInfo,sizeof(BROWSEINFO));
int iImage = 0;
char szFolderPath[MAX_PATH];
char szTitle[255];
memset(szFolderPath,'\0',sizeof(szFolderPath));
memset(szTitle,'\0',sizeof(szTitle));
brwsInfo.hwndOwner = GetSafeHwnd();
brwsInfo.iImage = iImage;
brwsInfo.lpfn = NULL;
brwsInfo.pidlRoot = NULL;
brwsInfo.pszDisplayName = szFolderPath;
brwsInfo.lpszTitle = szTitle;
//InitCommonControls();
ITEMIDLIST *ptrItemList = SHBrowseForFolder(&brwsInfo);
if(ptrItemList != NULL)
m_strFolderPath = szFolderPath;
UpdateData(FALSE);
}
this is the simplest. if you want all advanced functionality, you should inherit yoour custom fileDialog class. please go thourh the MSDN.you have to write your version of
virtual void OnFolderChange();
virtual BOOL OnFileNameOK();
best of luck...
kamalesh
|
|
|
|
|
Anjali Patil wrote: now with this implementation i am able to select files but i want to select only folder.
what other implementation i should do so that i will be able to select folder and not file?
You were suggested to use SHBrowseForFolder() . Why show code that does otherwise?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Can someone tel me what's the equivalent of the following on .Net 2003
<br />
istrstream sin(szBuffer);<br />
sin.eatwhite();
Thanks a lot
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: Can someone tel me what's the equivalent
There is no equivalent ISO C++ function available, you will have to write your own.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi all,
I've get a sample code from one of my friends used in word processing application. Written on C++ 6.
I'll try to run it on VS.Net 2003. At compile time I got an error on this.
ifstream fin(lpszPathName, ios::in | ios::nocreate | ios::binary);
Actually I got the error on ios::nocreate
I've never see this identifier for ios base. Can anyone clarify me on this.
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi.
CodingLover wrote: I've get a sample code from one of my friends used in word processing application. Written on C++ 6.
I'll assume that you meant Visual C++ 6, since there is no "C++ 6"...
CodingLover wrote: Actually I got the error on ios::nocreate
I've never see this identifier for ios base. Can anyone clarify me on this.
Assuming that by "error" you mean a "compiler error"... This has to do more with history of the pre-standard C++ era. Take a look at this[^].
Regards.
Stupidity is an International Association - Enrique Jardiel Poncela
Die deutsche Sprache sollte sanft und ehrfurchtsvoll zu den toten Sprachen abgelegt werden, denn nur die Toten haben die Zeit, diese Sprache zu lernen. - Mark Twain
|
|
|
|
|
Wondering if anyone has encountered this issue:
I put a modeless dialog into one of my apps, which has two controls -- a CAnimateCtrl, and a static text. It's basically a little splash to keep the user happy, while one of my DLLs is doing some lengthy work. I put some text there to tell them what's happening, and a little animation for eye candy.
Doesn't quite work though!
The animation will show, but not play.
Pretty simple stuff, and works if the little dialog is modal, but won't play when modeless, unless I make the dialog visible on startup -- and then it only plays on startup -- not after I call it up with ShowWindow (which calls the Play function).
Everything seems to be in order, so the only thing I can think of, is perhaps there is a threading issue between my main app, and the work the DLL is doing...?
Any ideas...?
Thanx,
Rick
|
|
|
|
|
Does the animation play when you move the mouse over it? If so, then you may need to start a timer to keep the message loop running. Try something like SetTimer(1, 50, NULL); in OnInitDialog().
|
|
|
|
|
Hi Hans,
Tried that -- no go...
Upon further testing, it will work fine, unless I do a call to the DLL. I've even tried pumping the message queue from the DLL during the process, but still doesn't help.
BTW, the function in the DLL, is building image lists to be used in the main app, using a pointer to a CListCtrl in the main app. The function works fine, as the memory is allocated in the main app through a callback.
I think I may have to implement this directly in the DLL -- I'll try that, and see if it works ok there...
|
|
|
|
|
Just in case anybody runs into this issue, I did manage to get it to work, albeit, not the way it should (according to the way the CAnimateCtrl should work).
I can get it to play if:
a) The function in the DLL does not use Begin/End WaitCursor.
b) The DLL function must constantly pump its message queue during processing.
In my case, it was somewhat easy, since I write the DLL, and can tweak it. Not sure what happens if you are using a function from a 3rd party DLL. In that case, you might have to start a worker thread in your app to run the animation properly, as a timer won't do it...
Supposedly, pumping the message queue is expensive, although I use it quite a bit without any issues -- just a simple function:
MSG msg;
while ( PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ))
AfxGetThread()->PumpMessage();
|
|
|
|
|
I'm using CWinFormControl to create instances of .Net UserControls.
CWinFormsControl<myproject::mycontrol xmlns:myproject="#unknown"> m_control;
m_control.CreateManagedControl( WS_CHILD | WS_VISIBLE, rect, this, IDC_HOSTCONTROL );
This works fine. The problem occurs when I try to destroy the control. I need a deterministic call to the 'MyControl' finalizer, so I wrote the following:
m_control.DestroyWindow();
System::GC::Collect();
This code does not cause the Finalize\Dispose code to be called on 'MyControl'. In fact, 'MyControl' sticks around in memory until the MFC app closes. What am I doing wrong here?
Thanks,
Aaron
|
|
|
|
|
tags.
This function destroys variable0 and variable1 upon completion:
void variableCopy0(variable variable0, variable variable1) {
int time0;
variable1.numTimes = variable0.numTimes;
for (time0 = 0; time0 < variable0.numTimes; time0++) {
dateCopy1(variable0.dates[time0], variable1.dates[time0]);
variable1.values[time0] = variable0.values[time0];
};
};
I call it with the following code:
vars = new variable [numVars + maxInterventions + 1];
for (var0 = 0; var0 < numVars + maxInterventions + 1; var0++) {
vars[var0].setUp(inVars[var0].numTimes);
variableCopy0(inVars[var0], vars[var0]);
};
Upon return, vars[var0] and inVars[var0] are also destroyed. I want to keep them. How do I do that. Here's the class definition:
class variable {
public:
double *values;
date *dates;
int time0;
int numTimes;
variable() {
numTimes = -1;
};
variable(int inTimes) {
values = new double [inTimes + 20];
dates = new date [inTimes + 20];
numTimes = inTimes;
};
void setUp(int inTimes) {
values = new double [inTimes + 20];
dates = new date [inTimes + 20];
numTimes = inTimes;
};
~variable() {
delete [] values;
delete [] dates;
cout << "got into variable destructor" << '\n';
};
};
Phred
|
|
|
|
|
try passing by reference
void variableCopy0(variable &variable0, variable &variable1)
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you very much. That worked.
|
|
|
|
|
Fred Andres wrote: This function destroys variable0 and variable1 upon completion:
void variableCopy0(variable variable0, variable variable1)
Yes it does, because the scope of those variables is the function.
The original variables you pass remain unaltered.
You need to pass by reference. Try something like
void variableCopy0(<code>const variable &</code>variable0, variable <code>&</code>variable1) {
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|