Windows窗口模板

写在前面:
大家好,我是 花狗Fdog ,来自内蒙古的一个小城市,目前在泰州读书。
很感谢能有这样一个平台让我能够在这里分享所学所感。
我喜欢编程,喜欢代码,喜欢去做一个程序员。
努力学习,争取多年后,给亲人更好的生活。
QQ/WX:2506897252 欢迎交流。

1.界面效果

在这里插入图片描述

2.相关代码

#include<Windows.h>
LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdshow)
{
static TCHAR szAppName[] = TEXT("你好");
 HWND hwnd;
 MSG msg;
 WNDCLASS wndclass;
 wndclass.style = CS_VREDRAW | CS_HREDRAW;//窗口风格
 wndclass.lpfnWndProc = WindowProc;  //消息响应
 wndclass.cbClsExtra = 0;
 wndclass.cbWndExtra = 0;
 wndclass.hInstance = hInstance;//句柄
 wndclass.hIcon = LoadIcon(NULL, IDI_ERROR);//图标
 wndclass.hCursor = LoadCursor(NULL, IDI_APPLICATION);//光标
 wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);//背景
 wndclass.lpszMenuName= NULL;
 wndclass.lpszClassName = szAppName;
 if (!RegisterClass(&wndclass))
 {
   MessageBox(NULL, TEXT("This program requires Windows NT!"),
   szAppName, MB_ICONERROR);
  return 0;
 }
  hwnd=CreateWindow( szAppName,
  TEXT("第二个程序"),
  WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT, // initial x position  
  CW_USEDEFAULT, // initial y position    
  CW_USEDEFAULT, // initial x size   
  CW_USEDEFAULT, // initial y size  
  NULL,   // parent window handle  
  NULL,         // window menu handle  
  hInstance,     // program instance handle   
  NULL) ;      // creation parameters
 ShowWindow(hwnd, nCmdshow);
 UpdateWindow(hwnd);
 while (GetMessage(&msg,NULL,0,0))
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
 return 0;
 }
 LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
 HDC hdc;
 PAINTSTRUCT ps;
 RECT  rect;
 switch (uMsg)
 {
  case WM_CREATE:
  return 0;
  case WM_PAINT:
  return 0;
 case WM_DESTROY:   
  return 0;
 }
  return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

如有不对,欢迎指出,期待我的下一篇文章。
每文一句:穷人并不是指身无分文的人,而是指没有理想的人。

发布了15 篇原创文章 · 获赞 41 · 访问量 6150

猜你喜欢

转载自blog.csdn.net/Fdog_/article/details/102734127
今日推荐