|
Hi, am building a GUI MFC application, I have several toolbars in my application, i want my toolbars to auto align according to my application frame width, the code i have been tried is given below. By this code the toolbar is simply align in a single row. what should i do to reach my goal? thanks in advance
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
tb1.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
tb4.EnableDocking(CBRS_ALIGN_ANY);
tb8.EnableDocking(CBRS_ALIGN_ANY);
tb9.EnableDocking(CBRS_ALIGN_ANY);
tb2.EnableDocking(CBRS_ALIGN_ANY);
tb3.EnableDocking(CBRS_ALIGN_ANY);
tb6.EnableDocking(CBRS_ALIGN_ANY);
tb7.EnableDocki:confused:ng(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&tb9);
DockPaneLeftOf(&tb8, &tb9);
DockPaneLeftOf(&tb4, &tb8);
DockPaneLeftOf(&m_wndToolBar, &tb4);
DockPaneLeftOf(&tb1, &m_wndToolBar);
DockPaneLeftOf(&tb7, &tb1);
DockPaneLeftOf(&tb6, &tb7);
DockPaneLeftOf(&tb3, &tb6);
DockPaneLeftOf(&tb2, &tb3);
A learner
|
|
|
|
|
Your intention is not totally clear, can you try and explain better what you are trying to do and what is not working ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Entropy isn't what is used to.
|
|
|
|
|
|
|
Another comment:
Is your toolbar CMFCToolbar ?
From MSDN: http://msdn.microsoft.com/en-us/library/cc665920.aspx[^]
This method (EnableDocking) extends the base class implementation, CBasePane::EnableDocking, by setting the CBasePane::m_dwControlBarStyle data member to AFX_CBRS_FLOAT. This method then passes dwAlignment to the base class implementation.
Maybe you would need the AFX_CBRS_RESIZE as well, see here in the base class:
http://msdn.microsoft.com/en-us/library/cc701911.aspx[^]
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Entropy isn't what it used to.
|
|
|
|
|
Yes am using CMFCToolbar, i have already checked with palette sample and EnableDocking();, they didnt help me i will attach the code i have tried for docking the toolbar
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
tb1.EnableDocking(CBRS_ALIGN_ANY);
tb2.EnableDocking(CBRS_ALIGN_ANY);
tb3.EnableDocking(CBRS_ALIGN_ANY);
tb4.EnableDocking(CBRS_ALIGN_ANY);
tb6.EnableDocking(CBRS_ALIGN_ANY);
tb7.EnableDocking(CBRS_ALIGN_ANY);
tb8.EnableDocking(CBRS_ALIGN_ANY);
tb9.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&tb1);
DockPane(&m_wndToolBar);
DockPane(&tb4);
DockPane(&tb8);
DockPane(&tb9);
DockPane(&tb7);
DockPane(&tb3);
DockPane(&tb6);
DockPane(&tb2);
|
|
|
|
|
Hello everybody,
I am playing with LibSDL and tried to use smart pointers for some of the objects created by the Library (i.E. SDL_CreateWindow returns a SDL_Window* which I would like to put into a std::shared_ptr<sdl_window>). For the rest of the post I will simple refer to SDL_Window but the same applies to other SDL objects.
The SDL_Window structure in the SDL header is a forward declaration for a simple structure without a destructor (plain old data) but there is a function called SDL_DestroyWindow which destroyes the SDL_Window and frees the allocated memory.
I use the following code to declare and initialize my smart pointer:
std::shared_ptr<SDL_Window> window(
SDL_CreateWindow( "Title", 0, 0, 640, 480, SDL_WINDOW_SHOWN ),
SDL_DestroyWindow
);
Now if I assign a nullptr to the initialized shared_ptr I get warning C4150 for deleting a pointer to the undefined or incomplete type SDL_Window but the SDL_DestroyWindow function gets called.
Am I doing something wrong or will I have to ignore this warning?
Thank you for your help,
Andreas
modified 7-Mar-14 14:40pm.
|
|
|
|
|
The warning is probably because of the forward declaration.
Look at the documentation - Compiler Warning (level 2) C4150[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
Hi!
I am sure the forward declaration is the problem because you cannot delete a forward declarated type. The compiler simply does not know if it has the call a destructor if it has not been declared.
But what I do not understand is why I get the warning if I supply a custom deleter. In this case the default delete (and therefor class destructor) should not be used by the shared_ptr template. If the last shared_ptr runs out of context it simply calls the provided custom deleter (which should know the full definition for the class it is deleting)
Thank you for your response, but it does not hit the mark.
However, I have found the problem (and the resolution) which I will explain in my next post.
Andreas
|
|
|
|
|
Hello again,
I now know what is causing the "problem" and will explain it.
Example code:
class MyIncompleteType; // forward declaration
std::shared_ptr<MyIncompleteType> y(myAllocate(), myFree);
y.reset(); // this works without warning (and calls myFree)
y = nullptr; // this gives me warning C4150
The second parameter to the shared_ptr constructor (myFree) is used to create a specialized a custom deleter template which calles myFree if the object pointed to by shared_ptr has to be deleted.
y.reset(); invokes the custom delimiter and sets the shared_ptr to empty (which is
y = nullptr; initialized the shared_ptr with a new pointer to an object uf MyIncompleteType which is actually nullptr, but a standard deleter is created which causes to C4150 warning because it would delete the object using 'delete' (which is not going to happen because the new pointer is nullptr).
So if you have to reset a shared_ptr of an incomplete type you simply have to use the reset() method.
Assigning a new value to the shared_ptr will also assign a new deleter and if you assign a nullptr it will be boxed and the shared_ptr created will use a default deleter which causes the warning C4150.
Andreas
|
|
|
|
|
Hi, in a modal dialog based MFC application, I use addFontResource() function to load font resource in application's InitInstance().
I want to use this font in all life of application.
when application ends, then release the font resource.
But I can't find the destructor of the modal dialog based MFC application, do I need to write it myself?
modified 7-Mar-14 11:15am.
|
|
|
|
|
See ExitInstance() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
It's a dialog based application, can't find
ExitInstance()
|
|
|
|
|
Override it, easiest done with the class wizard.
|
|
|
|
|
is that means CDialog class has a ExitInstance() member function? inherited from ,maybe a parent class.
I will check thhat
|
|
|
|
|
It means that your Application object (derived from CWinApp) has an ExitInstance() override.
|
|
|
|
|
Since you're adding the font in the application's InitInstance method, it would be properly matched if you release it in ExitInstance[^].
It would also work if done in the destructor of the dialog class, but ExitInstance would be cleaner.
The Visual Studio wizard does not normally output the dialog class destructor, but you could write one yourself as you would normally do and it will be called when the dialog class goes out of scope.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
|
I am a C++ programmer(based on Visual Studio-MFC, Win32). I have 3-year work experience, now i'm so confused when search jobs at monster.com. So many Android job chances, and very few Windows C++ jobs. And the salary of Android is much better than VC++.
To my dismay, Microsoft had fooled a lot of people, its technologies uupdated frequently and many of them are out of date, like Visual Basic, SilverLight, MFC, FrontPage, Expression Studio and so on.
So confused about my situation, should I learn Android or go on learning MFC/Win32 or Linux C++ development?
If should I learn Android, where should I start? How long will it take to make me a Anroid programmer?(If I want to find a Android job)
I want to hear your recommentations.
|
|
|
|
|
Hm... I'll give you Silverlight, but MFC and Visual Basic both lasted over a decade, which isn't too shabby in this business. MFC is still supported and developed, but far less used, these days. (If you want to work with GUIs on Windows, learn C#.)
Predicting the future is notoriously hard, and predicting what platforms will be around in five years isn't much easier (remember Symbian, which had close to 100% of the smartphone market?) so it's hard to give advice, especially since the smartphone/social media/online world is experiencing a nice bubble at the moment.
The main language used for Android development is Java, which means learning a new language and its libraries, as well as the quirks of the Android platform. How long did it take you to learn C++/MFC?
Of course, you can also develop for Android using C/C++, C# (via Xamarin's Mono), or JavaScript (via PhoneGap). As the latter two are evolving and improving, I'd say they are better bets, since they both are platform-independent. However, most Android jobs I've seen advertised have been for Java-based development.
In the end, it comes down to what you want to work with. If you enjoy C++, why not stick with it? It will be around for a good while yet.
|
|
|
|
|
thank you so much for the long response~ it's a good answer.
|
|
|
|
|
Falconapollo wrote: How long will it take to make me a Anroid programmer? I've been doing it for nearly fours year, and have barely scratched the surface.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
may i know your salary? PS: i'm from Beijing, China.
|
|
|
|
|
You're not confused, you're scared. Welcome to analysis - paralysis.
"So many Android job chances, and very few Windows C++ jobs. And the salary of Android is much better than VC++."
Why are we still talking? Go get a cheap tablet, there are numerous Android resources on the network, and I suspect a few getting started articles on CP.
You have 3 years of experience, many of us have 30+. If you want to do Android, do Android.
Charlie Gilley
<italic>You're going to tell me what I want to know, or I'm going to beat you to death in your own house.
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
excuse me, 30+? you mean 300k dollars per year?
I'm from China, work in Beijing.
|
|
|
|