当前位置:首页 » 编程博文
开发技术指南» 文章正文
    引言: 本文翻译自MSDN,由于本人英文水平一般,如果有什么差错,请大家积极指出,本人一定知错就改。
 

 

 ·系统引导过程分析与编制    »显示摘要«
    摘要: 读了2004年《程序员》杂志中的《程序员田园》板块中相关的文章之后,对此颇有感触。因此也想对此作一番小小的研究。 其实说穿了,系统引导很简单: 1、 启动电源之后,硬件完成它所应完成的工作; 2、 bios按照cmos中保存的设置,按照启动顺序读取启动盘中的0柱面0磁道1扇区,将512字节装载到内存的0:7c00处并运行,并把硬件的控制权交给软件;判断一个扇区是否是引导扇区的依据是它是否以......
 ·非模式对话框的显示问题    »显示摘要«
    摘要:非模式对话框就像photoshop里面的toolbar,总显示在其父窗口上面。如何将非模式对话框显示在父窗口后面呢?一种解决办法是:建立非模式对话框时create的第二个参数用getdesktopwindow(),m_pdlg->create(idd_,getdesktopwindow());如果需要恢复toolbar的属性:m_pdlg->setwindowpos(&wndt......


一个Generic实例应用程序

本文翻译自msdn,由于本人英文水平一般,如果有什么差错,请大家积极指出,本人一定知错就改.

原文链接:http://msdn.microsoft.com/library/en-us/winprog/winprog/a_generic_sample_application.asp 【程序编程相关:Visual C++.NET编程基础讲座

【推荐阅读:华为进攻(宽带城域网引发的华为营销策略分

本文适合于win32 api的初学者 【扩展信息:面向对象的思维方法

a generic sample application

一个generic实例应用程序

this section introduces the source code components of a generic windows-based application, named generic. this section assumes that you have used windows-based applications and therefore are already familiar with windows, menus, and dialog boxes in microsoft? windows?.

这个部分介绍一个基于windows的应用程序的源代码的组成部分,我们这个程序叫做generic.我们假定你已经使用过基于windows的应用程序,因此你应该对windows中的窗口.菜单与对话框都比较熟悉.

the generic application described here consists of the following parts:

这里讲述的generic应用程序由以下部分组成:

the entry-point function

入口函数

the menu

菜单

the window procedure

窗口过程

the about dialog box

about对话框

the complete code is shown in source code.

完整的代码被列在“source code”这个部分.

 

 

the entry-point function

入口函数

every application must have an entry-point function. the name commonly given to the entry point is the winmain function.

每个应用程序都必须有一个入口函数.通常入口点的名称是winmain.

as in most windows-based applications, the winmain function for the generic application completes the following steps:

与大部分基于windows的应用程序一样,generic应用程序中的winmain函数都完成以下一些步骤:

registering the window class

注册窗口类

creating the main window

创建主窗口

entering the message loop

进入消息循环

 

 

registering the window class

注册窗口类

every window must have a window class. a window class defines the attributes of a window, such as its style, its icon, its cursor, the name of the menu, and the name of the window procedure.

每个窗口都必须有一个窗口类.这个窗口类定义了一个窗口的属性,例如它的风格.图标.光标指针.菜单名与窗口过程的名称.

the first step is to fill in a wndclass structure with class information. next, you pass the structures to the registerclass function. the generic application registers the genericappclass window class as follows:

第一步是用类的信息来填充一个wndclass结构.下一步,将这个结构传递给registerclass函数.generic应用程序依照下列代码来注册genericappclass窗口类:

hinstance hinstance;

wndclass  wc;

wc.lpszclassname = "genericappclass";

wc.lpfnwndproc = mainwndproc;

wc.style = cs_owndc | cs_vredraw | cs_hredraw;

wc.hinstance = hinstance;

wc.hicon = loadicon(null, idi_application);

wc.hcursor = loadcursor(null, idc_arrow);

wc.hbrbackground = (hbrush)(color_window + 1);

wc.lpszmenuname = "genericappmenu";

wc.cbclsextra = 0;

wc.cbwndextra = 0;

registerclass(&wc);

for more information on the menu, see the menu. for more information on the window procedure, see the window procedure.

至于菜单方面的更多信息,请参考“the menu”这个部分.而关于窗口过程方面的更多信息,请参考“the window procedure”.

 

 

creating the main window

创建主窗口

you can create the window by calling the createwindow function. the generic application creates the window as follows:

你可以通过调用createwindow函数来创建窗口.generic应用程序依照下列代码来创建窗口:

hwnd = createwindow("genericappclass",

    "generic application",

    ws_overlappedwindow | ws_hscroll | ws_vscroll,

    0,

    0,

    cw_usedefault,

    cw_usedefault,

    null,

    null,

    hinstance,

    null

);

the first parameter is the name of the class that we registered. the remaining parameters specify other window attributes. this call creates the window, but the system does not display a window until the application calls the showwindow function. the generic application displays the window as follows:

第一个参数是我们已注册的窗口类的名称.剩下的参数用来指定其它的窗口属性.这个函数调用创建一个窗口,但是系统不会显示它,除非你再调用showwindow这个函数.generic应用程序依照下列代码来在屏幕上显示该窗口:

showwindow( hwnd, ncmdshow );

 

 

entering the message loop

进入消息循环

once the main window is created and displayed, the winmain function can begin its primary task, which is to read messages from the application queue and dispatch them to the appropriate window.

一旦主窗口已被创建并显示,winmain函数就可以开始它的主要任务,那就是从应用程序的消息队列中读取消息并把它发送到合适的窗口中去.

the system does not send input directly to an application. instead, it places all mouse and keyboard input from the user into a message queue, along with messages posted by the system and other applications. the application must read the message queue, retrieve the messages, and dispatch them so that the window procedure can process them.

系统不会将输入直接发送到一个应用程序.
...   下一页
 ·递归函数之java演绎(原创)    »显示摘要«
    摘要: 递归函数之java演绎 lxgljj 1、递归函数的定义: 答:递归函数即自调用函数,在函数体内直接或间接的调用自己,即函数的嵌套是函数本身。 2、递归方式:递归调用有直接递归和间接递归两种方式。 a:直接递归:在函数中出现调用函数本身。 示例1:下面代码求斐波那契数列第n项,斐波那契数列第一和第二项是1,后面每一项是前两项之和,即1、1、2、3、5、8、13 .......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE