vs2022 wxWidgets

来源:https://www.cnblogs.com/khlbat/archive/2023/06/14/17479111.html
-Advertisement-
Play Games

# 下載 https://www.wxwidgets.org/downloads/ 下載壓縮包即可 ![image](https://img2023.cnblogs.com/blog/916065/202306/916065-20230614040303993-2082032985.png) # 編 ...


下載

https://www.wxwidgets.org/downloads/

下載壓縮包即可
image

編譯

打開 build\msw 目錄下的 sln 文件

image

vs發佈版本與vc版本對應關係: vs發佈版本與vc版本對應關係

vs發佈包版本 vc版本
Visual Studio 2003 VC7
Visual Studio 2005 VC8
Visual Studio 2008 VC9
Visual Studio 2010 VC10
Visual Studio 2012 VC11
Visual Studio 2013 VC12
Visual Studio 2015 VC14
Visual Studio 2017 VC15
Visual Studio 2019 VC16
Visual Studio 2022 VC17

生成->批生成
image

全選->重新生成
image

大約需要 30 分鐘

新建 hello world 前的準備

新建一個目錄, 將 include 目錄和lib目錄複製過去

image

配置環境變數 wx_win, 值為includelib所在目錄: E:\program\wx_wdigets_3.2.2.1

hello world

editor config

[*]
guidelines = 120

[*.{cpp,c,h}]
charset = charset = utf-16le
indent_style = space
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
tab_width = 4

代碼

// wxWidgets "Hello World" Program

// For compilers that support precompilation, includes "wx/wx.h".
#define WXUSINGDLL
// #define __WXMSW__
// #define _UNICODE
#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};

class MyFrame : public wxFrame
{
public:
    MyFrame();

private:
    void OnHello(wxCommandEvent& event);
    void OnExit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
};

enum
{
    ID_Hello = 1
};

wxIMPLEMENT_APP(MyApp);

bool MyApp::OnInit()
{
    MyFrame* frame = new MyFrame();
    frame->Show(true);
    return true;
}

MyFrame::MyFrame()
    : wxFrame(NULL, wxID_ANY, "第一個視窗")
{
    wxMenu* menuFile = new wxMenu;
    menuFile->Append(ID_Hello, "&你好...\tCtrl-H",
        "此菜單的提示文本顯示在狀態欄");
    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);

    wxMenu* menuHelp = new wxMenu;
    menuHelp->Append(wxID_ABOUT);

    wxMenuBar* menuBar = new wxMenuBar;
    menuBar->Append(menuFile, "文件(&F)");
    menuBar->Append(menuHelp, "幫助(&H)");

    SetMenuBar(menuBar);

    CreateStatusBar();
    SetStatusText("Welcome to wxWidgets!");

    Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello);
    Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
    Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
}

void MyFrame::OnExit(wxCommandEvent& event)
{
    Close(true);
}

void MyFrame::OnAbout(wxCommandEvent& event)
{
    wxMessageBox("This is a wxWidgets Hello World example",
        "About Hello World", wxOK | wxICON_INFORMATION);
}

void MyFrame::OnHello(wxCommandEvent& event)
{
    wxLogMessage("Hello world from wxWidgets!");
}

項目屬性設置

修改輸出目錄與中間目錄

所有配置, 所有平臺

$(SolutionDir)$(ProjectName)\$(Platform)\$(Configuration)\
image

添加頭文件目錄

所有配置, 所有平臺

$(wx_win)\include\msvc
$(wx_win)\include

image

image

添加庫目錄

註意, win32與x64 不同

win32
$(wx_win)\lib\vc_dll

image

x64
$(wx_win)\lib\vc_x64_dll
image

修改子系統

image

dll 文件的複製

因為使用的時動態庫形式, 所以運行時需要動態庫文件, 添加生成事件

所有配置, 所有平臺
用於 MSBuild 命令和屬性的常用巨集

python $(SolutionDir)$(ProjectName)\copylib.py $(Platform) $(Configuration) $(SolutionDir)$(ProjectName)

image

python 腳本

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys 
import os
from shutil import copyfile

wx_env_name='wx_win'

dll_dict={
    # 'wxbase322u':'net',
    'wxbase322u':'',
    # 'wxbase322u':'xml',

    # 'wxmsw322u':'adv',
    # 'wxmsw322u':'aui',
    'wxmsw322u':'core',
    # 'wxmsw322u':'gl',
    # 'wxmsw322u':'html',
    # 'wxmsw322u':'media',
    # 'wxmsw322u':'propgrid',
    # 'wxmsw322u':'qa',
    # 'wxmsw322u':'ribbon',
    # 'wxmsw322u':'richtext',
    # 'wxmsw322u':'stc',
    # 'wxmsw322u':'webview',
    # 'wxmsw322u':'xrc'
}


