
VC++
日出东升我方觉醒
C/C++
展开
-
C++ 文本编程实践
新建MFC Test项目文本插入符:int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct){ if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: 在此添加您专用的创建代码 //创建设备描述表 CClientDC dc(this); //定义文本信息结构体变量 TEXTMETRIC tm; //获取...原创 2020-10-14 17:10:40 · 326 阅读 · 0 评论 -
C++ MoveToEx和LineTo函数画图
函数MoveToEx和LineTo声明如下:WINGDIAPI BOOLWINAPI MoveToEx( __in HDC hdc, __in int x, __in int y, __out_opt LPPOINT lppt);hdc是当前设备的句柄。x是X轴的位置,水平方向,一般原点是在屏幕左上角的位置。y是Y轴的位置,垂直方向。lppt是移动前的坐标位置。WINGDIAPI BOOL WINAPI LineTo( __in HDC hdc, __in int x, __..原创 2020-09-17 11:03:33 · 5877 阅读 · 0 评论 -
C++ 引用是指一个变量的别名,它需要用另一个变量或者对象来初始化自身。
#include <iostream>using namespace std;void change(int &a,int &b);//引用是指一个变量的别名,它需要用另一个变量或者对象来初始化自身。int main(){ std::cout << "Hello World!\r\n"; int z = 5; int &w = z;//用&表示申明一个引用,引用必须在申明时进行初始化 int h = 333;...原创 2020-09-16 10:00:11 · 868 阅读 · 0 评论 -
C++ 函数的覆盖与隐藏
#include <iostream>using namespace std;class Animal{public: void eat(int x) { cout << "animal eat(int x) x=" << x << endl; } void sleep(int y) { cout << "animal sleep(int y) y=" <&l...原创 2020-09-16 09:45:32 · 647 阅读 · 0 评论 -
//虚函数和多态性的区别
#include <iostream>using namespace std;//虚函数和多态性class Animal{public: void eat() { cout << "animal eat" << endl; } void sleep() { cout << "animal sleep" << endl; } void breath...原创 2020-09-15 19:20:02 · 186 阅读 · 0 评论 -
C++ 多重继承 一个类可以从多个基类中派生
#include <iostream>using namespace std;//多重继承//一个类可以从多个基类中派生。在派生类由多个基类派生的多重继承模式中,//基类是用基类表语法成分来说明的,多重继承的语法与单一继承很类似,//只需要在声明继承的多个类之间加上逗号来分隔class B1{public: void output();};class B2{public: void output();};void B1::output(){...原创 2020-09-15 18:28:24 · 5795 阅读 · 0 评论 -
在构造子类时,显式地去调用父类的带参数的构造函数。
#include <iostream>using namespace std;//在父类(Animal类)中修改构造函数,增加两个参数height和weight,分别表示动物的高度与重量class Animal{public: Animal(int height,int weight) { cout << "animal construct" << endl; } ~Animal() { ...原创 2020-09-15 17:51:06 · 477 阅读 · 0 评论 -
父类与子类 析构与构造的调用顺序
#include <iostream>using namespace std;//父类与子类 析构与构造的调用顺序class Animal{public: Animal() { cout << "animal construct" << endl; } ~Animal() { cout << "animal destruct" << endl; } v...原创 2020-09-15 17:17:30 · 403 阅读 · 0 评论 -
C++ 类的继承 派生类除了自己的成员变量和成员方法外,还可以继承基类的成员变量和成员方法
#include <iostream>using namespace std;//类的继承//定义一个动物类,对于动物来说,它应该具有吃、睡和呼吸的方法class Animal{public: void eat() { cout << "animal eat" << endl; } void sleep() { cout << "animal sleep" << ...原创 2020-09-15 17:09:32 · 639 阅读 · 0 评论 -
VC++ this指针(Point函数中的成员变量对于是 函数void input(int x, int y)是不可见的)
#include <iostream>using namespace std;class Point{public: int x; int y; Point() { x = 0; y = 0; } Point(int a,int b) { x = a; y = b; } void input(int x, int y) { ...原创 2020-09-15 16:11:10 · 313 阅读 · 0 评论 -
VC++ 构造函数的作用 若不初始化这个内存空间的值是一个随机值,构造函数就是对类中的成员进行初始化
#include <iostream>using namespace std;class Point{public: int x; int y; void output() { cout << x << endl << y << endl; }};int main(){ std::cout << "Hello World!\n"; Poi...原创 2020-09-15 15:49:26 · 149 阅读 · 0 评论 -
VC++深入详解 第二章例子
#include <windows.h>#include <stdio.h>LRESULT CALLBACK WinSunProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nCmdShow){ //typedef struct tagWND...原创 2020-09-15 15:21:31 · 1199 阅读 · 0 评论 -
敲书中例子遇到这个问题:error LNK2019-无法解析的外部符号 _main-该符号在函数 ___tmainCRTStartup 中被引用
#include <windows.h>#include <stdio.h>LRESULT CALLBACK WinSunProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nCmdShow){ WNDCLASS wndcls; w...转载 2020-09-15 14:35:57 · 920 阅读 · 0 评论 -
MFC SerialPort类
Run-Time Check Failure #3 - The variable 'comstat' is being used without being initialized这里我只是试了方案1:方案1: 改变项目配置属性一种解决方案是改变基本运行时检查(changing the runtime checks in project settings):在菜单Project->Project properties-> C/C++ -> Code generation->转载 2020-06-16 11:24:08 · 735 阅读 · 0 评论 -
MFC SerialPort 类试了下485通迅
资源链接 https://mp.youkuaiyun.com/console/uploadResources原创 2020-06-16 11:08:53 · 331 阅读 · 0 评论 -
OnSysCommand
截获系统控制命令OnSysCommand 这个函数不是使用者调用,是使用者重写这个函数,当然使用者指的是使用MFC编程的人。在函数里写自己的逻辑,当然也有必要调用一下它的父类这个函数,以便让系统处理一些默认的功能,有如下伪代码表示这个意思void OnSysCommand(UINT nID, LPARAM lParam){ if("命令码" == 我要专门处理的命令码) { 我处理 }else { 系统来处理CMai...转载 2020-06-09 11:08:51 · 1131 阅读 · 0 评论 -
OnPaint()和OnQueryDragIcon()
OnPaint()是重绘。为WM_PAIN消息CDialog::OnPaint()是给对话框一个描画的机会(WM_PAINT事件的响应)。如果没有特殊的描画任务,就不必改写OnPaint()。CDialog::OnPaint()将调用CWnd的OnPaint(),CWnd的OnPaint()接着调用LRESULT CWnd::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)到了这个函数就意味着,用户对一个事件没有作处理,而是交给系统处理...转载 2020-06-09 10:50:15 · 667 阅读 · 0 评论 -
WM_ICONERASEBKGND
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);这个函数,是发送WM_ICONERASEBKGND到本窗口消息队列,(WPARAM) dc.GetSafeHdc(), 是响应这个消息的函数的参数。WM_ICONERASEBKGND发送给某个最小化窗口,仅当它在画图标前它的背景必须被重画后面获取图标信息,设置,然后重新画(以下参考自MSDN)在计算机绘制窗口类的图标前,系统发送一个WM_ICONERASEBKGND消息转载 2020-06-09 10:23:06 · 242 阅读 · 0 评论 -
GetSystemMetrics 系统指标或者配置设置
GetSystemMetrics是一个计算机函数,该函数只有一个参数,称之为「索引」,这个索引有75个标识符,通过设置不同的标识符就可以获取系统分辨率、窗体显示区域的宽度和高度、滚动条的宽度和高度。The GetSystemMetrics function retrieves various system metrics (widths and heights of display elements) and system configuration settings. Alldimensions re原创 2020-06-09 10:14:12 · 1247 阅读 · 0 评论