|
if you have the start and end indexes the use Mid()
str.Mid(start, end-start);
|
|
|
|
|
int begin = str.Find(char_begin);
int end = str.Find(char_end);
return str.Mid(char_begin + 1, char_end - char_begin - 1);
Robert-Antonio
"Life is very hard, if you apply E-R model to it."
|
|
|
|
|
I'm leaning English.I'm Korean.
I need that oldeDB use programming.
DB:MS-Access
language: visual C++ 6.0
I need sample code.
|
|
|
|
|
Check out the OLE-DB samples in MSDN, and the ATL support for OLEDB in ATLDBCLI.H
along with the online documentation for them.
They aren't (or should not be) specific to MS ACCESS, and have the advantage that they are reasonably lightweight compared to ADO.
Steve S
|
|
|
|
|
I am working on an on-screen keyboard replacement for Tablet PC's. I am using SendInput to send the characters. This works fine with "normal" windows. However, if a console window has the focus, it gets no output. I know that this can be done because the On-Screen Keyboard that comes with Windows XP does it. Can anyone point me in the right direction.
Thanks,
Dave
|
|
|
|
|
Check out MSDN.
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q190/3/51.asp&NoWebContent=1
Kuphryn
|
|
|
|
|
|
I have an application where I need to access the doc page and put data there from a function that is part of the mainframe.cpp file. I know how to access the doc page from the view...but I am not doing that in this application.
Also, can someone show me a simple SDI or MDI program where I can pass messages between classes, using handles to a class...forward referencing , etc, as is done in a typ C++ program with a main().
Thanks.
jerry1211a
jerry1211a
|
|
|
|
|
Hi jerry
here is the code to access doc page from mainframe.cpp
/////////////////////////////////////////////////////////////
//get main wnd handle
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
// Get the active MDI child window.
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
// or CMDIChildWnd *pChild = pFrame->MDIGetActive();
// Get the active view attached to the active MDI child
// window.
m_pView = (CTDGView *) pChild->GetActiveView();
m_pDOC = m_pView->GetDocument();
///////////////////////////////////////////////////////////
this code can be used from any part of the application to access a document.
Hope this helps
thanks
Krithika
|
|
|
|
|
I am having problem setting a dirty flag to a record (CRecordset). I am adding controls to the interface so that no updating to the database is allowed if the form has already been approved. So I did something like the code below. However, I always get the dialog saying "field is still dirty, do not know why". I am not expecting to see this dialog.
m_pSet->Edit();
m_pSet->UpdateData(TRUE);
if (m_pSet->IsFieldDirty(NULL))
{
If (m_pSet->m_is_approved == "1")
{
//reset the dirty flag
m_pSet->SetFieldDirty(NULL, FALSE);
AfxMessageBox("no updating is allowed on an approved application.");
if (m_pSet->IsFieldDirty(NULL) )
{
AfxMessageBox("field is still dirty, do not know why");
}
}
}
m_pSet->Update();
Elizabeth
|
|
|
|
|
Hi!
I've done a new Dialog Box in my application that appears when the user clicks a button in the main window. I need to know if the user has clicked one button in that Dialog box but I don't know how could I check this. I can check edit boxes or Radio Buttons if I see Dialog Box's int variables values from my main window code but I don't know what could I use for checking if buttons have been clicked or not. May I use a control variable or what could I do?
Thank you in advance!
|
|
|
|
|
All u need to do is create a member variable a bool type and set it true when the user has clicked on the desired button. Now that variable button has the state. You can either pass it as a parameter to the child window or read the value from the child window.
Hope this helps.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Yes, it's perfect. Thank you
|
|
|
|
|
I recently upgraded to Visual Studio 2003 from a version of Visual Studio .Net that is a few years old. After doing so, I converted an old (working) project file to the new version and tried to build.
I'm getting various versions of the same error, and I have no idea what's wrong. My only guess is that it has something to do with the inheritance from std::allocator in class_allocator. I realize its a rather long mess, but this is the first error straight from the build log.
Here's the error, which is basically repeated in various ways about 2000 times:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\map(25) : error C2248: 'class_allocator<type,blockCount,alignment>::rebind<U>::other' : cannot access inaccessible typedef declared in class 'class_allocator<type,blockCount,alignment>'
with
[
type=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>::value_type,
blockCount=256,
alignment=8,
U=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>::value_type
]
and
[
type=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>::value_type,
blockCount=256,
alignment=8
]
..\clientCommon\Allocator.h(76) : see declaration of 'class_allocator<type,blockCount,alignment>::rebind<U>::other'
with
[
type=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>::value_type,
blockCount=256,
alignment=8,
U=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>::value_type
]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xtree(23) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled
with
[
_Kty=UString,
_Ty=ResObject *,
_Pr=std::less<UString>,
_Alloc=class_allocator<std::pair<UString,ResObject *>>,
_Mfl=false
]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xtree(65) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>
]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xtree(87) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>
]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xtree(105) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>
]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\map(77) : see reference to class template instantiation 'std::_Tree<_Traits>
' being compiled
with
[
_Traits=std::_Tmap_traits<UString,ResObject *,std::less<UString>,class_allocator<std::pair<UString,ResObject *>>,false>
]
Shell\ResPool.h(71) : see reference to class template instantiation 'std::map<_Kty,_Ty,_Pr,_Alloc>' being compiled
with
[
_Kty=UString,
_Ty=ResObject *,
_Pr=std::less<UString>,
_Alloc=class_allocator<std::pair<UString,ResObject *>>
]
Here's the relevant code:
template< class type, size_t blockCount = 256, size_t alignment = 8 >
class class_allocator : public std::allocator<type>
{
public:
// All of this weirdness is required to make it stl compatible
template <class U> struct rebind { typedef class_allocator<U,blockCount,alignment> other; }; //!< Allow containers to manufacture notes containing node+this
template <class U> class_allocator(const class_allocator<U,blockCount,alignment>&) {} //!< Whatever sort of constructor, this eats them all to provide compatibility
class_allocator() {}
static type* allocate( size_t count = 1, void* = NULL ) { return (type*)pool_allocator<type, sizeof (type), blockCount, alignment>::allocate( count * sizeof (type) ); }
static void deallocate( void* p, size_t = 0 ) { pool_allocator<type, sizeof (type), blockCount, alignment>::deallocate( p ); }
static size_t GetBlockCount() { return pool_allocator<type, sizeof (type), blockCount, alignment>::GetBlockCount(); }
static size_t GetFreeCount() { return pool_allocator<type, sizeof (type), blockCount, alignment>::GetFreeCount(); }
static size_t GetInstanceCount() { return pool_allocator<type, sizeof (type), blockCount, alignment>::GetInstanceCount(); }
};
Does anyone have any idea what's wrong? If not, does anyone have any idea where I could look to find out?
Thanks,
Jon McClure
|
|
|
|
|
My first instinct on looking at the allocator was that most custom allocators I've seen don't inherit from std::allocator, and my second was that maybe throwing in a couple of 'typename's might make the problem go away - but that's a big guess - if my template code gets complicated enough to warrant that I've generally looked for a different approach .
I went through my bookshelf and found some material on writing custom allocators in:
"The C++ Standard Library: A Tutorial and Reference" - Nicolai M. Josuttis (good basic reference)
"Modern C++ Design" - Andrei Alexandrescu (Fixed size allocator + tricks)
"The C++ Programming Language" - Bjarne Stroustrup (pool allocator)
But you're right though, there isn't much good stuff on writing allocators.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Message Removed
modified 29-Jun-21 16:11pm.
|
|
|
|
|
I have a simple function:
void Cell::SetNumber ()
{
cout << "enter";
number= 1;
cout << "exit" ;
}
I get a segment fault after the "enter" prints, and it never seems to leave the routine.number is just an int. What should I suspect?
thanks,
ns
|
|
|
|
|
|
nope. Just using cout.....
|
|
|
|
|
is it possible that the Cell object is not valid ? or the "number" object ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
This is the hundredth time I have made this same mistake.....I say MyClass * ptr, and then blithely do a ptr->method() on it, without having allocated memory which I think is what the problem is here.
Many thanks.
ns
|
|
|
|
|
How is number declared? Could you show more code?
Robert-Antonio
"Life is very hard, when you apply E-R model to it."
|
|
|
|
|
Here's another combo box question for everybody. I have seen some applications where the dropdown menu of a combo box is partitioned into columns separated by a vertical line. How do I create this separate columns, and how do I fill them once they are created? Thanks a ton!!!
|
|
|
|
|
|
In order to use Hadi's suggestion, you'll first need to ensure that the sub dialogs were created with a parent. Otherwise, you'll get the desktop as a parent, ensuring unexpected results!
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|