|
I think you want to cutomize your controls like buttons,treectrls and... so you can derived your class for example you can derived your class of CButton.See Creating Custom Controls[^] for more info.
|
|
|
|
|
hi
i am having a char* which have a '\0' EOS as a data
problem is the data after this '\0'EOS is not assigned to CString object.
when i assign this char* to CString the data after '\0' EOS is not available in the CString object.
where i go wrong ? or is there any other method to do so ?
please help
Thanks,
|
|
|
|
|
Well of course, this character is the end of string character so CString will detect the end of the string because of this character.
|
|
|
|
|
One of the CString constructors takes a char * pointer and a character count. I'm not sure, but that one may allow embedded nul's in the string.
|
|
|
|
|
Well, use a CArray (or better) a std::vector instead of a CString object.
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
[My articles]
|
|
|
|
|
My project is SDI that first view is CFromView derive class.
Then I add second view with CScrollView derive class.
In this view I want to print out the data So I add this function
BOOL CReportView::OnPreparePrinting(CPrintInfo* pInfo)
{
CPrintDialog *dlg = new CPrintDialog(FALSE, PD_PAGENUMS);
pInfo->m_pPD = dlg;
pInfo->SetMinPage(1);
pInfo->SetMaxPage(1);
return DoPreparePrinting(pInfo);
}
while I run this function I got exception error at
BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
in file "dlgcore.cpp"
BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
ASSERT(IS_INTRESOURCE(lpszTemplateName) ||
AfxIsValidString(lpszTemplateName));
m_lpszTemplateName = lpszTemplateName;
if (IS_INTRESOURCE(m_lpszTemplateName) && m_nIDHelp == 0)
m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);
#ifdef _DEBUG
if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))
{
Error Here >>>> ASSERT(FALSE);
PostNcDestroy();
return FALSE;
}
#endif //_DEBUG
HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
HGLOBAL hTemplate = LoadResource(hInst, hResource);
BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);
FreeResource(hTemplate);
return bResult;
}
Please help me to solve this problem
|
|
|
|
|
Hi
I have declared static vectors in a function that i call multiple times:
static map<HWND, myVector<CString>> myMap;
On some of the function calls i want to remove elements from a vector:
myMap[hWindow].erase(iterator)
where iterator pointers to the element in the array I want to remove.
when I call myMap[hWindow].size() after erasing this element the size is the same as before??
Is this a consequences of using static vectors. Or am I doing something wrong?????
More likely option 2 but wanted to check with some one who knows more about this stuff.
Many thanks
|
|
|
|
|
steph5 wrote: Is this a consequences of using static vectors.
I don't think so.
steph5 wrote: Or am I doing something wrong?
I think so.
I tried this:
HWND hWindow = (HWND)1234;
static std::map <HWND, vector <CString>> myMap;
typedef pair <HWND, vector <CString>> myPair;
vector <CString> myVector;
myVector.push_back(_T("string 1"));
myVector.push_back(_T("string 2"));
myVector.push_back(_T("string 3"));
myMap.insert(myPair(hWindow, myVector));
vector <CString>::size_type sizeBefore = myMap[hWindow].size();
vector <CString>::iterator iterator;
iterator = myMap[hWindow].begin();
myMap[hWindow].erase(iterator);
vector <CString>::size_type sizeAfter = myMap[hWindow].size();
sizeBefore is 3, sizeAfter is 2.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
great got it working
thanks for your help
|
|
|
|
|
I am trying to use STL within a library to make portability to linux easier in the future.
So, what is the best alternaive to sprintf ?
Thanks.
|
|
|
|
|
There's no real alternative to sprintf !
Anyway you may use the output manipulators [^] on a strstream [^] object.
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
[My articles]
|
|
|
|
|
I think strstream is deprecated and you should use stringstream.
-Saurabh
|
|
|
|
|
You're only partially right, while strstream usage is deprecated because it supports only char * objects, i.e. C -like strings, the proposed alternative is sstream and not stringstream .
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
[My articles]
|
|
|
|
|
You're also only partially right
sstream is the name of the header file, which contain the following:
Classes
basic_stringbuf
basic_istringstream
basic_ostringstream
basic_stringstream
Typedefs
istringstream
ostringstream
stringbuf
stringstream
wistringstream
wostringstream
wstringbuf
wstringstream
-Saurabh
|
|
|
|
|
Touché.
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
[My articles]
|
|
|
|
|
You can use stringstream for that, it supports formatting and once you are used to it, it is much better than sprintf (better type safety also). Our great Christian wrote an article about it here[^].
|
|
|
|
|
Here is another suggestion.
"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
|
|
|
|
|
Hello Team,
I am thinking of a sw which can help the people who does the lot of presentation.
Normally when we beam thru the projector from the laptop, everything on the laptop will be visible to the user. we cant use Alt+Tab while presenting.
Thinking of writing a software, thru with ppl will present their presentation and in background they can browse other think in the pc !
can we send output to VGA card using VC++ /MFC?
Thank you
|
|
|
|
|
Instead of writing software, set the VGA output as a second desktop.
|
|
|
|
|
Hello ,
Thank you for the respose. I am using winxp OS. can i know how to get this second desktop in win Xp?
Thank you
|
|
|
|
|
I have an MDI application with 3 CMFCToolbars. When I resize the main window, these toolbars are wandering around the top of the screen of their own accord for no apparently good reason.
Has anybody got any ideas what's causing this and preferably how to stop it as well?
|
|
|
|
|
An app built from the app wizard doesn't exhibit this behavior.
What are you doing different with your toolbars?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Nothing is intentionally different from the code appwizard creates.
It looks like I'm confusing one of the CMainFrame default handlers somehow, I'm just not quite sure where to start looking to fix it and I was hoping someone else had made a similar mistake and could point me in the right direction.
|
|
|
|
|
Hello everyone,
This is what I found when reading atl/com internal implementation code (e.g. ATLCOM.h), for example in the definition of VARIANT. I show similar code segment below.
I think the purpose of such struct definition is, defining struct and a variable of the type (in this sample type tFoo) altogether, any other benefits of using such type of definition?
(I have such question is because I always use typdef to define a struct type, and then using a separate statement to define a vraible of the type, not merge type definition and variable definition together.)
struct tFoo
{
int abc;
} Foo;
int main()
{
Foo;
return 0;
}
thanks in advance,
George
|
|
|
|
|
It's a pretty old school but perfectly valid way of doing things. You see a lot of this in 'C' code. I expect this gets used mostly where the type, tFoo, is not likely to be used again, it's just a one off definition to define Foo as a single entity. It's a style thing rather than anything technical, there's quite a bit of that on the boundary of C and C++ where backward compatability opens up the syntax for a few of the wierder elements from C.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|