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. LoadRunner中winsocket协议学习

    首先让我们先看一下loadrunner- winsock 函数 一览表:        lrs_accept_connection 接受侦听套接字连接 lrs_close_socket 关闭打开的套接 ...

  2. VC++ GetSafeHwnd()和GetSafeHandle()

    GetSafeHwnd()和GetSafeHandle()的主要区别: 使用者不同: (1)窗体使用:GetSafeHwnd()用于获取窗体的安全句柄(即HWND),有了HWND我们就可以方便的对HW ...

  3. SQL的学习

    1. 判断表达式的值是否为空在表达式后面接 IS NULL 或 IS NOT NULL 可以判断表达式是否为空或不为空 2. 把数据库中的数据导出成可执行的SQL语句对数据库点击右键一次选择 任务-- ...

  4. Xmanager连接图形界面

    1.编辑gnome配置文件vim /etc/gdm/custom.conf # GDM configuration storage [daemon]RemoteGreeter= /usr/libexe ...

  5. 调用PostgreSQL存储过程,找不到函数名的问题

    PostgreSQL的表,函数名称都是严格区分大小写的,所以在使用的时候没有注意大小写问题容易导致找不到函数名的错误,但最近两天我们发现,如果函数参数使用了自定义的数据类型,也会发生这个问题. 问题描 ...

  6. 三 Android Studio打包EgretApp (SDK选择和下载)

    一 设置项目的sdk路径 二 设置项目使用sdk版本 一 设置项目的sdk路径 设置SDK目录 选择你电脑上的sdk路径 二 在项目中设置SDK版本 在项目中设置编译的sdk版本 在SDK Manag ...

  7. android EditText自动弹出和自动关闭软键盘

    程序进入某个activity直接弹出软键盘,不能直接在OnCreate中设置,必须等View绘制事件完毕才可以弹出,需要用到Timer辅助实现,如果要实现输入的功能,必须让EditText获得焦点. ...

  8. Netty 服务端创建

    参考:http://blog.csdn.net/suifeng3051/article/details/28861883?utm_source=tuicool&utm_medium=refer ...

  9. Oracle Schema Objects——Tables——Oracle Data Types

    Oracle Schema Objects Oracle Data Types 数据类型 Data Type Description NUMBER(P,S) Number value having a ...

  10. UIAlertAction 改变字体颜色

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil pre ...