易码技术论坛

 找回密码
 加入易码
搜索
查看: 443372|回复: 15

在C语言中,窗口是怎么做出来的?

[复制链接]
发表于 2006-12-26 22:15:52 | 显示全部楼层
Windows窗口是用Win32API做的。至于怎么做Windows应用程序建议去看看《Programming Windows》
发表于 2006-12-26 22:19:18 | 显示全部楼层
窗口与语言无关
 楼主| 发表于 2006-12-27 10:28:44 | 显示全部楼层
那窗口中的最大化最小化的功能都不是用C语言写出来的罗?
还有,那个鼠标坐标是怎么得到的?
发表于 2006-12-27 10:39:06 | 显示全部楼层
就是说:窗口是操作系统的一部分,而不上语言的特性
用basic语言也可写窗口
 楼主| 发表于 2006-12-27 10:51:55 | 显示全部楼层
那如果要学做windows下的*.exe应用程序一般要看什么书呢?LEE能帮我推荐一本吗?我好买来系统学习一下!谢谢了!
发表于 2006-12-27 12:23:27 | 显示全部楼层
我的沙发贴不就告诉你了么...算了...都被无视了...
 楼主| 发表于 2006-12-27 13:48:56 | 显示全部楼层
引用第6楼yzk03702006-12-27 12:23发表的“”:
我的沙发贴不就告诉你了么...算了...都被无视了...
非常抱歉!是我大意了!谢谢你啊!
谢谢大家的帮忙!
发表于 2007-1-1 19:20:14 | 显示全部楼层
最近淘到一本《Windows下的C/C++高级编程》,好像刚好就可以回答LZ的问题~~
发表于 2007-1-9 17:00:52 | 显示全部楼层
用C#吧,那个做窗口容易~
发表于 2007-1-27 18:09:18 | 显示全部楼层
WIN32API
发表于 2007-2-7 18:52:08 | 显示全部楼层
Windows 窗口 有专门的API函数
C可能难以实现一点
发表于 2007-2-7 23:44:21 | 显示全部楼层
我觉得还是Delphi好,很多东西都设计好了的,虽然说最近Borland发展得不怎么样,我还是一直支持Delphi的(偶Pascal学开头的,呵呵!)
发表于 2007-2-15 22:14:07 | 显示全部楼层
学 VC#  直接就可以画窗口
发表于 2007-2-15 22:18:18 | 显示全部楼层
#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
              HINSTANCE hPrevInstance,
              LPSTR lpszArgument,
              int nFunsterStil)

{
   HWND hwnd;          /* This is the handle for our window */
   MSG messages;        /* Here messages to the application are saved */
   WNDCLASSEX wincl;      /* Data structure for the windowclass */

   /* The Window structure */
   wincl.hInstance = hThisInstance;
   wincl.lpszClassName = szClassName;
   wincl.lpfnWndProc = WindowProcedure;    /* This function is called by windows */
   wincl.style = CS_DBLCLKS;            /* Catch double-clicks */
   wincl.cbSize = sizeof (WNDCLASSEX);

   /* Use default icon and mouse-pointer */
   wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
   wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
   wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
   wincl.lpszMenuName = NULL;            /* No menu */
   wincl.cbClsExtra = 0;               /* No extra bytes after the window class */
   wincl.cbWndExtra = 0;               /* structure or the window instance */
   /* Use Windows&#39;s default color as the background of the window */
   wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

   /* Register the window class, and if it fails quit the program */
   if (!RegisterClassEx (&wincl))
      return 0;

   /* The class is registered, let&#39;s create the program*/
   hwnd = CreateWindowEx (
        0,             /* Extended possibilites for variation */
        szClassName,      /* Classname */
        "Windows App",     /* Title Text */
        WS_OVERLAPPEDWINDOW, /* default window */
        CW_USEDEFAULT,     /* Windows decides the position */
        CW_USEDEFAULT,     /* where the window ends up on the screen */
        544,            /* The programs width */
        375,            /* and height in pixels */
        HWND_DESKTOP,      /* The window is a child-window to desktop */
        NULL,           /* No menu */
        hThisInstance,     /* Program Instance handler */
        NULL            /* No Window Creation data */
        );

   /* Make the window visible on the screen */
   ShowWindow (hwnd, nFunsterStil);

   /* Run the message loop. It will run until GetMessage() returns 0 */
   while (GetMessage (&messages, NULL, 0, 0))
   {
      /* Translate virtual-key messages into character messages */
      TranslateMessage(&messages);
      /* Send message to WindowProcedure */
      DispatchMessage(&messages);
   }

   /* The program return-value is 0 - The value that PostQuitMessage() gave */
   return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)            /* handle the messages */
   {
      case WM_DESTROY:
        PostQuitMessage (0);     /* send a WM_QUIT to the message queue */
        break;
      default:               /* for messages that we don&#39;t deal with */
        return DefWindowProc (hwnd, message, wParam, lParam);
   }

   return 0;
}
发表于 2007-2-15 22:22:02 | 显示全部楼层
这个是一个最简单的窗口

调用windows api

显示窗口 刷新窗口 消息循环
 楼主| 发表于 2006-12-26 21:37:58 | 显示全部楼层 |阅读模式
  自学TC这么久了,写的程序都是在一个DOS窗口里运行的,想问一下各位,那些WINDOWS的窗口是怎么做的?
还有,鼠标操作是怎么完成的?
还有,最大化,最小化是怎么完成的?
望高手解释一下!谢谢!


我是C语言的新手,各位别打我啊!!我闪!
您需要登录后才可以回帖 登录 | 加入易码

本版积分规则

Archiver|手机版|小黑屋|EMAX Studio

GMT+8, 2024-4-25 21:31 , Processed in 0.011239 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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