A simple windows programm in c
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的更多相关文章
- Simple Windows Service in C++
本文是来自CodeProject中的一篇名为Simple Windows Service in C++的译文,原文地址为:https://www.codeproject.com/Articles/49 ...
- A basic Windows service in C++ (CppWindowsService)
A basic Windows service in C++ (CppWindowsService) This code sample demonstrates creating a basic Wi ...
- C#高级编程(第六版)学习:第三十一章:Windows窗体
第三十一章 Windows窗体 创建Windows窗体应用程序 在文本编辑器中输入: /* * form.cs * a simple windows form * */ using System; u ...
- 30+ Excellent Windows Phone 7 Development Tutorials
原文发布时间为:2012-01-16 -- 来源于本人的百度文章 [由搬家工具导入] Here are 30+ cool Windows Phone Development articles for ...
- windows server使用 LetsEncrypt-Win-Simple来安装和使用用Let's Encrypt免费SSL证书
一.网站部署 LetsEncrypt-Win-Simple可以自动发现已经部署的网站供我们选择要生成证书的网站,而且还需要进行验证.所以在生成证书之前,确保网站已经部署好并可以正常访问. 二.生成证书 ...
- 使用 C++ 编写的基础 Windows 服务 (CppWindowsService)
最近项目中涉及到使用C++写一个后台服务程序,找了很多资料,还是使用Google搜索找到了比较详细点的资料,就是从微软官方MSDN的例子,如下: 使用 C++ 编写的基础 Windows 服务 (Cp ...
- windows pip 安装 转载
经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的 ...
- Windows下更改pip镜像源
其实学习是一个逐步探索的过程.今天因为把带有中文的Python安装路径给改了,结果带来很大的麻烦,导致在命令行输入vietualenv和其他一些第三方模块都出现Fatal error in launc ...
- windows下python自带的pip安装速度过慢解决方案
自带下载地址为国外源下载速度时常在20KB以内切换为国内源直接满速! 国内源: 新版ubuntu要求使用https源,要注意. 清华:https://pypi.tuna.tsinghua.edu.cn ...
随机推荐
- iScroll框架的使用和修改
iScroll 的诞生是因为手机 Webkit 浏览器(iPhone.iPod.Android 和 Pre)本身没有为固定宽度和高度的元素提供滚动内容的方法.这导致了很多网页使用 position:a ...
- 【BZOJ】1052: [HAOI2007]覆盖问题(贪心)
http://www.lydsy.com/JudgeOnline/problem.php?id=1052 首先膜拜题解orz,表示只能想到二分... 贪心就是每一次找到一个最小的能包围所有点的矩阵,然 ...
- 【POJ】1523 SPF(割点)
http://poj.org/problem?id=1523 太弱... too weak.. 割点我都还要看书和看题解来写..果然是写不出么.. 割点就那样求,然后分量直接这个节点有多少子树就有子树 ...
- 用 HTML5+ payment方法支付宝支付遇到的坑
用 HTML5+ payment方法碰到的第一个坑就是如果是支付宝的话签约那种支付方式. 因为 Dcloud的文档没有更新的原因你可以看到他们说的都是‘移动支付’,但是你去支付宝平台的时候看到的根本就 ...
- 如何用几何画板画V型尖波函数图像
虽然几何画板没有编程功能,无法直接进行逻辑判断,但通过恰当地运用sgn.trunc等函数可以间接地画出一些特殊函数图像,比如V型尖波函数图像,下面将详细介绍如何用几何画板画V型尖波函数图像. 具体的操 ...
- C语言数组元素的查询
在实际开发中,经常需要查询数组中的元素.例如,学校为每位同学分配了一个唯一的编号,现在有一个数组,保存了实验班所有同学的编号信息,如果有家长想知道他的孩子是否进入了实验班,只要提供孩子的编号就可以,如 ...
- windows mysql初始化
参考文章 https://dev.mysql.com/doc/refman/5.7/en/windows-install-archive.html mysqld --initialize --user ...
- centos-iptables-scripts
author:headsen chen date:2018-06-04 11:20:38 notice:This article is created by headsen chen himsel ...
- GitHubDesktop的使用方法
author:headsen chen date:2018-05-30 17:24:55 notice:This article is created by headsen chen hims ...
- 【BZOJ2049,2631,3282,1180】LCT模板四连A
好吧我并不想讲LCT 只是贴4个代码~ [BZOJ2049][Sdoi2008]Cave 洞穴勘测 #include <cstdio> #include <cstring> # ...