|
thanks for ur reply,
use this code snippet
..........
static bool reg =false;
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
if( reg )
{
UnregisterClass(szWindowClass, hInstance );
}
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("Win32 Guided Tour"),
NULL);
return 1;
}
reg = true;
.............
|
|
|
|
|
Well thanks, but I'm not going to try that. I don't see the point of it. I'd rather have an explanation as to why I can't destroy a window and it's class and recreate it like an MDI Child Window.
|
|
|
|
|
Toolbar with treeview?
What kind of toolbar you are referring to? Are you sure you are creating a toolbar? Maybe it is a tool window?
Could you please post a snippet showing how you create this toolbar.
JohnCz
|
|
|
|
|
It's a tool window, I just called it a toolbar so folks got the bigger picture of what I was trying to do.
So far so good, I have my MDI frame, and the 2 sidebars (toolbars) on the left. They size correctly, move and resize upon mid resize. The hide and show works good.
Next phase is to dock them, but I need to tighten up the program first, and do an initial alpha test release. Hopefully this week.
|
|
|
|
|
I can do the following:
boost::scoped_ptr<MyClass> class;
class->DoSomething();
class.reset(new MyClass);
Doesn't it go against RAII? I keep reading that scoped_ptr is RAII but i can use object before it is initialized.
Thanks
|
|
|
|
|
and what happens when you run that?
|
|
|
|
|
He won't even get as far as compiling it, let alone running it
|
|
|
|
|
I got a segmentation fault, as expected.
Could you please explain.
|
|
|
|
|
you declared a pointer, but never pointed it to an object. what's to explain?
|
|
|
|
|
Is the purpose of RAII not to allow such a thing?
Currently i am acquiring a resource but do not initialize it.
|
|
|
|
|
elelont2 wrote: Currently i am acquiring a resource but do not initialize it.
but you're not acquiring any resource; you're just declaring an uninitialized pointer. the scoped_ptr c'tor allows you to defer allocation - but you do need to allocate it at some time, before you start using it.
look at boost's examples[^]:
boost::scoped_ptr<Shoe> x(new Shoe);
they allocate (acquire) the object while declaring the pointer.
also:
class MyClass {
boost::scoped_ptr<int> ptr;
public:
MyClass() : ptr(new int) { *ptr = 0; }
int add_one() { return ++*ptr; }
};
they declare the pointer, but defer allocation until the 'add_one' call.
|
|
|
|
|
So, apart from the fact you'll never be able to call an object class (naughty, naughty) how does writing:
boost::scoped_ptr<any_old_iron> ptr;
leave you with an unitialised object? Or in other words what's not initialised in that statement?
If you can work that out you'll see that scoped_ptr supports RAII (or as I prefer to call it these days scoped based resource management, SBRM) perfectly.
Cheers,
Ash
|
|
|
|
|
I have an uninitialized object in that case and ptr->Func() will probably crash?
|
|
|
|
|
ny_old_iron class will be uninitialized. How is it initialized?
Also, what do you mean by "object class"?
RAII says that the object is initialized during acquisition. scoped_ptr is supposed to support RAII but it allows to defer allocation, which means that the object pointed by the scoped_ptr is uninitialized.
Therefore i would say that scoped_ptr is not RAII.
|
|
|
|
|
When in the .net platform, it is easy to operate database, but when in the unmanaged c++,
how to operate the sql server 2005?
Can someone give me a example link?
|
|
|
|
|
|
you can connect your table to display in data format to make possible for it. So Sql(Sequence query language) to use,we do in edit,delete and update our data into the table.
|
|
|
|
|
I think the OP would be more interested in this information.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
As well as Richard's link if you do a search for ODBC you'll find (IMHO) the best interface to use databases through while programming in C or C++. While there are other methods to plug into databases ODBC has the advantage of being portable at both ends of the connection - so your C++ code can use any RDBS that has an ODBC connector AND your C++ code can be compiled on another compiler or operating system.
And instead of a concrete link I'd like to recommend a very good book - "Inside ODBC" by Kyle Geiger - instead. It's out of print but you can pick up cheap second hand copies on Amazon marketplace [1]. It's well worth a read and got me started on the rocky road to being an informed C++ DB programmer.
Cheers,
Ash
[1] At least you could 20 minutes ago when I recommended it as part of an answer to another question. I might have caused a run on them.
|
|
|
|
|
Dear All,
i'm beginner in c++ and I write template somethin like this :
template< class Type > class T1
{
bool MyMatch( int in )
{
return true;
}
public:
typedef bool (*T1<Type>::Match)( int in );
bool DoSomething( int& out, Match inConditionMethod )
{
return true;
}
};
but after compile i get this error :
error C2061: syntax error : identifier 'Match'
I google it and read MSDN but i can't find my mistake please help me to solve it.
sorry for my poor english
|
|
|
|
|
Should not be "MyMatch" ?
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Shahin_ke wrote: typedef bool (*T1<Type>::Match)( int in );
what are you trying to do here?
|
|
|
|
|
I try define something like delegate for compare two data in my template data. I need user can implement match and pass it to T1::Get(Match) and get find correct data and return it.
my original template more huge and complex and I minimize it to show the problem. I use the match typedef in Test project and it work good but when i need use it in my template i give this error.
thanks for your help
|
|
|
|
|
are you trying to add a member function to an existing class? (you can't do that in C++)
|
|
|
|
|
Check the way you've typedeffed the Match member function pointer, you've got the asterisk in the wrong place.
A pointer to a member function of A which takes a B as a parameter and returns a C is declared as:
C (A::*funct)( B );
So change your typedef to the same style and you're good to go!
Cheers,
Ash
|
|
|
|