How do I best share an embeddable form in VB6? - forms

Is there a good way to create a form in VB6 that can easily be embedded inside other forms?
On a few occasions recently, I've wanted to design and code a Form object that I could plug into several other "parent" forms. My goal is to create a centralized piece of code for managing several UI components in a particular way, and then be able to use that (both the UI layout and the logic) in more than one place. I'm certainly willing to use code (rather than the Design View) to load the child form.
The best I've come up with so far is to pull all of the interesting logic for the child form into a Class Module, and have each parent form lay out the UI (in a Picture control, perhaps) and pass that Picture object into the class module. The class then knows how to operate on the picture, and it assumes that all its expected pieces have been laid out appropriately. This approach has several downsides, and I'd like something a bit more elegant.

Take a look at VB6 UserControls; I think they are exactly what you need. You can create a UserControl within your project, add controls and code to that control, and then insert it onto a form just like standard VB6 controls. I've used UserControls to share UI layouts on many occasions and it works great.

Related

Binding to custom built control according to different data

Here's the issue, I build a special book reader/browser (For holy quran), my code behind loads the page and constructs how it should look. and then it should bind that look to a some kind of data-bindable custom control to view it properly. the problem is, the look differs from page to page, so I cannot bind to a certain control or wrap panel.
here's how it generally looks:
The decorative border top of the page is always there at any page, it indicates the part and chapter the viewer is in.
If you're starting a new chapter it have additional image under that decorative border or anywhere in the page (there can be multiple chapters in the same page) something like this
or this:
The normal text is not an issue, it's just a special font, however, I put each individual word in its own text block for reasons of user selection by word.
The issue here is, given the previous information, and knowing how random it is to place the decoration picture or the amount of words (text blocks) per page. how can I bind that to some kind of view to separate the view from the VM and Engine that builds the page.
my past solution was to actually build everything in the VM in a wrappanel built inside a scrollviewer having lots of textblocks and images according to the page. but that's naiive solution. I want to rebuild that in a more professional separated way. I also want to do this for Windows RT beside Windows phone so I need to reuse the code behind in a Portable class library.
I think all you need to do is slightly adjust your current design. So perhaps have a VM that represents the entire content, and that would have a Collection of say Pages or Sections. A second VM would represent the Page/Section, allowing you to create a property for the WrapPanel content (i.e. the words) and another property for the Header and or other things.
In the View you would have the scrollviewer and bind to the main VM collection. Then create another View or DataTemplate that represents the Page/Section.
You should be able to do this is a strict MVVM sense quite easily and it will be dynamic based on the content.
You could even cater for advanced scenarios where each section has a different template/view.

Can I develope a dynamic GUI with glade?

This is a newbie question so forgive me but I'm confused.
Suppose, as a simple example, that I wish to have a GUI that has a button to add some component (say a file chooser widget) to the interface as many times as I want. (and maybe another button to remove the last if you wish to think more pragmatically). How would I design such a thing using glade? Is there any way to have the buttons "working" inside glade itself?
My guess is that I can only design the default interface and then I am manually responsible for the callbacks that will add and remove components. My GUI will however be static from within glade so I can only test it during runtime. Is that the basic idea?
You're correct, there is no way to test the callbacks in glade itself and you can only test it during runtime.

GWT: In an MVP design, should the underlying page layout be a considered a view?

I have been following the GWT MVP tutorial (https://developers.google.com/web-toolkit/articles/mvp-architecture-2) and while it all makes a lot of sense, I have some trouble taking it from the example they explain to a larger scale application.
In particular, I would like to use a DockLayoutPanel to have a separate navigation, content and header section. What I'm struggling with is primarily the question of: where does the main dock panel live? Is it a view with it's own associated presenter? Does it constitute a special case where I don't want to use a view as this is really just the fundamental page layout?
It would be greatly appreciated to get some practical insights from people having faced a similar issue before.
Well I think as always it depends.
But I would recommend to create a View (i.e. MainPageView) with it's own associated Presenter (i.e. MainPagePresenter) even when there is almost no business logic and the View only defines the layout of the application.
Maybe in the future there will be some business logic.
For example if you want to show alerts or notification popups to a user you will probably do this in this View.
So your MainPagePresenter will listen for Notification events on the global EventBus and once an event is fired from any nested Presenter it will display a notification popup in the MainPageView.
Another use case would be if you want to display breadcrumbs in the north panel.
Of course you could create a separate Presenter for breadcrumbs but IMHO that's too much overengineering. You could however easily do that in the MainPagePresenter
I am using GWTP as my MVP framework and there it is really trivial to create View/Presenter pairs and it also supports nested PresenterWidgets which you can for example embed in any panel of your DockLayoutPanel
After searching for something related, I stumbled across another thread that asks a similar question and was quite insightful for me:
GWT MVP - maintaining multiple displays that are separate of one another

j2me form how to define gui properties

i'm new to j2me. how to set form elements (text field ,text box) width,font,alignment and other Gui related properties.
i tried to find solution for setting form background but no success. can you guide me
Firstly, J2ME is a very limited framework.
As far as I can remember if you are just using an item from the basic javax.microedition.lcdui package there is very limited styling available. It allows you to give directives on how to lay the item out on the screen and what the item's appearance mode will be.
An Item is not responsible for where it is placed and is down to the Screens layout management algorithm to place your item on the Screen. For example, the way Items are laid out on Forms and Lists differ based upon how the layout management works.
You can create your own customs items by extending CustomItem and implementing and overriding various functions to get the desired visual effect. This however is a lot of work
and the end result is not always very pleasing. You could also do the same by extending the Form class and overriding the paint methods to get your disered visual effect.
The best way to have control over form elements is to use one of the Widget like frameworks that exist and are built upon these basic J2ME classes. For example LWUIT and J2ME Polish allow you to style items in a very similar manner and layout Items using a CSS box inspired manner.
Although I have no used LWUIT so cannot vouch for it.

GWT 2.1 Tree or CellTree?

I'm really struggling with a choice between the GWT Tree widget, which has been a part of GWT for ages; or the new CellTree, which is introduced by GWT 2.1.
The tree I want to present to the user is not particularly large, but I am very concerned about responsiveness.
The data at the nodes of the tree will be editable. By clicking on a node, the user will put the node into edit mode. Editing the more simple nodes will require only a single TextBox or TextArea; but others will involve several widgets, over which I want styling control via CSS.
I'm attracted to the CellTree approach because it seems to offer great flexibility and speed; however, the sample code for CellTree editing deals with only very simple data types: string, date, integer, etc. I don't know if CellTree is appropriate when you've got more complex node-editing needs.
What do you think? Is CellTree the best approach? Does CellTree replace Tree in general? What heuristics can I apply in choosing between them?
I'm using a CellTable with several custom input Cells, including one comprised of many widgets. It works great!
It took me a couple of hours to understand how to implement a custom Cell that could do complex operations - since a single instance of the Cell will flit around the CellTree, pretending to be many instances, you need to understand how it's getting its data and when it is refreshed and rendered. I learned a lot from the source of the DatePickerCell.
I can't speak for CellTree, but the CellTable is very flexible, was easy to program, and saves me hundreds of Widget instances.
Using CellTree is problematic. Because it hasn't good access to view implementation stored in CellTree. It cause problem (ex. for me :D) in making custom handlers for opening nodes with children by clicking on whole parent cell. Of course you can make custom cells by AbstractCell, where you must write own renderer.
I think this widget must be enchanced and more objects must be more visible for users.
Customizing CSS is simple. All what you have to do is extende CellTree.resource and insert own css based on celltree.css class names.