U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Add Button crashes program on start
Re: Add Button crashes program on start [message #54842 is a reply to message #54840] Sun, 20 September 2020 23:48 Go to previous messageGo to previous message
Klugier is currently offline  Klugier
Messages: 1119
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Jim,

I can not reproduce this on the latest nightly build. Could you try to test with nightly? You can download it from our download page. On the other hand it might be due to some other code that we are not aware at this moment.

Here is my example:
// main.cpp
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define LAYOUTFILE <Gui16/dlg.lay>
#include <CtrlCore/lay.h>

struct MyApp : public WithDlgLayout<TopWindow> {
	MyApp() {
		CtrlLayout(*this, "MyDialog");
		
		btn << [=] { onClick(); };
	}
	
	virtual void Paint(Draw& w) override {
		w.DrawRect(GetSize(), Color(204, 255, 255));
	}
	
	void onClick() {
		PromptOK("Click Add");
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}

// dlg.lay
LAYOUT(DlgLayout, 208, 64)
	ITEM(Label, dv___0, SetLabel(t_("Label")).LeftPosZ(8, 36).TopPosZ(8, 19))
	ITEM(EditString, text, LeftPosZ(48, 92).TopPosZ(8, 19))
	ITEM(Option, option, SetLabel(t_("Option")).LeftPosZ(8, 108).TopPosZ(32, 15))
	ITEM(Button, btn, SetLabel(t_("asdasd")).SetFrame(ButtonFrame()).LeftPosZ(124, 56).TopPosZ(40, 15))
END_LAYOUT


Some code improvements you could apply:
virtual void Paint(Draw& w) override // virtual override is a nice addition - this will check that you indeed overriding this method
{
    w.DrawRect(GetSize(), Color ( 204, 255, 255 )); // <= enter your background color here
}

btnAddCustomer << [=] { btnAddCustomerClick(); }; // THISBACK is not needed in c++11 world and could be replaced with lambda.


I saw your second post. You eliminated crash by not connecting callback - this is not the solution Smile

Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 20 September 2020 23:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Background color of StaticText or EditString
Next Topic: LabelBase vertical alignment
Goto Forum:
  


Current Time: Sat Sep 19 05:44:28 GMT+2 2026

Total time taken to generate the page: 0.00590 seconds