A simple windows programm in c
        
The following programm is a minimal windows program. It opens a window and writes a text into the window.
If you compile it with MinGW, be sure to add the -mwindows flag in order to prevent the ... undefined reference to 'TextOutA@20' and ... undefined reference to 'GetStockObject@4 linker error.

#include <windows.h>

LRESULT CALLBACK WndProc(
    HWND   hWnd,
    UINT   msg,
    WPARAM wParam,
    LPARAM lParam ) {

switch( msg ) {
    case WM_PAINT: {
      PAINTSTRUCT ps;
      HDC hDC = BeginPaint( hWnd, &ps );
      TextOut(hDC, 10, 10, "ADP GmbH", 8 );
      EndPaint( hWnd, &ps );
    }
    break;

case WM_DESTROY:
      PostQuitMessage(0);
    break;

default:
      return DefWindowProc( hWnd, msg, wParam, lParam);
  }
  return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int nCmdShow) {

WNDCLASSEX wce;

wce.cbSize        = sizeof(wce);
  wce.style         = CS_VREDRAW | CS_HREDRAW;
  wce.lpfnWndProc   = (WNDPROC) WndProc;
  wce.cbClsExtra    = 0;
  wce.cbWndExtra    = 0;
  wce.hInstance     = hInstance;
  wce.hIcon         = LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
  wce.hCursor       = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
  wce.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
  wce.lpszMenuName  = 0;
  wce.lpszClassName = "ADPWinClass",
  wce.hIconSm       = 0;
 
  if (!RegisterClassEx(&wce)) return 0;
 
  HWND hWnd = CreateWindowEx(
    0,          // Ex Styles
    "ADPWinClass",
    "ADP GmbH",
     WS_OVERLAPPEDWINDOW,
     CW_USEDEFAULT,  // x
     CW_USEDEFAULT,  // y
     CW_USEDEFAULT,  // Height
     CW_USEDEFAULT,  // Width
     NULL,           // Parent Window
     NULL,           // Menu, or windows id if child
     hInstance,      //
     NULL            // Pointer to window specific data
  );

ShowWindow( hWnd, nCmdShow );

MSG msg;
  int r;
  while ((r = GetMessage(&msg, NULL, 0, 0 )) != 0) {
    if (r == -1) {
      ;  // Error!
    }
    else {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
  }

// The application's return value
  return msg.wParam;
};

A simple windows programm in c的更多相关文章

  1. Simple Windows Service in C++

    本文是来自CodeProject中的一篇名为Simple Windows Service in C++的译文,原文地址为:https://www.codeproject.com/Articles/49 ...

  2. A basic Windows service in C++ (CppWindowsService)

    A basic Windows service in C++ (CppWindowsService) This code sample demonstrates creating a basic Wi ...

  3. C#高级编程(第六版)学习:第三十一章:Windows窗体

    第三十一章 Windows窗体 创建Windows窗体应用程序 在文本编辑器中输入: /* * form.cs * a simple windows form * */ using System; u ...

  4. 30+ Excellent Windows Phone 7 Development Tutorials

    原文发布时间为:2012-01-16 -- 来源于本人的百度文章 [由搬家工具导入] Here are 30+ cool Windows Phone Development articles for ...

  5. windows server使用 LetsEncrypt-Win-Simple来安装和使用用Let's Encrypt免费SSL证书

    一.网站部署 LetsEncrypt-Win-Simple可以自动发现已经部署的网站供我们选择要生成证书的网站,而且还需要进行验证.所以在生成证书之前,确保网站已经部署好并可以正常访问. 二.生成证书 ...

  6. 使用 C++ 编写的基础 Windows 服务 (CppWindowsService)

    最近项目中涉及到使用C++写一个后台服务程序,找了很多资料,还是使用Google搜索找到了比较详细点的资料,就是从微软官方MSDN的例子,如下: 使用 C++ 编写的基础 Windows 服务 (Cp ...

  7. windows pip 安装 转载

    经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的 ...

  8. Windows下更改pip镜像源

    其实学习是一个逐步探索的过程.今天因为把带有中文的Python安装路径给改了,结果带来很大的麻烦,导致在命令行输入vietualenv和其他一些第三方模块都出现Fatal error in launc ...

  9. windows下python自带的pip安装速度过慢解决方案

    自带下载地址为国外源下载速度时常在20KB以内切换为国内源直接满速! 国内源: 新版ubuntu要求使用https源,要注意. 清华:https://pypi.tuna.tsinghua.edu.cn ...

随机推荐

  1. c++开发之对应Linux下的sem_t和lock

    http://www.cnblogs.com/P_Chou/archive/2012/07/13/semaphore-and-mutex-in-thread-sync.html http://blog ...

  2. ThinkPHP项目笔记之函数篇

    说到函数,可能有人会想:框架的C(控制器)通牌都是函数构成的,没有必要讲吧. 当然,我要说的是,公共函数:function.php,该文件就是为了开发一下功能准备的,比方说,某个功能,a地方可用,b地 ...

  3. v8随心记

    因为node原因,研究v8已经有段时间了,但是一直也没有抽空写点什么,现在想想有好多当时清晰的东西又模糊了.哎,伤心的很啊.但是一时又想不起什么章法,所以只能随手胡乱写了. 下载.编译: https: ...

  4. python3----练习题(爬取电影天堂资源,大学排名,淘宝商品比价)

    import requests import re url = 'http://www.ygdy8.net/html/gndy/dyzz/list_23_{}.html' for n in range ...

  5. AWS系列-使用Could Events定时对EC2打快照

    第1章 使用Could Events定时对EC2打快照 1.1 打开控制台搜索CloudWatch 在搜索栏输入CloudWatch,点击进入CloudWatch控制台 1.2 选择进入Events ...

  6. open() 函数以 r+ 模式打开文件

    第一种用法:如果我们对文件进行写操作,则默认会从第一行开始写,且直接覆盖第一行的内容 [root@localhost ~]$ cat 1.txt # 文件内容如下 aaa bbb ccc In [1] ...

  7. UE4 Multiplayer多人局域网LAN联机打包参数设置

    需要注意几点: A. 建好后我们先到项目根目录,在Config文件夹中的DefaultEngine.ini文件加上两行: [OnlineSubsystem]  DefaultPlatformServi ...

  8. 【BZOJ4873】[Shoi2017]寿司餐厅 最大权闭合图

    [BZOJ4873][Shoi2017]寿司餐厅 Description Kiana最近喜欢到一家非常美味的寿司餐厅用餐.每天晚上,这家餐厅都会按顺序提供n种寿司,第i种寿司有一个代号ai和美味度di ...

  9. Android 调用系统相机拍照保存以及调用系统相册的方法

    系统已经有的东西,如果我们没有新的需求的话,直接调用是最直接的.下面讲讲调用系统相机拍照并保存图片和如何调用系统相册的方法. 首先看看调用系统相机的核心方法: Intent camera = new ...

  10. 170418、vmware 安装 centos 开启网卡自启动

    前言:CentOS虚拟机安装成功后,默认开机未启用网关,通过修改配置文件,启用网卡 开启方法如下: 1.登录系统,虚拟机安装完成后,第一次登录系统,系统只有一个账号,即超级管理员root账户,输入安装 ...