• WTL Hello World


    构建最简单的WTL Hello World程序,基于:WTL91_5321_Final + VS2013 + WIN7


    添加->新建项目




    为了简单起见,我们删除一些button和对应的处理代码(一般我们只需要修改dialog对应的.h/.cpp代码)

    MainDlg.h

    // MainDlg.h : interface of the CMainDlg class
    //
    /////////////////////////////////////////////////////////////////////////////
    
    #pragma once
    
    class CMainDlg : public CDialogImpl<CMainDlg>
    {
    public:
    	enum { IDD = IDD_MAINDLG };
    
    	BEGIN_MSG_MAP(CMainDlg)
    		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
    		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
    	END_MSG_MAP()
    
    // Handler prototypes (uncomment arguments if needed):
    //	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    //	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    //	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
    
    	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
    	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    };
    
    MainDlg.cpp
    // MainDlg.cpp : implementation of the CMainDlg class
    //
    /////////////////////////////////////////////////////////////////////////////
    
    #include "stdafx.h"
    #include "resource.h"
    
    #include "MainDlg.h"
    
    LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    {
    	// center the dialog on the screen
    	CenterWindow();
    
    	// set icons
    	HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
    	SetIcon(hIcon, TRUE);
    	HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
    	SetIcon(hIconSmall, FALSE);
    
    	return TRUE;
    }
    
    LRESULT CMainDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    {
    	EndDialog(wID);
    	return 0;
    }
    
    最初的运行样子:


    我们新建一个Static Text


    我们可以直接在Caption属性修改成我们想要的文字

    或者在OnInitDialog编码实现:

    CWindow wnd = this->GetDlgItem(IDC_STATIC);
    	CStatic *pEdit = (CStatic*)&wnd;
    	pEdit->SetWindowText(_T("Hello World"));

    更改字体:

    	CFont font;
    	font.CreatePointFont(16, TEXT("Arial"));
    
    	
    
    	CWindow wnd = this->GetDlgItem(IDC_STATIC);
    	CStatic *pEdit = (CStatic*)&wnd;
    
    	pEdit->SetFont(font);
    	pEdit->SetWindowText(_T("Hello World"));


    Keep it simple!
    作者:N3verL4nd
    知识共享,欢迎转载。
  • 相关阅读:
    Spring的事务处理机制
    英特尔诺基亚联手研发Symbian系统的智能手机
    国际最新LOGO设计趋势总结
    Java学习笔记_身份验证机制
    用Validator检查你的表单
    软件企业:细节造就竞争力
    优化软件性能的方法
    【开发经验】Struts常见错误及原因分析
    CF547E Mike and Friends
    [ZJOI2015]诸神眷顾的幻想乡
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/6616374.html
Copyright © 2020-2023  润新知