|
This might make more sense to you:
#include <string>
#include <iostream>
using std::wcout;
using std::endl;
using std::wstring;
typedef wstring::iterator wciter;
int _tmain(int argc, _TCHAR* argv[])
{
wstring answer = L"telephone";
wstring guess = L"pXlXXXXnX";
// Make sure both strings are the same size.
if (answer.size() == guess.size()) {
wciter a = answer.begin();
wciter g = guess.begin();
while (a != answer.end() && g != guess.end()) {
if (*a == *g) {
wcout << *a;
}
else {
wcout << L"X";
}
++a;
++g;
}
}
wcout << endl;
return 0;
}
|
|
|
|
|
Help me, I need to create a CFormView class with CToolBar, but when update my CFormView, the toolbar disappears. I'm use a MainFrame with CSplittstWnd, so the my program use many CFormView as controls. Inside de CFormView, I call the CtoolBar in OnInitialUpdate;
What is the error?
part of source code:
void CForm2::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
if (!m_toolBar2.Create( this ) ||
!m_toolBar2.LoadToolBar(IDR_TOOLBAR2))
{
TRACE0("Failed to create toolbar2\n");
return; // fail to create
}
m_toolBar2.SetBarStyle(CBRS_ALIGN_ANY | CBRS_TOOLTIPS | CBRS_FLYBY);
WINDOWPLACEMENT wndPlmnt2;
m_ctrlTB1Holder2.GetWindowPlacement(&wndPlmnt2);
m_toolBar2.GetToolBarCtrl().SetWindowPlacement(&wndPlmnt2);
m_toolTip2.Create(this, TTS_ALWAYSTIP);
CRect rect;
m_toolBar2.GetToolBarCtrl().GetItemRect(0, rect);
m_toolTip2.AddTool(&m_toolBar2, ID_TB2_ONE, rect, ID_TB2_ONE);
m_toolBar2.GetToolBarCtrl().GetItemRect(1, rect);
m_toolTip2.AddTool(&m_toolBar2, ID_TB2_TWO, rect, ID_TB2_TWO);
m_toolBar2.GetToolBarCtrl().SetToolTips(&m_toolTip2);
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
//////////////
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
(...)
if (!m_wndSplitter3.CreateView(0,0,RUNTIME_CLASS(CForm2),CSize(cr.Width()-100,cr.Height()-100),pContext))
{
TRACE(_T("failed to create view in third pane"));
return FALSE;
}
(...)
Later, I do another call the other "CForm1", but I return to "CForm2", your toolbar disappers, undertand?
|
|
|
|
|
Hi All,
I'm writing a program, part of which needs to read text from a .log file in UNICODE line by line, then convert it to ASCII and write it to an ASCII .log file line by line...
I've been battling with this issue for a week, and have yet to find a solution.
PS: I'm writing in C
Thanks a lot
Alex
|
|
|
|
|
What about W2A() ?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'll research this, thanks...
|
|
|
|
|
|
thanks for the extra info i'll do more researc and let you guys know my progress in this matter
|
|
|
|
|
|
|
Where can I post my Java questions?
Java kinda resembles C++, so can I post it here?
Thanks.
"C++ will solve any problem."
|
|
|
|
|
#hackC++ wrote: Java kinda resembles C++, so can I post it here?
You can, but you won't get very many responses ... and quite likely will get yelled at for doing so.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I'm trying to use a string as a parameter for CreateWindowEx and I'm getting compile errors. Firstly I was just casting it to a LPCWSTR as this was what the compiler error message was reported. This wasn't working as I was also casting from Ascii to UNICODE. _T() sorted that out. But I can't get _T() to work when I'm using a std::string. When I try and compile this code:
HWND hWnd = CreateWindow( _T("Barry's D3D BaseClass"), _T(windowName),
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,GetDesktopWindow(),
NULL, windowClass.hInstance, NULL );
gives the following error:
c:\documents and settings\barryod\my documents\visual studio 2005\projects\directx1\directx1\directxbase.cpp(38) : error C2065: 'LwindowName' : undeclared identifier
I'm not sure why its generating the LwindowName identifier, I've tried the .c_str function but that doesn't work either. Any help would be really appreciated.
|
|
|
|
|
If you are trying to write code (using the STL string) that will be compilible on both ANSI and UNICODE builds, you need to do a little work:
#ifdef UNICODE
typedef wstring tstring;
#else
typedef string tstring;
#endif
There are a few other classes you may want to do the same thing for. Basically, what you will want is to use wstring when building with UNICODE, and string when building ANSI.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Thanks for the reply, I've added the above #ifdef to the header file of the class I'm trying to call this method in and in the .cpp file as well but neither seemed to have an affect. _T(windowName) still throws the LwindowName undeclared identifier and windowName used directly as a parameter throws this:
c:\documents and settings\barryod\my documents\visual studio 2005\projects\directx1\directx1\directxbase.cpp(49) : error C2664: 'CreateWindowExW' : cannot convert parameter 3 from 'std::string' to 'LPCWSTR'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Am I doing something wrong or is there anything else I have to do?
|
|
|
|
|
Assuming windowName is the name of your tstring variable, you don't need the _T() macro. Just call it using windowName.c_str() .
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
That works! thanks buddy. I was still declaring it as a string doh .
|
|
|
|
|
|
Hello,
I am looking for dowloading a ActiveX DataGrid control 6.0. Where can I found the possibility to install this ActiveX because on the computer where I want used this control it is not present and the application cann not start.
thank you for your help!
AutreChien
|
|
|
|
|
Hello All,
A few quick questions that i would really appreciate some answers on:
The standard template library vector (i.e. vector<myobjec> myVector) - can you double subscript it (i.e. myVector[2][3])?
Do vectors (again from the STL) inherently allocate dynamic memory (the more abundant kind)? In other words, if I use the pushback() method, is the vector allocating that memory dynamically on the heap (or free-store)?
Thanks, any help or advice would be great.
Have a great day.
Peace,
BP
|
|
|
|
|
BlitzPackage wrote: can you double subscript it (i.e. myVector[2][3])?
No
BlitzPackage wrote: if I use the pushback() method, is the vector allocating that memory dynamically on the heap (or free-store)?
Yes, when required but normally not for every push_back()
http://www.sgi.com/tech/stl/Vector.html[^]
"I've found that the shortcomings of human nature have little to do with nationality." Christopher Duncan in the Lounge
led mike
|
|
|
|
|
|
BlitzPackage wrote: The standard template library vector (i.e. vector myVector) - can you double subscript it (i.e. myVector[2][3])?
Yes. You just declare it this way:
vector< vector<int> > myVector;
This creates a 2 dimensional array of integers.
BlitzPackage wrote: Do vectors (again from the STL) inherently allocate dynamic memory (the more abundant kind)? In other words, if I use the pushback() method, is the vector allocating that memory dynamically on the heap (or free-store)?
The memory that vector/list/deque/heap/stack/map/set/etc use is on the heap. It allocates and manages it so that you don't have to. Almost all of the STL containers allocate a default size (or a grow-by depending on the type of container) to optimize allocations. They also typically do not resize smaller (so resizing a vector to a smaller size will not free up any memory).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
cheater I was thinking technically... no [][] operator.
"I've found that the shortcomings of human nature have little to do with nationality." Christopher Duncan in the Lounge
led mike
|
|
|
|
|
You must learn to look passed the surface to the true meaning of the question, young padawan
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|