C语言程序的窗体

来源:百度知道 编辑:UC知道 时间:2024/05/30 06:34:54
C语言应该不可能只能编出那种基于"文本"方式的程序吧,比如像面向对象程序中的窗体在和按钮等C语言中是怎么实现的呢?

可以是可以,但是如果光用C语言的特性来编写Windows窗口程序太费劲,C不适合写窗口程序。给你如下代码,可以在VC中编译成功。

/*------------------------------------------------------------
HELLOWIN.C -- Displays "Hello, Windows 98!" in client area
(c) Charles Petzold, 1998
------------------------------------------------------------*/

#include <windows.h>

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;

wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIc