⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lion-tutorial03.htm

📁 内有一些代码
💻 HTM
📖 第 1 页 / 共 3 页
字号:
  <b>lpfnWndProc:</b> The address of the window procedure responsible for windows 
  created from this class. <br>
  <b>cbClsExtra:</b> Specifies the number of extra bytes to allocate following 
  the window-class structure. The operating system initializes the bytes to zero. 
  You can store window class-specific data here. <br>
  <b>cbWndExtra: </b>Specifies the number of extra bytes to allocate following 
  the window instance. The operating system initializes the bytes to zero. If 
  an application uses the WNDCLASS structure to register a dialog box created 
  by using the CLASS directive in the resource file, it must set this member to 
  DLGWINDOWEXTRA. <br>
  <b>hInstance:</b> Instance handle of the module. <br>
  <b>hIcon:</b> Handle to the icon. Get it from LoadIcon call. <br>
  <b>hCursor:</b> Handle to the cursor. Get it from LoadCursor call. <br>
  <b>hbrBackground:</b> Background color of windows created from the class. <br>
  <b>lpszMenuName:</b> Default menu handle for windows created from the class. 
  <br>
  <b>lpszClassName:</b> The name of this window class. <br>
  <b>hIconSm:</b> Handle to a small icon that is associated with the window class. 
  If this member is NULL, the system searches the icon resource specified by the 
  hIcon member for an icon of the appropriate size to use as the small icon. 
<p><b>&nbsp;&nbsp;&nbsp; invoke CreateWindowEx, NULL,\</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  ADDR ClassName,\</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  NULL,\</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  NULL,\</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  hInst,\</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  NULL</b> 
<p>After registering the window class, we can call CreateWindowEx to create our 
  window based on the submitted window class. Notice that there are 12 parameters 
  to this function. 
<p><b>CreateWindowExA proto dwExStyle:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; lpClassName:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; lpWindowName:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; dwStyle:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; X:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; Y:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; nWidth:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; nHeight:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; hWndParent:DWORD ,\</b> <br>
  <b>&nbsp;&nbsp; hMenu:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; hInstance:DWORD,\</b> <br>
  <b>&nbsp;&nbsp; lpParam:DWORD</b> 
<p>Let's see detailed description of each parameter: <br>
  <b>dwExStyle:</b> Extra window styles. This is the new parameter that is added 
  to the old CreateWindow. You can put new window styles for Windows 95 &amp; 
  NT here.You can specify your ordinary window style in dwStyle but if you want 
  some special styles such as topmost window, you must specify them here. You 
  can use NULL if you don't want extra window styles. <br>
  <b>lpClassName: </b>(Required). Address of the ASCIIZ string containing the 
  name of window class you want to use as template for this window. The Class 
  can be your own registered class or predefined window class. As stated above, 
  every window you created must be based on a window class. <br>
  <b>lpWindowName: </b>Address of the ASCIIZ string containing the name of the 
  window. It'll be shown on the title bar of the window. If this parameter is 
  NULL, the title bar of the window will be blank. <br>
  <b>dwStyle:&nbsp;</b> Styles of the window. You can specify the appearance of 
  the window here. Passing NULL&nbsp; is ok but the window will have no system 
  menu box, no minimize-maximize buttons, and no close-window button. The window 
  would not be of much use at all. You will need to press Alt+F4 to close it. 
  The most common window style is WS_OVERLAPPEDWINDOW. A window style is only 
  a bit flag. Thus you can combine several window styles by "or" operator to achieve 
  the desired appearance of the window. WS_OVERLAPPEDWINDOW style is actually 
  a combination of the most common window styles by this method. <br>
  <b>X,Y:</b> The coordinate of the upper left corner of the window. Normally 
  this values should be CW_USEDEFAULT, that is, you want Windows to decide for 
  you where to put the window on the desktop. <br>
  <b>nWidth, nHeight: </b>The width and height of the window in pixels. You can 
  also use CW_USEDEFAULT to let Windows choose the appropriate width and height 
  for you. <br>
  <b>hWndParent: </b>A handle to the window's parent window (if exists). This 
  parameter tells Windows whether this window is a child (subordinate) of some 
  other window and, if it is, which window is the parent. Note that this is not 
  the parent-child relationship of multiple document interface (MDI). Child windows 
  are not bound to the client area of the parent window. This relationship is 
  specifically for Windows internal use. If the parent window is destroyed, all 
  child windows will be destroyed automatically. It's really that simple. Since 
  in our example, there's only one window, we specify this parameter as NULL. 
  <br>
  <b>hMenu:</b> A handle to the window's menu. NULL if the class menu is to be 
  used. Look back at the a member of WNDCLASSEX structure, lpszMenuName. lpszMenuName 
  specifies *default* menu for the window class. Every window created from this 
  window class will have the same menu by default. Unless you specify an *overriding* 
  menu for a specific window via its hMenu parameter. hMenu is actually a dual-purpose 
  parameter. In case the window you want to create is of a predefined window type 
  (ie. control), such control cannot own a menu. hMenu is used as that control's 
  ID instead. Windows can decide whether hMenu is really a menu handle or a control 
  ID by looking at lpClassName parameter. If it's the name of a predefined window 
  class, hMenu is a control ID. If it's not, then it's a handle to the window's 
  menu. <br>
  <b>hInstance:</b> The instance handle for the program module creating the window. 
  <br>
  <b>lpParam: </b>Optional pointer to a data structure passed to the window. This 
  is used by MDI window to pass the CLIENTCREATESTRUCT data. Normally, this value 
  is set to NULL, meaning that no data is passed via CreateWindow(). The window 
  can retrieve the value of this parameter by the call to GetWindowLong function. 
