Simple MessageBox C++ class
Good Morning!
I'm starting with NoesisGUI...
I am trying to create a MessageBox in C++.
But I'm not getting ...
I tried to look for an example in the forum and in the examples of the SDK C++ but I also didn't find it.
I'm trying to use the idea of viewtopic.php?f=3&t=862&p=4694#p4692 as a basis
However, I was unable to create the class in c++ that would make the connection between Title / Message / OkText / OkCommand (I don't need the cancel button).
The only way I managed to make this work was to create an x: Name on the elements and set the value like this:
Could you please give me an example of what this class would look like in c++?
Thanks.
Leandro Daldegam
I'm starting with NoesisGUI...
I am trying to create a MessageBox in C++.
But I'm not getting ...
I tried to look for an example in the forum and in the examples of the SDK C++ but I also didn't find it.
I'm trying to use the idea of viewtopic.php?f=3&t=862&p=4694#p4692 as a basis
However, I was unable to create the class in c++ that would make the connection between Title / Message / OkText / OkCommand (I don't need the cancel button).
The only way I managed to make this work was to create an x: Name on the elements and set the value like this:
Code: Select all
auto* title_component = static_cast<Noesis::TextBlock*>(FindName("Title"));
title_component->SetText("TEXT FROM C++");
Thanks.
Leandro Daldegam
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Simple MessageBox C++ class
To connect data from C++ to the xaml you can use data binding and expose the data in your user control as dependency properties.
This was just an example for one of the properties, you can add as many properties as you need to build your message box UI.
You can also add event handlers to react to Button clicks as explained here: https://www.noesisengine.com/docs/Gui.C ... bscription
Anyway, as this is a topic that was asked a few times now, we will add an example to our application framework in a future release so users can use that as reference for their own implementations.
Code: Select all
class MessageBox: public UserControl
{
public:
MessageBox()
{
GUI::LoadComponent(this, "UI/Xamls/MessageBox.xaml");
}
static const DependencyProperty* TitleProperty;
NS_IMPLEMENT_INLINE_REFLECTION(MessageBox, UserControl, "MyNamespace.MessageBox")
{
UIElementData* data = NsMeta<UIElementData>(TypeOf<MessageBox>());
data->RegisterProperty<String>(TitleProperty, "Title", PropertyMetadata::Create(String("Default Title")));
}
};
Code: Select all
<UserControl x:Class="MyNamespace.MessageBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyNamespace"
x:Name="TheMessageBox">
<Grid Background="#80000000">
<DockPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock DockPanel.Dock="Top" Text="{Binding Title, ElementName=TheMessageBox}" FontSize="32"/>
</DockPanel>
</Grid>
</UserControl>
You can also add event handlers to react to Button clicks as explained here: https://www.noesisengine.com/docs/Gui.C ... bscription
Anyway, as this is a topic that was asked a few times now, we will add an example to our application framework in a future release so users can use that as reference for their own implementations.
Re: Simple MessageBox C++ class
I managed to make it work from your example.
Thanks for the answer.
---
Just one more question, is there any search in the documentation?
I couldn't find where to search for a particular term in it.
Thanks.
Thanks for the answer.
---
Just one more question, is there any search in the documentation?
I couldn't find where to search for a particular term in it.
Thanks.
Re: Simple MessageBox C++ class
Not yet, sorry, but we have plans for that. Right now, the only alternative is using the Class Hierarchy or Google (site:noesisengine.com/docs ...)Just one more question, is there any search in the documentation?
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Simple MessageBox C++ class
Added a new ticket #1833 to our tracker to follow this.
Re: Simple MessageBox C++ class
This was finally added to 3.0.8, thanks for your feedback!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 64 guests