如何用C语言编写win32程序~!~!~!

ytfitihc 2003-09-14 02:59:02
大家提点意见!~!~
...全文
827 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Wolf0403 2003-09-16
  • 打赏
  • 举报
回复
To: plusir(狂热的C++信徒)
谢谢,谢谢啊【热泪盈眶】,居然还有人看到我的帖子
----------------------------------------
MFC 不是严格的 single root 继承结构,而且因为是对 WIN API 的浅层次封装,因此学着费事,还不如直接学 Win API,C/C++ 都可以用。
dawndu 2003-09-16
  • 打赏
  • 举报
回复
学MFC就是学VC,而学VCL和学C++ Builder没什么区别?
====================================================
vc的东西很多。mfc是一小部分,还有,vcl上delphi的Object Pascal写的,跟c++没关系的

plusir 2003-09-14
  • 打赏
  • 举报
回复
现在学Win32桌面程序有两种途径的
一种是学习纯C,然后调用WinAPI,这个途径好像叫Win32 SDK,北大翻译的《Windows程序设计》是这方面很好的入门书,而且书中没用到一点C++的内容,《Windows核心编程》是提高,不适合初学的;
另外一种是用C++的知识,把各种操作封装到类里面,做成类库供开发者使用。最常用的是Microsoft的MFC和Borland的VCL(呵呵,好像是这么拼的,记不清了),虽然都是用C++封装各种类,但实现方法却是南辕北辙,前者是严格的单根结构,后者采用多重继承。学MFC就是学VC,而学VCL和学C++ Builder没什么区别。
新出的C#和.net框架用于B/S结构,桌面不是强项,对那个东西还不太了解,呵呵
学MFC有很多好的书,比如《MFC Windows程序设计》,技术内幕和深入浅出什么的。至于BCB的书,我就不太了解了,你可以问问其他人。
PS:二楼的例子就是Win32 SDK的例子,纯C调用WinAPI。
sevencat 2003-09-14
  • 打赏
  • 举报
回复
windows核心编程也可以。
里面基本上都是SDK的例子。
l1ul1u 2003-09-14
  • 打赏
  • 举报
回复
看看关于window 编程的书籍
就是sdk编程
cxjddd 2003-09-14
  • 打赏
  • 举报
回复
#include <windows.h>
dreamfly8848 2003-09-14
  • 打赏
  • 举报
回复
看看window 程序设计那本书。很不错。
ggg82 2003-09-14
  • 打赏
  • 举报
回复
使用c语言编写win32应用程序,必须使用winapi函数,所以建议你先学习winapi.
Wolf0403 2003-09-14
  • 打赏
  • 举报
回复
不需要 VCL/MFC/.NET 的范例:
#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'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'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't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}
kingofvc 2003-09-14
  • 打赏
  • 举报
回复
使用win32的编译器
vc bcb gcc 都可以
然后使用那个程序框架即可
参考《windows程序设计》

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