<p><b>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp; hwnd,eax</b> <br>
  <b>&nbsp;&nbsp;&nbsp; invoke ShowWindow, hwnd,CmdShow</b> <br>
  <b>&nbsp;&nbsp;&nbsp; invoke UpdateWindow, hwnd</b> 
<p>On successful return from CreateWindowEx, the window handle is returned in 
  eax. We must keep this value for future use. The window we just created is not 
  automatically displayed. You must call ShowWindow with the window handle and 
  the desired *display state* of the window to make it display on the screen. 
  Next you can call UpdateWindow to order your window to repaint its client area. 
  This function is useful when you want to update the content of the client area. 
  You can omit this call though. 
<p><b>&nbsp;&nbsp;&nbsp; .WHILE TRUE</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  invoke GetMessage, ADDR msg,NULL,0,0</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  .BREAK .IF (!eax)</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  invoke TranslateMessage, ADDR msg</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  invoke DispatchMessage, ADDR msg</b> <br>
  <b>&nbsp;&nbsp; .ENDW</b> 
<p>At this time, our window is up on the screen. But it cannot receive input from 
  the world. So we have to *inform* it of relevant events. We accomplish this 
  with a message loop. There's only one message loop for each module. This message 
  loop continually checks for messages from Windows with GetMessage call. GetMessage 
  passes a pointer to a MSG structure to Windows. This MSG structure will be filled 
  with information about the message that Windows want to send to a window in 
  the module. GetMessage function will not return until there's a message for 
  a window in the module. During that time, Windows can give control to other 
  programs. This is what forms the cooperative multitasking scheme of Win16 platform. 
  GetMessage returns FALSE if WM_QUIT message is received which, in the message 
  loop, will terminate the loop and exit the program. <br>
  TranslateMessage is a utility function that takes raw keyboard input and generates 
  a new message (WM_CHAR) that is placed on the message queue. The message with 
  WM_CHAR contains the ASCII value for the key pressed, which is easier to deal 
  with than the raw keyboard scan codes. You can omit this call if your program 
  doesn't process keystrokes. <br>
  DispatchMessage sends the message data to the window procedure responsible for 
  the specific window the message is for. 
<p><b>&nbsp;&nbsp;&nbsp; mov&nbsp;&nbsp;&nbsp;&nbsp; eax,msg.wParam</b> <br>
  <b>&nbsp;&nbsp;&nbsp; ret</b> <br>
  <b>WinMain endp</b> 
<p>If the message loop terminates, the exit code is stored in wParam member of 
  the MSG structure. You can store this exit code into eax to return it to Windows. 
  At the present time, Windows does not make use of the return value, but it's 
  better to be on the safe side and plays by the rule. 
<p><b>WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM</b> 
<p>This is our window procedure. You don't have to name it WndProc. The first 
  parameter, hWnd, is the window handle of the window that the message is destined 
  for. uMsg is the message. Note that uMsg is not a MSG structure. It's just a 
  number, really. Windows defines hundreds of messages, most of which your programs 
  will not be interested in. Windows will send an appropriate message to a window 
  in case something relevant to that window happens. The window procedure receives 
  the message and reacts to it intelligently. wParam and lParam are just extra 
  parameters for use by some messages. Some messages do send accompanying data 
  in addition to the message itself. Those data are passed to the window procedure 
  by means of lParam and wParam. 
<p><b>&nbsp;&nbsp;&nbsp; .IF uMsg==WM_DESTROY</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke PostQuitMessage,NULL</b> 
  <br>
  <b>&nbsp;&nbsp;&nbsp; .ELSE</b> <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invoke DefWindowProc,hWnd,uMsg,wParam,lParam</b> 
  <br>
  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret</b> <br>
  <b>&nbsp;&nbsp;&nbsp; .ENDIF</b> <br>
  <b>&nbsp;&nbsp;&nbsp; xor eax,eax</b> <br>
  <b>&nbsp;&nbsp;&nbsp; ret</b> <br>
  <b>WndProc endp</b> 
<p>Here comes the crucial part. This is where most of your program's intelligence 
  resides. The codes that respond to each Windows message are in the window procedure. 
  Your code must check the Windows message to see if it's a message it's interested 
  in. If it is, do anything you want to do in response to that message and then 
  return with zero in eax. If it's not, you MUST call&nbsp; DefWindowProc, passing 
  all parameters you received to it for default processing.. This DefWindowProc 
  is an API function that processes the messages your program are not interested 
  in. <br>
  The only message that you MUST respond to is WM_DESTROY. This message is sent 
  to your window procedure whenever your window is closed. By the time your window 
  procedure receives this message, your window is already removed from the screen. 
  This is just a notification that your window was destroyed, you should prepare 
  yourself to return to Windows. In response to this, you can perform housekeeping 
  prior to returning to Windows. You have no choice but to quit when it comes 
  to this state. If you want to have a chance to stop the user from closing your 
  window, you should process WM_CLOSE message. Now back to WM_DESTROY, after performing 
  housekeeping chores, you must call PostQuitMessage which will post WM_QUIT back 
  to your module. WM_QUIT will make GetMessage return with zero value in eax, 
  which in turn, terminates the message loop and quits to Windows. You can send 
  WM_DESTROY message to your own window procedure by calling DestroyWindow function.
<hr size="1">
<div align="center"> This article come from Iczelion's asm page, Welcom to <a href="http://asm.yeah.net">http://asm.yeah.net</a></div>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -