MFC: 孙鑫教程1笔记

http://msdn.microsoft.com/en-us/library/900ks98t.aspx

typedef struct tagMSG {

  HWND   hwnd;

  UNIT     message;

  WPARAM   wParam;

  LPARAM    lParam;

  DWORD    time;

  POINT       pt;

} MSG;

 

http://msdn.microsoft.com/en-us/library/aa930760.aspx

int WINAPI WinMain (

  HINSTANCE    hInstance,

  HINSTANCE    hPrevInstance,

  LPWSTR         lpCmdLine,

  int                 nShowCmd,

);

 

http://msdn.microsoft.com/en-us/library/aa925944.aspx

typedef struct tagWNDCLASS {

  UINT                  style;

  WNDPROC          lpfnWndProc;

  int                     cbClsExtra;

  int                     cbWndExtra;

  HINSTANCE        hInstance;

  HICON               hIcon;

  HCURSOR          hCursor;

  HBRUSH            hbrBackground;

  LPCTSTR    lpszMenuName;

  LPCTSTR    lpszClassName;

} WNDCLASS;

 

http://msdn.microsoft.com/en-us/library/aa921556.aspx

HGDIOBJ GetStockObject( int fnObject );

 

http://msdn.microsoft.com/en-us/library/aa931018.aspx

HWND CreateWindow (

  LPCTSTR  lpClassName,

  LPCTSTR  lpWindowName,

  DWORD  dwStyle,

  int     x,

  int     y,

  int      nWidth,

  int      nHeight,

  HWND    hWndParent,

  HMENU   hMenu,

  HANDLE   hInstance,

  PVOID    lpParam

);

 

http://msdn.microsoft.com/zh-cn/ms913089

ATOM RegisterClass(const WNDCLASS *lpWndClass);

 

http://msdn.microsoft.com/zh-cn/aa932387

BOOL ShowWindow(HWND hWnd, int nCmdShow);

 

http://msdn.microsoft.com/zh-cn/office/aa932747

BOOL UpdateWindow(HWND hWnd);

 

http://msdn.microsoft.com/en-us/library/aa921213.aspx

BOOL GetMessage(

  LPMSG  lpMsg,

  HWND  hWnd,

  UINT    wMsgFilterMin,

  UINT    wMsgFilterMax

);

 

http://msdn.microsoft.com/en-us/library/aa925780.aspx

LRESULT CALLBACK WindowProc (

  HWND  hwnd,

  UINT    uMsg,

  WPARAM wParam,

  LPARAM   lParam

);

 

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx

int MessageBox(

  HWND   hWnd,

  LPCTSTR lpText,

  LPCTSTR   lpCaption,

  UINT     uType

);

 

http://msdn.microsoft.com/zh-cn/aa921543

HDC GetDC(HWND hWnd);

 

http://msdn.microsoft.com/en-us/library/windows/desktop/dd145133(v=vs.85).aspx

BOOL TextOut(

  HDC  hdc,

  int      nXStart,

  int      nYStart,

  LPCTSTR    lpstring,

  int     cchString

);

 

http://msdn.microsoft.com/zh-cn/aa922023

HDC BeginPaint (

  HWND         hwnd,

  LPPAINTSTRUCT  lpPaint

);

 

http://msdn.microsoft.com/en-us/library/aa929827.aspx

BOOL DestroyWindow (HWND hWnd);

 

http://msdn.microsoft.com/en-us/library/aa922965.aspx

void PostQuitMessage(int nExitCode);

 

创建一个空项目

 1 #include <windows.h>

 2 #include <stdio.h>

 3 

 4 LRESULT CALLBACK WinSunProc(

 5     HWND hwnd, 

 6     UINT uMsg, 

 7     WPARAM wParam, 

 8     LPARAM lParam

 9 );

10 

11 

12 int WINAPI WinMain(

13     HINSTANCE hInstance, 

14     HINSTANCE hPrevInstance, 

15     LPTSTR lpCmdLine, 

16     int nShowCmd

17 )

18 {

19     WNDCLASS wndcls;

20     wndcls.cbClsExtra = 0;

21     wndcls.cbWndExtra = 0;

22     wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

23     wndcls.hCursor = LoadCursor(NULL, IDC_CROSS);

24     wndcls.hIcon = LoadIcon(NULL, IDI_APPLICATION);

25     wndcls.hInstance = hInstance;

26     wndcls.lpfnWndProc = WinSunProc;

27     wndcls.lpszClassName = "Weixin2014";

28     wndcls.lpszMenuName = NULL;

29     wndcls.style = CS_HREDRAW | CS_VREDRAW;

30     RegisterClass(&wndcls);

31 

32     HWND hwnd;

33     hwnd = CreateWindow("Weixin2014", 

34                       "南京熊猫电子装备有限公司", 

35                       WS_OVERLAPPEDWINDOW,

36                       CW_USEDEFAULT,

37                       CW_USEDEFAULT,

38                       CW_USEDEFAULT,

39                       CW_USEDEFAULT,

40                       NULL,

41                       NULL,

42                       hInstance,

43                       NULL);

44     ShowWindow(hwnd, SW_SHOWNORMAL);

45     UpdateWindow(hwnd);

46     

47     MSG msg;

48     while(GetMessage(&msg, NULL, 0, 0)) 

49     {

50         TranslateMessage(&msg);

51         DispatchMessage(&msg);

52     }

53     return 0;

54 }

55 

56 LRESULT CALLBACK WinSunProc(

57     HWND hwnd, 

58     UINT uMsg, 

59     WPARAM wParam, 

60     LPARAM lParam

61 )

62 {

63     switch (uMsg)

64     {

65     case WM_CHAR:

66         char szChar[20];

67         sprintf_s(szChar, sizeof(szChar), "char is %d", wParam);

68         MessageBox(hwnd, szChar, "weixin", 0);

69         break;

70     case WM_LBUTTONDOWN:

71         MessageBox(hwnd, "mouse clicked", "weixin", 0);

72         HDC hdc;

73         hdc = GetDC(hwnd);

74         TextOut(hdc, 0, 50, "研发团队", strlen("研发团队"));

75         ReleaseDC(hwnd, hdc);

76         break;

77     case WM_PAINT:

78         HDC hDC;

79         PAINTSTRUCT ps;

80         hDC = BeginPaint(hwnd, &ps);

81         TextOut(hDC, 0, 0, "yingzhongwen", strlen("yingzhongwen"));

82         EndPaint(hwnd, &ps);

83         break;

84     case WM_CLOSE:

85         if (IDYES == MessageBox(hwnd, "exit?", "weixin", MB_YESNO))

86         {

87             DestroyWindow(hwnd);

88         }

89         break;

90     case WM_DESTROY:

91         PostQuitMessage(0);

92         break;

93     default:

94         return DefWindowProc(hwnd, uMsg, wParam, lParam);

95     }

96     return 0;

97 }
View Code

 

你可能感兴趣的:(mfc)