if __name__ == "__main__":
    platform = sys.argv[1]
    configuration = sys.argv[2]
    proj_dir = sys.argv[3]
    wx_path = os.getenv(wx_env_name)

    # print('wx_path:',wx_path)
    # print('platform:', platform)
    # print('configuration:',configuration)
    # print('proj_dir:',proj_dir)

    for key,value in dll_dict.items():
        dll_name = key
        if 'Debug' == configuration:
            dll_name = dll_name + 'd'
        if 0 == len(value):
            dll_name = dll_name + '_vc_'
        else:
            dll_name = dll_name + '_' + value + '_vc_'
        if 'x64' == platform:
            dll_name = dll_name + 'x64_'
        dll_name = dll_name + 'custom.dll'
        # print('dll_name:',dll_name)
        
        source_dll = wx_path + os.path.sep + 'lib'
        if 'x64' == platform:
            source_dll = source_dll + os.path.sep + 'vc_x64_dll' + os.path.sep + dll_name
        else:
            source_dll = source_dll + os.path.sep + 'vc_dll' + os.path.sep + dll_name
        # print('source_dll',source_dll)
        target_dll = proj_dir + os.path.sep + platform + os.path.sep + configuration  +  os.path.sep + dll_name
        # print('target_dll',target_dll)
        print(source_dll + ' => ' + target_dll)
        if not os.path.exists(target_dll):
            copyfile(source_dll, target_dll)

測試效果

  1. 刪除與解決方案 .sln 同級的構建目錄, 比如 x64等, 保持目錄清晰乾凈
    image

分別運行 Debug x86 , Debug x64 , Release x86 , Release x64 驗證效果
image

image

項目模板

用Visual Studio2019自定義項目模板

.editorconfigcopylib.py添加到項目
添加->現有項
image

註意:

  1. 生成的模板文件位於: C:\Users\用戶名\Documents\Visual Studio 2022\My Exported Templates
  2. 實際使用的模板文件在: C:\Users\用戶名\Documents\Visual Studio 2022\Templates\ProjectTemplates
  3. 可能編輯模板之後不生效, 需要刪除緩存: C:\Users\用戶名\AppData\Local\Microsoft\VisualStudio\vs版本號\ComponentModelCache\Microsoft.VisualStudio.Default.cache

效果
image

本文來自博客園,作者:laolang2016,轉載請註明原文鏈接:https://www.cnblogs.com/khlbat/p/17479111.html


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • ### 前言 前不久,在我的一個項目中,需要展示一個橫向滾動的標簽頁,它支持滑鼠橫向拖動和點擊切換。在實現的過程中,我發現這個小功能需要同時用到前端的三輛馬車,但是實現難度不高,而且最終效果還不錯,是個難得的初學者項目,於是萌生了寫這篇文章的想法,希望對初學者有所幫助。同時為了避免初學者學習框架,我 ...
  • 這裡給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 使用背景: 1.因為svg圖標在任何設備下都可以高清顯示,不會模糊。而icon會在顯卡比較低的電腦上有顯示模糊的情況 2.svg圖標在頁面render時 速度會比icon稍微快一點 3.實現小程式換膚功能 ;方案見:www.yuque.c ...
  • 博客推行版本更新,成果積累制度,已經寫過的博客還會再次更新,不斷地琢磨,高質量高數量都是要追求的,工匠精神是學習必不可少的精神。因此,大家有何建議歡迎在評論區踴躍發言,你們的支持是我最大的動力,你們敢投,我就敢肝 ...
  • 前幾天打算給博客添加一個圖片預覽的效果,可在網上找了半天也沒找到合適的庫,於是自己乾脆自己手寫了個。 ...
  • # CSS特性 ## 1、繼承性 ##### 特性: 1、子元素有預設繼承父元素樣式的特點(**子承父業**) 2、可以繼承的常見屬性(文字控制屬性都可以繼承) 1.color 2.font-style、font-weight、font-size、font-family 3.text-indent, ...
  • 博客推行版本更新,成果積累制度,已經寫過的博客還會再次更新,不斷地琢磨,高質量高數量都是要追求的,工匠精神是學習必不可少的精神。因此,大家有何建議歡迎在評論區踴躍發言,你們的支持是我最大的動力,你們敢投,我就敢肝 ...
  • 遠程線程註入是最常用的一種註入技術,在應用層註入是通過`CreateRemoteThread`這個函數實現的,通過該函數通過創建線程並調用 `LoadLibrary` 動態載入指定的DLL來實現註入,而在內核層同樣存在一個類似的內核函數`RtlCreateUserThread`,但需要註意的是此函數... ...
  • 生活中我們經常談及 “架構”,那麼到底什麼是 “架構”,Robert C.Martin《架構整潔之道》中的定義:軟體架構是指設計軟體的人為軟體賦予的形狀,這個形狀是指系統如何被劃分為組件 (Components),各個組件如何排列(Arrangement),組件之間如何溝通(Communicatio... ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...