Is there a JPanel equivalent for MFC - visual-studio-2010

Im my application I want to implement the feature of when a user click on a button show a Panel which will consist of some user controls. I know In Java I can easily use Jpanel and use setVisible() method to get this done easily. But this is an MFC application. I couldn't find any built or customized component that I can use for my purpose.
I also tried GroupBox. But it is not grouping the components logically.
What would be the best approach for this?

As user1793036 says, start by creating a dialog resource and CDialog derived class for the panel. In the dialog resource properties turn off the Title Bar style. In the code call Create for the dialog and then SetWindowPos to place it where you want it to appear.

MFC is nothing but a thin wrapper over Win32 API for windows and controls. The core Win32 API doesn't provide any feature to group controls in a group-box or panel. One way is to have a window and make that window parent of all required controls. Unfortunately, this isn't easy to do.
I suggest you, since you are learning, to drop the idea. Instead, learn what you can achieve with existing set of features provided by MFC/Win32. With MFC/Win32, you would, mostly need to derive/subclass a class/window to get something fancy (such as colored list-control).

Related

MFC:CDHtmlDialog Purpose/Usages to open other views?

I was thinking of writing a new app where a users selects an option of what procedure they want to perform and the view changes to that until done then goes back to the main menu. I came across CDHtmlDialog and looked like a nice easy way to add a nice looking menu using html. But I wonder if that is the purpose of that class? Can I set it up so when a button or graphic link is clicked it changes out the view to another one (I would need to use traditional things like CTreeView with CListView with a splitter) or is it more for staying within the HTML world?
Thanks.
From the MSDN MSDN documentation
CDHtmlDialog Class is used to create dialog boxes that use HTML rather than dialog resources to implement their user interface.
From what I can gather from your post, I think you should consider SDI application using view classes that you want. To switch views on the command you do not need a splitter window. A static splitter is used to display a number of views in a different part of the splitter simultaneously.

How to create a view for a single control?

What is the best way to create a view for a single control that I need to load into a Shell region in a Prism app. I know I can wrap the control in a UserControl, but I suspect there may be a better way.
I am working on a demo app to learn Prism 4. Each module will load a navigation button into an ItemsControl in a region in the Shell. These navigation buttons will function like the Mail, Calendar, and other buttons in Outlook.
I am creating the view in each module that will hold the module's navigation button. The simplest way to create the view seems to be to wrap it in a UserControl. My question is this: Is there a better way to do it? Thanks for your help.
If you need graphical control, what you are doing is the way to go. If you find yourself making all of the buttons look the same (copy - pasting) you might find that a menu registration service is the way to go.
You'd have a service like IMenuService that you register with your container and modules can come around and register menu items to. You can then create buttons for the module. I've provided a sample for this here:
http://dl.getdropbox.com/u/376992/CAGMenus.zip
Your question, though, seems to be about whether or not you need to wrap a control in a UserControl to register them with a region? If that's the question, I believe the answer is no, although you might amend your question to tell us what you are running up against that makes you think this.
I ended up wrapping the control in a UserControl, and it seems to work fine. I am still interested in seeing if there is a better way to load the button, so I will hold this question open for a few days.
Edit 02/22/2011: I tried using a control without a UserControl wrapper, and I got the following error:
Library project file cannot specify ApplicationDefinition element.
I wrapped the control in a UserControl and the error went away.

Win32 textBox in treeview

I want to add textbox in treeview as child of one of the parent node. Is it possible> If yes how to achieve this?
The native TreeView control isn't going to be helpful at all to make this work. Programming one yourself is a tricky proposition. It is however a very popular UI gadget. Any component vendor sells one, invariably called "TreeList".
You'll have to do some shopping if you want to use such a component from unmanaged C/C++. An ActiveX version of such a control is as close as you can get. Most component vendors have however put that in their legacy bag.
Depending on your requirements, you may be able to use the built-in label editing features of the Win32 tree view. See TVM_EDITLABEL.
To make an item act like an edit control, you could send this message yourself when the item is clicked. You could also use owner-draw techniques to make the item look more like an edit control when it isn't in label-editing mode.

Best practices of building composite custom controls WPF

Can You tell me about subj?
For example I need to create new custom control that must be derived from datagrid and toolbar. And I want that new control to expose/propagate properties of base controls in order they to be accessed easily. The only way I know is deriving a class. Then descendant automatically gets all properties of ancestor. But multiple deriving in C# is prohibited, so I don't know how to expose properties and other behavior of second control... Styling and templating of such custom control is also needed.
Thanks!
In WPF inheritance is "out". ;O) Actually, it was complicated before WPF already, but with WPF you get various really powerful alternatives.
For the basic control I thing you'd better go with composition, create some usercontrol and make it contain a ToolBar and a DataGrid. You can then expose these as public properties, if you need to manipulate them from outside.
For special feature additions, attached properties are a very versatile mechanism.
Watching a window from windowsclient.net is a good place to start.
Make sure you understand dependency properties well.
Reading wpf blogs is my best guest for what to do then.

How to derive class from CFindReplaceDialog? (MFC)

Is it possible to derive custom-built dialog from CFindEditDialog? I want to build a dialog template in Viasual Studio Resource Builder (to draw it), then to hide the default Find dialog window and to use my instead.
MSDN says:
To customize the dialog box, derive a
class from CFindReplaceDialog, provide
a custom dialog template, and add a
message map to process the
notification messages from the
extended controls. Any unprocessed
messages should be passed to the base
class.
Customizing the hook function is not
required
Has anyone had any experience with this?
While I don't have direct experience with this (but close others), it is quite possible and should be easish. Most of the messages will be implemented virtually, so you mearly need to override the ones you're interested in with code you add.
Code project has an artical that talks about CFindEdit. It might be helpfull
http://www.codeproject.com/KB/cpp/Media_PlayerByyazan_nemer.aspx
If you take a look at the oninitialize event for an of your dialogs, you should see how events are worked into inherited classes.

Resources