鱼C论坛

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

WINDOW程序问题只显示进程,不显示界面

[复制链接]
发表于 2016-2-17 13:28:44 | 显示全部楼层 |阅读模式
10鱼币
  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.         static TCHAR szAppName[] = TEXT("MyWindows");
  6.         HWND hwnd;
  7.         MSG msg;
  8.         WNDCLASS wndclass;

  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(NULL, IDI_APPLICATION);
  15.         wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
  16.         wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  17.         wndclass.lpszClassName = NULL;
  18.         wndclass.lpszClassName = szAppName;

  19.         //if(!RegisterClass(&wndclass))
  20.         //{
  21.         //        MessageBox(NULL, TEXT("这个程序需要在 Windows NT 才能执行! "),szAppName, MB_ICONERROR);
  22.         //        return 0;

  23.         //}

  24.         hwnd = CreateWindow(szAppName,
  25.                         TEXT("鱼C工作室"),
  26.                         WS_OVERLAPPEDWINDOW,
  27.                         CW_USEDEFAULT,
  28.                         CW_USEDEFAULT,
  29.                         CW_USEDEFAULT,
  30.                         CW_USEDEFAULT,
  31.                         NULL,
  32.                         NULL,
  33.                         hInstance,
  34.                         NULL);

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

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

  42.         return msg.wParam;
  43. }

  44. LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  45. {
  46.         HDC hdc;
  47.         PAINTSTRUCT ps;
  48.         RECT rect;
  49.         int i;

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

  55.                 for(i = rect.left; i <= rect.right; i++)
  56.                 {
  57.                         SetPixel(hdc, i, 100, RGB(255, 0, 0));
  58.                 }

  59.                 EndPaint(hwnd, &ps);
  60.                 return 0;

  61.         case WM_DESTROY:
  62.                 PostQuitMessage(0);
  63.                 return 0;
  64.         }

  65.         return DefWindowProc(hwnd, message, wParam, lParam);
  66. }





复制代码




生成了单打开只显示进程,不显示 界面 ,  求解,
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

头像被屏蔽
发表于 2016-6-15 20:22:10 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-20 21:55

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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