win

// WinTimer.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
HINSTANCE g_hInst = NULL;
HANDLE  g_hStdOut = NULL;

LRESULT CALLBACK WndProc(HWND hWnd,UINT nMsg,
       WPARAM wParam,LPARAM lParam)
{
 switch(nMsg)
 {
 case WM_DESTROY:
  PostQuitMessage(0);
  return 0;
 }
 return DefWindowProc(hWnd,nMsg,
  wParam,lParam);
}

BOOL RegisterWnd(LPSTR pszClassName)
{
 WNDCLASSEX wce = {0};
 wce.cbSize=sizeof(wce);
 wce.cbClsExtra = 0;
 wce.cbWndExtra = 0;
 wce.hbrBackground = HBRUSH(COLOR_WINDOW);
 wce.hCursor = NULL;
 wce.hIcon = NULL;
 wce.hIconSm = NULL;
 wce.hInstance = g_hInst;
 wce.lpfnWndProc = WndProc;
 wce.lpszClassName = pszClassName;
 wce.lpszMenuName = NULL;
 wce.style  = CS_VREDRAW|CS_HREDRAW;

 ATOM atom = RegisterClassEx(&wce);
 if(0==atom)
 {
  return FALSE;
 }
  return TRUE;
 
}

HWND CreateWnd(LPSTR pszClassName)
{
 HWND hWnd = CreateWindowEx(0,pszClassName,
  "MyWnd",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
  CW_USEDEFAULT,CW_USEDEFAULT,
  CW_USEDEFAULT,NULL,NULL,
  g_hInst,0);
 return hWnd;
}

void DisplayWnd(HWND hWnd)
{
 ShowWindow(hWnd,SW_SHOW);
 UpdateWindow(hWnd);
}
void Message()
{
 MSG msg = {0};
 while(GetMessage(&msg,NULL,0,0))
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
}

void NewConsole()
{
 AllocConsole();
 g_hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
}
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
 NewConsole();
 g_hInst = hInstance;
 RegisterWnd("MyWnd");
 HWND hWnd = CreateWnd("MyWnd");
 DisplayWnd(hWnd);
 Message();
 return 0;
}

 

2393260622


#include "stdafx.h"
HINSTANCE g_hInst = NULL;


LRESULT CALLBACK WndProc(HWND hWnd,UINT nMsg,
       WPARAM wParam,
       LPARAM lParam)
{
 switch(nMsg)
 {
 case WM_DESTROY:
  PostQuitMessage(0);
  return 0;
 }

 return DefWindowProc(hWnd,nMsg,wParam,lParam);
}
//注册窗口
BOOL RegisterWnd(LPSTR pszClassName)
{
 WNDCLASSEX wce = {0};
 wce.cbSize = sizeof(wce);
 wce.cbClsExtra = 0;
 wce.cbWndExtra = 0;
 wce.hbrBackground = HBRUSH(COLOR_BTNFACE+1);
 wce.hCursor = NULL;
 wce.hIcon = NULL;
 wce.hIconSm = NULL;
 wce.hInstance = g_hInst;
 wce.lpfnWndProc = WndProc;
 wce.lpszClassName = pszClassName;
 wce.lpszMenuName = NULL;
 wce.style = CS_HREDRAW|CS_VREDRAW;
 ATOM atom = RegisterClassEx(&wce);
 if(0==atom)
 {
  return FALSE;
 }else
  return TRUE;
}

HWND CreateWnd(LPSTR pszClassName)
{
 HWND hWnd = CreateWindowEx(0,
  pszClassName,"MyWnd",
  WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  NULL,NULL,
  g_hInst,NULL);
 return hWnd;
}

void DisplayWnd(HWND hWnd)
{
 ShowWindow(hWnd,SW_SHOW);
 UpdateWindow(hWnd);
}

void Message()
{
 MSG msg={0};
 while(GetMessage(&msg,NULL,0,0))
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
}
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.

 g_hInst = hInstance;
 RegisterWnd("MyWnd");
 HWND hWnd = CreateWnd("MyWnd");
 DisplayWnd(hWnd);
 Message();
 return 0;
}

 

#include "resource.h"

2 图标资源ICON
 2.1 常用的几种大小 16*16    32*32  48*48
 2.2  LoadIcon
  HICON LoadIcon(HINSTANCE hInstance,LPCTSTR lpIconName);

加速键资源添加  资源 右击 Accel 
HACCEL LoadAccelerator(HINSTANCE hInstance LPCTSTR lpTableName)


09 day 11am 静态库  C C++    动态库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值