C++/WinRT에서 UWP 1위는 Hello World입니다.
1.VS2019 설치~구축이 가능할 때까지
1-1.설치하다.
VS2019가 설치되어 있지 않으면 MS 다운로드 페이지에서'커뮤니티'의'무료 다운로드'무료 웹 다운로드를 다운로드하세요.규칙을 준수하다.
분명히'C++'나'.NET'라는 팻말을 달고 있는데, 검사만 하면 필요한 물건을 설치해야 한다!
개별 구성 요소의 Windows10SDK(...)도 자주 잊어버립니다.확인해보는 게 좋을 것 같습니다.다른 PC에서 제작된 버전××학벌이 없다는 욕을 자주 먹다.
여기까지만 끝내고 설치가 끝나기 전에 조금만 기다려요.
1-2.C++/WinRT 추가
설치 후 winrt에서 "확장 기능"- "확장 기능의 관리"에서 검색한 다음 "C+/WinRT"를 입력하십시오.이렇게 하면 C++/WinRT를 새 항목 만들기 등에 추가하거나 작성할 수 있습니다.
2.Hello World
2-1.프로젝트 추가
Blank App(C++/WinRT)을 선택하십시오.UWP 여기 있습니다.
2-2.버튼 및 텍스트 블록 추가
· 솔루션 자원 관리자의 'MainPage.xaml' 을 두 번 눌러서 표시하고, '도구상자' 의 'Button' 을 두 번 끌어다 놓으면 두 개의 단추를 추가합니다.Text Block 을 추가하십시오.
·MFC 등 앱을 만들 때 이때 버튼의 위치는 드래그하는 위치에서 자유롭게 결정할 수 있지만, UWP는 그렇게 할 수 없다(너비와 높이 등은 심하게 다뤄질 수 있다).
・위치를 변경하려면xaml을 편집해야 합니다.다음 기고입니다.
그러면 화면 바로 아래xaml 편집 화면에 다음 코드가 추가되었습니다.
title <Button x:Name="button" Content="Button" Click="button_Click"/>
<Button x:Name="button1" Content="Button" Click="button1_Click"/>
<TextBlock x:Name="textBlock" Text="TextBlock" TextWrapping="Wrap"/>
・x: Name =\"\"로 둘러싸인 이름을 사용하여 버튼이나 텍스트 블록에 액세스합니다.
・MainPage.cpp에서 button에 추가된 왼쪽 키를 가속할 수도 있고 text 블록에 추가된 텍스트 블록을 가속할 수도 있습니다.
・ 다음에는 드래그 앤 드롭 대신 추가 를 적으십시오.
2-3.프로세서 추가
· 버튼을 추가했기 때문에 MFC가 말한 이벤트 처리 프로그램을 추가합니다 (클릭했습니다).
・ 추가된 버튼을 선택하고 화면 왼쪽 상단 "속성"의 번개 아이콘(아래 아이콘)을 클릭합니다.
・"Click"의 편집 상자를 두 번 클릭하고 button이 클릭할 때의 이벤트 처리 프로그램MainPage를 클릭합니다.cpp에 추가되었습니다.
・button과 button1 두 가지에 속성을 추가하십시오.
2-4.이벤트 프로세서에 대한 설명
・ 처음에는 다음 코드였습니다.
title#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
using namespace winrt;
using namespace Windows::UI::Xaml;
namespace winrt::hello_world::implementation
{
MainPage::MainPage()
{
InitializeComponent();
}
int32_t MainPage::MyProperty()
{
throw hresult_not_implemented();
}
void MainPage::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
void MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
{
myButton().Content(box_value(L"Clicked"));
}
}
void winrt::hello_world::implementation::MainPage::button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
}
void winrt::hello_world::implementation::MainPage::button1_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
}
・ Hello World 는 대화 상자와 텍스트 블록을 통해 표시됩니다.
・대화 상자가 포함된 머리글, winrt:hello-world::implementation::MainPage::button_클릭할 때의 동작을 설명합니다.
title#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
//追加
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.UI.Popups.h>
using namespace winrt;
using namespace Windows::UI::Xaml;
namespace winrt::hello_world::implementation
{
MainPage::MainPage()
{
InitializeComponent();
}
int32_t MainPage::MyProperty()
{
throw hresult_not_implemented();
}
void MainPage::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
void MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
{
myButton().Content(box_value(L"Clicked"));
}
}
void winrt::hello_world::implementation::MainPage::button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
//追加
winrt::Windows::UI::Xaml::Controls::ContentDialog dialog;
dialog.Title(box_value(L"hello"));
dialog.Content(box_value(L"Hello World"));
dialog.CloseButtonText(L"OK");
dialog.PrimaryButtonText(L"OKOK");
dialog.ShowAsync();
Windows::UI::Popups::MessageDialog msg{ L"Hello World",L"Hello World" };
msg.ShowAsync();
}
void winrt::hello_world::implementation::MainPage::button1_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
//追加
textBlock().Text(L"Hello World");
}
3 재구축
• 추가 후 재구축 → 디버깅이 시작된 후에야 디버깅이 시작됩니다.
• 단지 나의 환경일 수도 있다. 만약 C++/WinRT로 어떤 곳을 개작했다면, '구축' 으로 변경된 곳만 구축할 수 있다. (App.h와 App.cpp를 대폭 개작하기 위해서?)오류가 발생할 수 있으므로 모든 컨텐트를 컴파일/링크하려면 재구축을 선택합니다.그래서 건물 시간이 길어요.
・여기까지만 하면 MFC와 다를 게 없어요.
3-1. 표시된 대화 상자
대화상자는 Message Dialog와 Content Dialog 두 가지로 나뉘어 있습니다.MessageDialog는 MessageBox와 비슷한 쪽이고, ContentDialog는 새로 끝난 쪽이다.ShowAsync()와 각각 비동기적으로 표시됩니다.MFC의 MessageBox와 AfxMessageBox를 표시할 때처럼 처리가 멈추지 않기 때문에 두 개의 대화상자가 나타납니다.동기 비동기에 대해서 그 정도로 배우면 할 거예요.
3-1-1. MessageDialog 정보
·메시지 다이얼로그「MessageDialog Class」는 여러 버튼을 추가할 수 있을 것 같지만 이번에는 추가되지 않았다.
3-1-2. 중심 Dialog 정보
·ContentDialog에는 CloseButtonText()와 PrimaryButtonText()가 추가되었습니다.CloseBottonText()를 추가하지 않으면 닫을 수 없습니다. 주의하십시오.「ContentDialog Class」 C++/WinRT를 지정하더라도 C# 샘플만 있는 페이지가 표시됩니다.MS가 C++/WinRT에 대한 열의를 아주 잘 전달했네요.
·SecondaryButtonText() 처음 3개 버튼이면 간단하게 추가할 수 있다.테티어리가 없어서 대충.
3-2. TextBlock 정보
· StaticText와 같네요.StaticText는 SetWindowText를 통해 내용을 변경할 수 있지만, 여기서는 Text () 를 사용합니다.
github가 공개했기 때문에 그렇습니다.
「yoshiyoshi-git/hello_world」
4 참조된 웹 사이트
아래 내용을 참고하게 해 주세요.감사합니다.
C++/WinRT 시작 방법
C++/WinRT
그럼 이어서 Xam 편집하겠습니다.
문자 방향
Reference
이 문제에 관하여(C++/WinRT에서 UWP 1위는 Hello World입니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/lilac0011/items/6d1282fa6c7b1265b1c2
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
2-1.프로젝트 추가
Blank App(C++/WinRT)을 선택하십시오.UWP 여기 있습니다.
![](https://s1.md5.ltd/image/3c2a7fd595aec2a2015a28722d98669d.png)
2-2.버튼 및 텍스트 블록 추가
· 솔루션 자원 관리자의 'MainPage.xaml' 을 두 번 눌러서 표시하고, '도구상자' 의 'Button' 을 두 번 끌어다 놓으면 두 개의 단추를 추가합니다.Text Block 을 추가하십시오.
·MFC 등 앱을 만들 때 이때 버튼의 위치는 드래그하는 위치에서 자유롭게 결정할 수 있지만, UWP는 그렇게 할 수 없다(너비와 높이 등은 심하게 다뤄질 수 있다).
・위치를 변경하려면xaml을 편집해야 합니다.다음 기고입니다.
![](https://s1.md5.ltd/image/e9b9d2abf44bc9432412c0dfe3f64212.png)
그러면 화면 바로 아래xaml 편집 화면에 다음 코드가 추가되었습니다.
title
<Button x:Name="button" Content="Button" Click="button_Click"/>
<Button x:Name="button1" Content="Button" Click="button1_Click"/>
<TextBlock x:Name="textBlock" Text="TextBlock" TextWrapping="Wrap"/>
・x: Name =\"\"로 둘러싸인 이름을 사용하여 버튼이나 텍스트 블록에 액세스합니다.・MainPage.cpp에서 button에 추가된 왼쪽 키를 가속할 수도 있고 text 블록에 추가된 텍스트 블록을 가속할 수도 있습니다.
・ 다음에는 드래그 앤 드롭 대신 추가 를 적으십시오.
2-3.프로세서 추가
· 버튼을 추가했기 때문에 MFC가 말한 이벤트 처리 프로그램을 추가합니다 (클릭했습니다).
・ 추가된 버튼을 선택하고 화면 왼쪽 상단 "속성"의 번개 아이콘(아래 아이콘)을 클릭합니다.
![](https://s1.md5.ltd/image/f7184a5cf087f57ed11c6991a43f8a1a.png)
・"Click"의 편집 상자를 두 번 클릭하고 button이 클릭할 때의 이벤트 처리 프로그램MainPage를 클릭합니다.cpp에 추가되었습니다.
・button과 button1 두 가지에 속성을 추가하십시오.
![](https://s1.md5.ltd/image/3100be783dedcc17698a1ffe5739b66a.png)
2-4.이벤트 프로세서에 대한 설명
・ 처음에는 다음 코드였습니다.
title
#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
using namespace winrt;
using namespace Windows::UI::Xaml;
namespace winrt::hello_world::implementation
{
MainPage::MainPage()
{
InitializeComponent();
}
int32_t MainPage::MyProperty()
{
throw hresult_not_implemented();
}
void MainPage::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
void MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
{
myButton().Content(box_value(L"Clicked"));
}
}
void winrt::hello_world::implementation::MainPage::button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
}
void winrt::hello_world::implementation::MainPage::button1_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
}
・ Hello World 는 대화 상자와 텍스트 블록을 통해 표시됩니다.・대화 상자가 포함된 머리글, winrt:hello-world::implementation::MainPage::button_클릭할 때의 동작을 설명합니다.
title
#include "pch.h"
#include "MainPage.h"
#include "MainPage.g.cpp"
//追加
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.UI.Popups.h>
using namespace winrt;
using namespace Windows::UI::Xaml;
namespace winrt::hello_world::implementation
{
MainPage::MainPage()
{
InitializeComponent();
}
int32_t MainPage::MyProperty()
{
throw hresult_not_implemented();
}
void MainPage::MyProperty(int32_t /* value */)
{
throw hresult_not_implemented();
}
void MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
{
myButton().Content(box_value(L"Clicked"));
}
}
void winrt::hello_world::implementation::MainPage::button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
//追加
winrt::Windows::UI::Xaml::Controls::ContentDialog dialog;
dialog.Title(box_value(L"hello"));
dialog.Content(box_value(L"Hello World"));
dialog.CloseButtonText(L"OK");
dialog.PrimaryButtonText(L"OKOK");
dialog.ShowAsync();
Windows::UI::Popups::MessageDialog msg{ L"Hello World",L"Hello World" };
msg.ShowAsync();
}
void winrt::hello_world::implementation::MainPage::button1_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e)
{
//追加
textBlock().Text(L"Hello World");
}
3 재구축
• 추가 후 재구축 → 디버깅이 시작된 후에야 디버깅이 시작됩니다.
• 단지 나의 환경일 수도 있다. 만약 C++/WinRT로 어떤 곳을 개작했다면, '구축' 으로 변경된 곳만 구축할 수 있다. (App.h와 App.cpp를 대폭 개작하기 위해서?)오류가 발생할 수 있으므로 모든 컨텐트를 컴파일/링크하려면 재구축을 선택합니다.그래서 건물 시간이 길어요.
・여기까지만 하면 MFC와 다를 게 없어요.
3-1. 표시된 대화 상자
대화상자는 Message Dialog와 Content Dialog 두 가지로 나뉘어 있습니다.MessageDialog는 MessageBox와 비슷한 쪽이고, ContentDialog는 새로 끝난 쪽이다.ShowAsync()와 각각 비동기적으로 표시됩니다.MFC의 MessageBox와 AfxMessageBox를 표시할 때처럼 처리가 멈추지 않기 때문에 두 개의 대화상자가 나타납니다.동기 비동기에 대해서 그 정도로 배우면 할 거예요.
3-1-1. MessageDialog 정보
·메시지 다이얼로그「MessageDialog Class」는 여러 버튼을 추가할 수 있을 것 같지만 이번에는 추가되지 않았다.
3-1-2. 중심 Dialog 정보
·ContentDialog에는 CloseButtonText()와 PrimaryButtonText()가 추가되었습니다.CloseBottonText()를 추가하지 않으면 닫을 수 없습니다. 주의하십시오.「ContentDialog Class」 C++/WinRT를 지정하더라도 C# 샘플만 있는 페이지가 표시됩니다.MS가 C++/WinRT에 대한 열의를 아주 잘 전달했네요.
·SecondaryButtonText() 처음 3개 버튼이면 간단하게 추가할 수 있다.테티어리가 없어서 대충.
3-2. TextBlock 정보
· StaticText와 같네요.StaticText는 SetWindowText를 통해 내용을 변경할 수 있지만, 여기서는 Text () 를 사용합니다.
github가 공개했기 때문에 그렇습니다.
「yoshiyoshi-git/hello_world」
4 참조된 웹 사이트
아래 내용을 참고하게 해 주세요.감사합니다.
C++/WinRT 시작 방법
C++/WinRT
그럼 이어서 Xam 편집하겠습니다.
문자 방향
Reference
이 문제에 관하여(C++/WinRT에서 UWP 1위는 Hello World입니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/lilac0011/items/6d1282fa6c7b1265b1c2
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
아래 내용을 참고하게 해 주세요.감사합니다.
C++/WinRT 시작 방법
C++/WinRT
그럼 이어서 Xam 편집하겠습니다.
문자 방향
Reference
이 문제에 관하여(C++/WinRT에서 UWP 1위는 Hello World입니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/lilac0011/items/6d1282fa6c7b1265b1c2텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)