Private Sub Button_Click_2(sender As Object, e As RoutedEventArgs)
Dim btn = New Button
btn.Width = 110
btn.Height = 50
btn.Content = "test"
sender.Parent().Children.Add(btn)
End Sub
Imports Windows.UI.Popups
Dim messageDialog = New MessageDialog("click")
Await messageDialog.ShowAsync()
using namespace Windows::UI::Popups;
MessageDialog ^ dialog = ref new MessageDialog("Hello WinRT");
dialog->ShowAsync();
extern "C" {
void MsgInfo( Platform::String ^ szMsg )
{
MessageDialog ^ dialog = ref new MessageDialog( szMsg );
dialog->ShowAsync();
}
};
std::wstring stows( std::string s )
{
std::wstring ws;
ws.assign( s.begin(), s.end() );
return ws;
}
std::string wstos( std::wstring ws )
{
std::string s;
s.assign( ws.begin(), ws.end() );
return s;
}
Platform::String ^ stops( std::string s )
{
return ref new Platform::String( stows( s ).c_str() );
}
std::string pstos( Platform::String ^ ps )
{
return wstos( std::wstring( ps->Data() ) );
}
Platform::String ^ atops( const char * text )
{
return stops( std::string( text ) );
}
extern "C" {
void hb_vmInit( BOOL );
std::wstring stows( std::string s )
{
std::wstring ws;
ws.assign( s.begin(), s.end() );
return ws;
}
std::string wstos( std::wstring ws )
{
std::string s;
s.assign( ws.begin(), ws.end() );
return s;
}
Platform::String ^ stops( std::string s )
{
return ref new Platform::String( stows( s ).c_str() );
}
std::string pstos( Platform::String ^ ps )
{
return wstos( std::wstring( ps->Data() ) );
}
Platform::String ^ atops( const char * text )
{
return stops( std::string( text ) );
}
void MsgInfo( char * szMsg )
{
MessageDialog ^ dialog = ref new MessageDialog( atops( szMsg ) );
dialog->ShowAsync();
}
void HB_FUN_MAIN( void );
};
size_t i;
char buffer[ 300 ];
wcstombs_s( &i, buffer, (size_t) 300, std::wstring( this->code->Text->Data() ).data(), (size_t) 300 );
unsigned long ulLen = platformString->Length() * 2;
char * buffer = ( char * ) malloc( uiLen );
size_t i;
wcstombs_s( &i, buffer, uiLen, std::wstring( platformString->Data() ).data(), uiLen );
... (use the text)
free( ( void * ) buffer );
Button ^ fivewinrt::BlankPage::AddButton( void )
{
static Button ^ btn = ref new Button;
btn->Width = 110;
btn->Height = 50;
btn->Content = "Button";
this->Grid->Children->Append( btn );
return btn;
}
void btn_Tapped( Object ^ sender, TappedRoutedEventArgs ^ e )
{
MsgInfo( "btn Click" );
}
Button ^ fivewinrt::BlankPage::AddButton( void )
{
static Button ^ btn = ref new Button;
btn->Width = 110;
btn->Height = 50;
btn->Content = "Button";
this->Grid->Children->Append( btn );
btn->AddHandler( TappedEvent, ref new TappedEventHandler( btn_Tapped ), false );
return btn;
}
Antonio Linares wrote:
- Code: Select all Expand view
void btn_Tapped( Object ^ sender, TappedRoutedEventArgs ^ e )
C++/CX (Component Extensions) is a language extension for C++ compilers from Microsoft that enables C++ programmers to write programs for the new Windows Runtime platform, or WinRT. It brings a set of syntax and library abstractions that interface with the COM-based WinRT programming model in a way that is natural to native C++-programmers.
The ref new instead returns a handle, which is a reference to the object rather than the pointer itself. These references are counted so that the object can be automatically deleted when there are no longer any references to it.
Return to Utilities / Utilidades
Users browsing this forum: No registered users and 5 guests