|
|
I have 2 flexHgrids in my application. now i need to loas the data from a text file delemiter as semicolon
Now in the text file the format is as follows
first flex grid 2nd flex grid
1;2;4;1;45;1;4;1;3; 1;2;4;1;3;4;1
both are on the same line. how do i do that? i can do the first one. but how do i check for the second string and display it on the second flexgrid?
|
|
|
|
|
it seems the first ad second dataset is seperated by space, you may use
string::getline with delimiter space to read upto first data set or after reading complete string separate the string using any of the string functions like Tokenize, Find, Mid ...
|
|
|
|
|
Can we delete CFont object which is created in OnintDilaog() itself after doing SetFont to corresponding controls in dialog???
|
|
|
|
|
Nope.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
No, if you delete the CFont, then your font won't be updated.
See this article[^] for more info (BTW, that was the first result in google when searching for SetFont).
|
|
|
|
|
Yes you can. But the results may not be very appealing as you are destroying the font object prematurely. Why not just do a little test?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Yes I had done a test, even though after deleting its working fine. From where is it referring even after deletion?
|
|
|
|
|
Super Hornet wrote: From where is it referring even after deletion?
Turn your monitor East so that I can see it. But then CPallini, Cedric, David, and all others won't be able to see it.
So, show us your code.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
But the article refered by cedric clearly tells we shouldn't delete.
Here is my code:
BOOL NcEventArrhythmiaOnDlg::OnInitDialog()
{
NcEventSpecificDlg::OnInitDialog();
LOGFONT lf;
GetFont()->GetLogFont(&lf);
lf.lfHeight = -16;
lf.lfWidth = 0;
CFont* pFont = new CFont;
pFont.CreateFontIndirect(&lf);
GetDlgItem(IDC_ARRHYTHMIA_ONSET_TIME)->SetFont(&pFont);
GetDlgItem(IDC_ARRHYTHMIA_ONSET_INFO)->SetFont(&pFont);
GetDlgItem(IDC_CYCLE_LENGHT)->SetFont(&pFont);
GetDlgItem(IDC_ARRHYHMIA_UNIT)->SetFont(&pFont);
pFont->DeleteObject();
if(pFont != NULL)
{
delete pFont;
pFont = NULL;
}
return TRUE;
}
|
|
|
|
|
Super Hornet wrote: GetDlgItem(IDC_ARRHYTHMIA_ONSET_TIME)->SetFont(&pFont);
GetDlgItem(IDC_ARRHYTHMIA_ONSET_INFO)->SetFont(&pFont);
GetDlgItem(IDC_CYCLE_LENGHT)->SetFont(&pFont);
GetDlgItem(IDC_ARRHYHMIA_UNIT)->SetFont(&pFont);
How can the above lines work?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Super Hornet wrote: CFont* pFont = new CFont;
pFont.CreateFontIndirect(&lf);
This code won't compile.
And this too:
Super Hornet wrote: GetDlgItem(IDC_ARRHYTHMIA_ONSET_TIME)->SetFont(&pFont);
GetDlgItem(IDC_ARRHYTHMIA_ONSET_INFO)->SetFont(&pFont);
GetDlgItem(IDC_CYCLE_LENGHT)->SetFont(&pFont);
GetDlgItem(IDC_ARRHYHMIA_UNIT)->SetFont(&pFont);
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Super Hornet wrote: But the article refered by cedric clearly tells we shouldn't delete.
From the article:
Do not destroy the specified CFont object until after the CWnd control has been destroyed. Windows does not copy the font specified in a SetFont() call. If the font is destroyed before the control is destroyed, unpredictable results can occur.
Well, you wouldn't want the program to work only your computer, but not on the client's. You wouldn't want your program to behave in an unpredictable manner, do you?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
So finally decided not to delete it in OnintDialog().
|
|
|
|
|
Super Hornet wrote: So finally decided not to delete it in OnintDialog().
Ah - finally I got you convinced to do it the right way.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Leakfinder shows memory leak in ADORecordset::Getfieldvalue function
the function is called in a loop on a separate thread.
BOOL CADORecordset::GetFieldValue(LPCTSTR lpFieldName, _variant_t& vtValue)
{
try
{
vtValue = m_pRecordset->Fields->GetItem(lpFieldName)->Value; <-leak
return TRUE;
}
catch(_com_error &e)
{
dump_com_error(e);
return FALSE;
}
}
c:\My Projects\PCSRecord_Plus\Code\Shell\LeakFinder.cpp (903): CMallocSpy::PostAlloc
77573015 (ole32): (filename not available): void * __stdcall CSpyMalloc_Alloc(struct IMalloc *,unsigned long)
77114B52 (OLEAUT32): (filename not available): public: void * __thiscall APP_DATA::AllocCachedMem(unsigned long)
77114C7F (OLEAUT32): (filename not available): _SysAllocStringByteLen@8
77114CF0 (OLEAUT32): (filename not available): _ErrStringCopyNoNull@8
7713D325 (OLEAUT32): (filename not available): _VariantCopy@8
c:\program files\microsoft visual studio\vc98\include\comutil.h (1295): _variant_t::operator=
c:\My Projects\PCSRecord_Plus\Code\Client\ADORecordset.cpp (968): CADORecordset::GetFieldValue
what do you think?
|
|
|
|
|
VariantCopy does not frees memory allocated at destination, you need to do that. Problem is , if you are running this function in loop, and using same variable for getting field value for each item in loop, you will definitely leak memory. You need to clear it first. Have a look at VariantCopy[^].
Just to add, VariantCopy is used in assignment operator / copy c'tor of _variant_t .
|
|
|
|
|
thanks for the reply.
I tried that already. Nothing changes.
BOOL CADORecordset::GetFieldValue(LPCTSTR lpFieldName, _variant_t& vtValue)
{
try
{
vtValue.Clear();
vtValue = m_pRecordset->Fields->GetItem(lpFieldName)->Value;
return TRUE;
}
catch(_com_error &e)
{
dump_com_error(e);
return FALSE;
}
}
I also tried clearing the vtValue in the calling function before GetFieldValue, same thing.
|
|
|
|
|
Is the value you are tring to assing is CString ?
It looks like , you are facing similar situation, I faced in past.
Refer, this[^] post.
Though, I never got satisfactory answer.
|
|
|
|
|
Well, I'm using the _variant_t class to have a general solution for getting the values from the recordsetfields, but yes most of the times they are strings, but at that point of the execution I didn't converted them to CString.
I also tried without using _variant_t, using VARIANT and BSTR and _bstr_t. Though the place changes I still have memory leaks somewhere.
I also have issues with CString Allocbuffer.
I'm close to pulling my hair one by one. Have been playing with this for weeks now.
These functions are called on a separate thread, I'm using a jobmanager class I wrote. What I was thinking about lately it might by due to threading issues. Or is it general, but others haven't noticed yet?
I should build a single threaded test program.
|
|
|
|
|
How can I programatically remove a member from the Administrators group?
For your reference :
In Win XP, the Administrator members are accessible through Right click
'My Computer' -> Manage -> Computer Management (Local) -> System Tools ->
Local Users and Groups -> Groups -> Administrators (Double click)
Thanks in Advance
|
|
|
|
|
I wrote the following vb script which removes a specific user from a domain
strDomain="XYZ"
strUser="TestAdminUser"
strGroupName ="Administrators"
Set oDomain = GetObject("WinNT://" & strDomain)
Set oGroup = oDomain.GetObject("Group", strGroupName)
oDomain.Delete "user", strUser
Set oDomain=Nothing
Set oGroup=Nothing
The following code snippet deletes specific user from a group
strDomain="XYZ"
strUser="TestAdminUser"
strGroupName ="Administrators"
Set oDomain = GetObject("WinNT://" & strDomain)
Set oGroup = oDomain.GetObject("Group", strGroupName)
Set ouser = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
oGroup.Remove(ouser.ADsPath)
Set oDomain=Nothing
Set oGroup=Nothing
But, could the above code be replicated in VC++ ?
I've used ShellExecute() to integrate (or run) the vbscript (.vbs) file in VC++ 6.0 code (or programming) ?
Is there a better way ?
|
|
|
|
|
Hi All,
I want to write an application that runs in the background and does not bring up any kind of UI (Not even the command prompt). How can I achieve this?
Thank you,
AJ
|
|
|
|
|
Creating window in Invisible mode can achieve this .
|
|
|
|
|
Hi,
Any idea how I could do this in a command line application?
Thank you,
AJ
|
|
|
|