|
|
Home » U++ TheIDE » U++ TheIDE: Layout (Forms) Designer » GUI with Menu bar and 5 Labels/Text Boxes
GUI with Menu bar and 5 Labels/Text Boxes [message #24631] |
Tue, 26 January 2010 03:10  |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
I am new to U++, seems like a great project.
I have tried all the GUI in the tutorial folder (Gui01 to 22) and have the GUI Tutorial:
http://www.ultimatepp.org/srcdoc$CtrlLib$Tutorial$en-us.html
I am having a problem with Menu bar and 5 Labels/Text Boxes.
I have one GUI that has a Menu bar with all the menu items with sub menus and links. Another GUI that uses the .lay format has 5 Labels and editable text boxes.
The GUI with the Menu I am having a problem adding the Labels/text boxes.
The GUI with the Labels/text boxes I am having a problem adding the Menu.
None of the Gui01 to 22 has both Menu and Labels/Text boxes.
An example that does this would be appreciated.
edit: Starting with the tutorial Gui16 how could a Menu bar be added?
I am getting errors like this:
error C2039: 'Exit' : is not a member of 'Upp::TopWindow'
error C2276: '&' : illegal operation on bound member function xpression
Or starting with Gui07 how could you add the Labels and text boxes?
[Updated on: Tue, 26 January 2010 07:25] Report message to a moderator
|
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #24648 is a reply to message #24631] |
Tue, 26 January 2010 11:45   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
1- Starting with Gui16 (You could also start with a new package with a main window, as this is a more suitable start to an application).
2- Add 'typedef xxx CLASSNAME' and MenuBar member to the class (see comments below for explanations)
3- Initialise the MenuBar in the class constructor
4- Add callback handling functions for menu, sub-menus and menu items.
5- Done. There is a small problem that the layout is now the wrong size but you can adjust this in the .lay file designer. It can also be done in code but I've left that out for simpliciy.
The final code:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <Gui16/dlg.lay>
#include <CtrlCore/lay.h>
struct MyApp : public WithDlgLayout<TopWindow> {
typedef MyApp CLASSNAME; // This makes the THISBACK macro work
MenuBar menu; // This is your menu bar
MyApp() {
CtrlLayout(*this, "MyDialog");
AddFrame(menu); // To make a menu bar you must add the frame before setting the callback
menu.Set(THISBACK(MainMenu)); // Set the menu callback
}
// Main menu bar
void MainMenu(Bar &bar) {
bar.Add("File", THISBACK(FileMenu));
bar.Add("About", THISBACK(AboutMenu));
}
// File sub-menu
void FileMenu(Bar &bar) {
bar.Add("Exit", THISBACK(Exit));
}
// About sub-menu
void AboutMenu(Bar &bar) {
bar.Add("About", THISBACK(About));
}
// About menu handler
void About() {
// Show about stuff
}
// Exit menu handler
void Exit() {
if(PromptOKCancel("Exit MyApp?"))
Break(); // Closes window with 'Cancel'
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
I think the error you made before was leaving out the Exit() function.
[Updated on: Tue, 26 January 2010 11:49] Report message to a moderator
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #24649 is a reply to message #24646] |
Tue, 26 January 2010 12:17   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
This is Gui07 modified
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <Gui16/dlg.lay>
#include <CtrlCore/lay.h>
struct MyApp : public WithDlgLayout<TopWindow> {
MenuBar menu;
MyApp() {
AddFrame(menu);
CtrlLayout(*this, "MyDialog");
}
void GetP1() {
PromptOK("GetP1 activated!");
}
void GetP2() {
PromptOK("GetP2 activated!");
}
void Exit() {
if(PromptOKCancel("Exit MyApp?"))
Break();
}
void FileMenu(Bar& bar) {
bar.Add("Open File", THISBACK(Exit));
bar.Add("Clear File", THISBACK(Exit));
bar.Add("Exit", THISBACK(Exit));
}
void PointsMenu(Bar& bar) {
bar.Add("Get Point 1", THISBACK(GetP1));
bar.Add("Get Point 2", THISBACK(GetP2));
bar.Add("GoTo Point 1", THISBACK(Exit));
bar.Add("GoTo Point 2", THISBACK(Exit));
}
void SubMenu(Bar& bar) {
bar.Add("Exit", THISBACK(Exit));
}
void MainMenu(Bar& bar) {
bar.Add("File", THISBACK(FileMenu));
bar.Add("Settings", THISBACK(SubMenu));
bar.Add("Points", THISBACK(PointsMenu));
bar.Add("Calculate", THISBACK(SubMenu));
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
This is Gui16 modified, it worked with the Labels/Text boxes until I added the Menu code
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyAppWindow : TopWindow {
MenuBar menu;
void GetP1() {
PromptOK("GetP1 activated!");
}
void GetP2() {
PromptOK("GetP2 activated!");
}
void Exit() {
if(PromptOKCancel("Exit MyApp?"))
Break();
}
void FileMenu(Bar& bar) {
bar.Add("Open File", THISBACK(Exit));
bar.Add("Clear File", THISBACK(Exit));
bar.Add("Exit", THISBACK(Exit));
}
void PointsMenu(Bar& bar) {
bar.Add("Get Point 1", THISBACK(GetP1));
bar.Add("Get Point 2", THISBACK(GetP2));
bar.Add("GoTo Point 1", THISBACK(Exit));
bar.Add("GoTo Point 2", THISBACK(Exit));
}
void SubMenu(Bar& bar) {
bar.Add("Exit", THISBACK(Exit));
}
void MainMenu(Bar& bar) {
bar.Add("File", THISBACK(FileMenu));
bar.Add("Settings", THISBACK(SubMenu));
bar.Add("Points", THISBACK(PointsMenu));
bar.Add("Calculate", THISBACK(SubMenu));
}
typedef MyAppWindow CLASSNAME;
MyAppWindow() {
Title("Neilson"); //.Sizeable();
AddFrame(menu);
menu.Set(THISBACK(MainMenu));
}
};
GUI_APP_MAIN
{
MyAppWindow app;
app.SetRect(0, 0, 260, 120);
app.Run();
}
and the .lay file
LAYOUT(DlgLayout, 208, 132)
ITEM(Label, dv___0, SetLabel(t_("Point 1")).LeftPosZ(8, 40).TopPosZ(8, 19))
ITEM(EditField, dv___1, LeftPosZ(48, 156).TopPosZ(76, 19))
ITEM(EditString, text, LeftPosZ(48, 156).TopPosZ(8, 19))
ITEM(Option, option, SetLabel(t_("Option")).LeftPosZ(8, 108).TopPosZ(104, 15))
ITEM(LineEdit, dv___4, LeftPosZ(48, 156).TopPosZ(28, 19))
ITEM(LineEdit, dv___5, LeftPosZ(48, 156).TopPosZ(52, 19))
ITEM(Label, dv___6, SetLabel(t_("Point 2")).LeftPosZ(8, 40).TopPosZ(28, 19))
ITEM(Label, dv___7, SetLabel(t_("Distance")).LeftPosZ(8, 40).VSizePosZ(52, 61))
END_LAYOUT
I also tried from examples Puzzles and EyeCare that have both a menu and addid graphics.
With Puzzles after stripping some of the code there were errors re "unresolved externals".
With EyeCare I am still removing code so I can understand it.
|
|
|
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #24903 is a reply to message #24880] |
Wed, 03 February 2010 18:10   |
Sc0rch
Messages: 99 Registered: February 2008 Location: Russia, Rubtsovsk
|
Member |

|
|
nlneilson wrote on Wed, 03 February 2010 03:06 |
1. How can the initial position be set to (6,60) rather than centered.
|
If you about dialogs: use NoCenter() method of child windows, then set the positions on screen (maybe, SetRect(...)).
nlneilson wrote on Wed, 03 February 2010 03:06 |
2. How can this be set to always on top.
|
Search for TopMost() method in TopWindow class.
nlneilson wrote on Wed, 03 February 2010 03:06 |
3. How to set it undecorated and still be able to drag it.
|
Sorry, what do you mean? Popup?
Best regards,
Anton
[Updated on: Wed, 03 February 2010 18:10] Report message to a moderator
|
|
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #24911 is a reply to message #24909] |
Thu, 04 February 2010 03:32   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
Thanks Anton!!
Your post pointed me in the right direction.
I downloaded the u++ package several days ago and did not have access to the internet until I just got back so was getting frustrated not having an example to follow.
I just downloaded the GUI Tutorial, it would be good if that was attached to the Help file that is with TheIDE or at least included in the download package.
SetRect(...) does work and over rides the size set in the .lay file. It takes 4 parameters, 2 for the position and 2 for the size where Java takes 2, frame.setLocation(5, 46); The NoCenter() is not necessary.
MyApp() {
CtrlLayout(*this, "Neilson1");
TopMost(true, true);
SetRect(6, 78, 264, 140);
I copied the GUI Tutorial into the upp directory and did a search for "decorated" in that directory. The only things that came up were:
String DecoratedItem
wbemErrNondecoratedObject
Neither of these seemed to apply.
MSVC has a box to check for this and in Java:
frame.setUndecorated(true);
So unless it is called something else this may not be implemented in upp/TheIDE, at least I found no examples that have it.
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #24912 is a reply to message #24911] |
Thu, 04 February 2010 07:46   |
Sc0rch
Messages: 99 Registered: February 2008 Location: Russia, Rubtsovsk
|
Member |

|
|
nlneilson wrote on Thu, 04 February 2010 08:32 |
SetRect(...) does work and over rides the size set in the .lay file. It takes 4 parameters, 2 for the position and 2 for the size where Java takes 2, frame.setLocation(5, 46); The NoCenter() is not necessary.
|
Well, glad to help. Sorry, but I haven't time for examples =(
About NoCenter(): if you can't change the position of dialog, use this method. Just remember for future =)
Best regards and sorry for my English,
Anton
|
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #24918 is a reply to message #24912] |
Thu, 04 February 2010 14:53   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
Thanks Anton.
Sc0rch wrote on Thu, 04 February 2010 07:46 | Well, glad to help. Sorry, but I haven't time for examples =(
Best regards and sorry for my English,
|
Your English is fine. What is important is getting the concept of the problem/solution across which you have done. My hang up many times is unlearning something I am used to. Before I used setLocation(10, 60) with 2 parameters.
As for an example that would not take much time if you had:
SetRect(10, 60, 200, 400);
with the 4 parameters that would have been clearer.
You pointed me in the right direction with the correct function, that is what is important.
Thanks
Neil
|
|
|
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #25025 is a reply to message #25023] |
Sun, 07 February 2010 21:51   |
|
You can check how it is realized in the packages:
- EyerCare
- GoogleTranslator
nlneilson wrote on Sun, 07 February 2010 21:20 | I like the ability to tinker with the dimensions manually for the location and size. For some of my apps this is very important.
With upp I was able to cut the size (left) from similar in java (right).

I have run into a problem. The app shows on the task bar but it cannot be minimized or closed from the task bar since I made it Frameless (Undecorated).
A search in the u++ directory for TaskBar found several in CtrlLib\TrayIconWin32.cpp and bazaar\UltimatePlayer but I was unable to figure out how to minimize/maximize and close from the TaskBar when the GUI is Frameless.
Can this be done with upp?
|
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #25028 is a reply to message #25025] |
Mon, 08 February 2010 13:48   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
Thanks tojocky, but neither of the packages had something I could figure out.
In EyeCare there was use of TrayIcon which is different from what is shown on the TaskBar for all apps that are running which can be right clicked and closed, minimized, etc., when the app made with upp is not Frameless it can but when it is Frameless it cannot.
With EyeCare it had a TrayIcon and when right clicked it has:
Show EyeCare, Ignore eyes, About and Exit, but not always.
Twice it could not be closed even with the TaskManager and starting the computer again it would pop up, NOT GOOD. I did a search of C:\ and found an EyeCare file in C:\WINDOWS\Prefetch.
I deleted that and every thing else in the search that could be deleted, EyeCare.exe could not until I rebooted again.
Tinkering with code re registry keys is something I want to stay clear of for now.
HKEY hkey;
if(RegOpenKeyEx(HKEY_CURRENT_USER, regpath, 0, KEY_ALL_ACCESS, &hkey) == ERROR_SUCCESS) {
RegDeleteValue(hkey, regname);
RegCloseKey(hkey);
}
The GoogleTranslator package does not have a main so was unable to run it. Looking through the code in the .cpp and .h files there was nothing re TrayIcon, tray, TaskBar or task and could find no code that was related, maybe because I don't know what code could be related to the TaskBar.
When the upp app is running it is on the TaskBar, I would like to be able to right click and have the option for closed, minimized, etc. when it is Frameless the same as when it has a frame.
Is there a way of implementing this with upp?
[Updated on: Mon, 08 February 2010 13:52] Report message to a moderator
|
|
|
Re: GUI with Menu bar and 5 Labels/Text Boxes [message #25029 is a reply to message #25028] |
Mon, 08 February 2010 19:00   |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
edit: Searching in this forum for TaskBar showed 15 but only 2 were remotely related.
16 February 2006 message #1048
"when the MenuBar is visible the taskbar shows an empty button for it"
This is no help.
07 May 2008 message #15793
"When I minimize it and then click on the taskbar to bring it back to the foreground, it is no longer maximized."
This is no help either. His problem was with two screens but clicking on the task bar did work and it probably was not Frameless.
Searching for Frameless in this forum:
08 June 2009 message #21838
Quote: | Anyway, if I understood you correctly, yes it's possible to hide the main title bar of the window. For this purpose, e.g. in the Windows operating system, you can change Window Style to not include WS_CAPTION. In U++ we use TopWindow class. It have SyncCaption0 method that changes window styles. FrameLess method can be placed in window constructor. In my opinion, it is not very flexible, because you don't have system menu in this mode and must implement own areas for window placement, close, maximize, minimize buttons, etc.
SetSkin method changes how U++ widget(s) (inherited from Ctrl) looks.
|
"... must implement own areas for window placement, close, maximize, minimize buttons, etc."
This seems to be a similar problem but I do not want any extra buttons but would like to click on the TaskBar to close, minimize, etc.
By not include WS_CAPTION may work for the Win OS but eventually I would like to be Linux compatible also.
Will the "SetSkin" method retain the TaskBar close, minimize, etc for a FrameLess GUI? If so is there code that shows how this is done?
Like this with the Java app. It works this way with the upp GUI unless it is FrameLess.
-
Attachment: TaskBar.jpg
(Size: 15.68KB, Downloaded 1353 times)
|
|
|
Goto Forum:
Current Time: Mon Apr 28 14:26:48 CEST 2025
Total time taken to generate the page: 0.00969 seconds
|
|
|