鱼C论坛

 找回密码
 立即注册
查看: 2113|回复: 1

小甲鱼老师第九课的例子怎么加滚动条?

[复制链接]
发表于 2017-1-2 13:51:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
刚学到滚动条, 突然想到这小甲鱼的这个例子, 折腾了很久还是加不上滚动条



  1. #include <Windows.h>

  2. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

  3. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
  4. {
  5.         WNDCLASS wndclass;
  6.         static TCHAR* szAppName = TEXT("abc");
  7.         HWND hwnd;
  8.         MSG msg;


  9.         wndclass.style = CS_HREDRAW | CS_VREDRAW;
  10.         wndclass.lpfnWndProc = WndProc;
  11.         wndclass.cbClsExtra = 0;
  12.         wndclass.cbWndExtra = 0;
  13.         wndclass.hInstance = hInstance;
  14.         wndclass.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
  15.         wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  16.         wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  17.         wndclass.lpszMenuName = NULL;
  18.         wndclass.lpszClassName = szAppName;


  19.         if (!RegisterClass(&wndclass))
  20.         {
  21.                 MessageBox(NULL, TEXT("程序只能在 Windows NT 下运行"),
  22.                         szAppName, MB_ICONERROR);

  23.                 return 0;
  24.         }

  25.         hwnd = CreateWindow(szAppName,
  26.                 TEXT("abc"),
  27.                 WS_OVERLAPPEDWINDOW,
  28.                 CW_USEDEFAULT,
  29.                 CW_USEDEFAULT,
  30.                 600, 400,
  31.                 NULL, NULL,
  32.                 hInstance,
  33.                 NULL);

  34.         ShowWindow(hwnd, iCmdShow);
  35.         UpdateWindow(hwnd);

  36.         while (GetMessage(&msg, NULL, 0, 0))
  37.         {
  38.                 TranslateMessage(&msg);
  39.                 DispatchMessage(&msg);
  40.         }
  41.         return msg.wParam;
  42. }

  43. LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  44. {
  45.         PAINTSTRUCT ps;
  46.         HDC hdc;
  47.         TCHAR szBuffer[128];
  48.         int i;


  49.         switch (message)
  50.         {
  51.         case WM_PAINT:
  52.                 hdc = BeginPaint(hwnd, &ps);

  53.                 for (i = 0; i < 100; i++)
  54.                 {
  55.                         wsprintf(szBuffer, TEXT("%d:  %s"), i + 1, TEXT("I love FishC.com!"));
  56.                         TextOut(hdc, 0, i * 15, szBuffer, lstrlen(szBuffer));
  57.                 }

  58.                 EndPaint(hwnd, &ps);

  59.                 return 0;

  60.         case WM_DESTROY:

  61.                 PostQuitMessage(0);
  62.                 return 0;
  63.         }

  64.         return DefWindowProc(hwnd, message, wParam, lParam);
  65. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-1-8 14:54:27 | 显示全部楼层
你应该好好把小甲鱼老师的SDK里面的滚动条视频好好看下  CreateWindow函数的参数看看,
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 22:08

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表