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

📄 languages.asm

📁 一个演示了用汇编语言编写的数据排序算法,源代码非常详细
💻 ASM
📖 第 1 页 / 共 2 页
字号:

;-----------------------------------------------------------------------------------------
; Include the language strings.
;-----------------------------------------------------------------------------------------

  include languages.inc


;-----------------------------------------------------------------------------------------
; Prototypes.
;-----------------------------------------------------------------------------------------

  SwitchLanguage      PROTO :DWORD
  LoadLanguageStrings PROTO :DWORD
  
  LoadOffsets         PROTO :DWORD, :DWORD 


.data

  ;---------------------------------------------------------------------------------------
  ;-- This flag signes whether the procedure SwitchLanguage is called the first time or
  ;-- not.
  fLanguageChoosen BYTE FALSE


.code

;-----------------------------------------------------------------------------------------
; Purpose:     Changes the menu item states and changes the texts of all dialogs.
;
; Inputs:      IDMI - identifier of the clicked menu item
;
; Outputs:     none
;
; Notes:       none
;-----------------------------------------------------------------------------------------

SwitchLanguage PROC IDMI:DWORD

  ;---------------------------------------------------------------------------------------
  ;-- Is the desired language already used?
  invoke GetMenuState, hMENU_Program, IDMI, MF_BYCOMMAND
  test   eax, MF_CHECKED
  jnz    @Return


  ;---------------------------------------------------------------------------------------
  ;-- No. Which language shall be used?

  .IF IDMI == IDMI_LANG_GERMAN

      ;-----------------------------------------------------------------------------------
      ;-- Uncheck the menu item "English".
      invoke CheckMenuItem, hMENU_Program, IDMI_LANG_ENGLISH, MF_BYCOMMAND or MF_UNCHECKED


      ;-----------------------------------------------------------------------------------
      ;-- Load "German".
      mov    eax, OFFSET LANG_German

  .ELSEIF IDMI == IDMI_LANG_ENGLISH

      ;-----------------------------------------------------------------------------------
      ;-- Uncheck the menu item "German".
      invoke CheckMenuItem, hMENU_Program, IDMI_LANG_GERMAN, MF_BYCOMMAND or MF_UNCHECKED


      ;-----------------------------------------------------------------------------------
      ;-- Load "English".
      mov    eax, OFFSET LANG_English

  .ELSE

      ;-----------------------------------------------------------------------------------
      ;-- Invalid parameter.
      ret

  .ENDIF

  ;---------------------------------------------------------------------------------------
  ;-- Load the offsets of the language strings into the array.
  invoke LoadOffsets, eax, OFFSET lpLANG_STRINGS


  ;---------------------------------------------------------------------------------------
  ;-- Change the texts only if the dialogs 'Frame', 'Table' and 'Graphic' are loaded.
  .IF fLanguageChoosen

      ;-----------------------------------------------------------------------------------
      ;-- Set the new texts.
      invoke LoadLanguageStrings, IDD_FRAME
      invoke LoadLanguageStrings, IDD_TABLE
      invoke LoadLanguageStrings, IDD_GRAPHIC


      ;-----------------------------------------------------------------------------------
      ;-- Update the window contents.
      invoke InvalidateRect, hDialogFrame, NULL, FALSE
      invoke UpdateWindow, hDialogFrame

  .ELSE

      mov    fLanguageChoosen, TRUE

  .ENDIF


  ;---------------------------------------------------------------------------------------
  ;-- Check the corresponding menu item.
  invoke CheckMenuItem, hMENU_Program, IDMI, MF_BYCOMMAND	or MF_CHECKED


@Return:
	ret
SwitchLanguage ENDP



;-----------------------------------------------------------------------------------------
; Purpose:     Changes the texts of the specified dialog according to the current
;              language.
;
; Inputs:      IDD - identifier of the dialog 
;
; Outputs:     none
;
; Notes:       The identifier has to be equal to the one used in the resource file.
;-----------------------------------------------------------------------------------------

LoadLanguageStrings PROC IDD:DWORD

  ;---------------------------------------------------------------------------------------
  ;-- Whose item texts shall be changed?
  mov    eax, IDD
  .IF eax == IDD_FRAME
      ;-----------------------------------------------------------------------------------
      ;-- Dialog: Frame

      ;-----------------------------------------------------------------------------------
      ;-- Change the text of the dialog window.
      invoke SendMessage, hDialogFrame, WM_SETTEXT, NULL, lpSTR_TITLE_PROGRAM


      ;-----------------------------------------------------------------------------------
      ;-- Change the tab texts.
      mov    TCI.imask, LVIF_TEXT

      mov    eax, lpSTR_TAB_TABLE
      mov    TCI.pszText, eax
      invoke SendMessage, hTabControl, TCM_SETITEM, TABINDEX_TABLE, OFFSET TCI

      mov    eax, lpSTR_TAB_GRAPHIC
      mov    TCI.pszText, eax
      invoke SendMessage, hTabControl, TCM_SETITEM, TABINDEX_GRAPHIC, OFFSET TCI


      ;-----------------------------------------------------------------------------------
      ;-- Change the menu item texts.
      mov    MII.cbSize, SIZEOF MII
      mov    MII.fMask, MIIM_STRING
      mov    MII.fType, MFT_STRING

      mov    eax, lpSTR_PMENU_PROGRAM
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMP_PROGRAM, FALSE, OFFSET MII

      mov    eax, lpSTR_MENUI_EXIT
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMI_EXIT, FALSE, OFFSET MII

      mov    eax, lpSTR_PMENU_LANGUAGE
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMP_LANGUAGE, FALSE, OFFSET MII

      mov    eax, lpSTR_MENUI_LANG_GERMAN
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMI_LANG_GERMAN, FALSE, OFFSET MII

      mov    eax, lpSTR_MENUI_LANG_ENGLISH
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMI_LANG_ENGLISH, FALSE, OFFSET MII

      mov    eax, lpSTR_PMENU_HELP
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMP_HELP, FALSE, OFFSET MII

      mov    eax, lpSTR_MENUI_HELP_GERMAN
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMI_HELP_GERMAN, FALSE, OFFSET MII

      mov    eax, lpSTR_MENUI_HELP_ENGLISH
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMI_HELP_ENGLISH, FALSE, OFFSET MII

      mov    eax, lpSTR_MENUI_INFO
      mov    MII.dwTypeData, eax
      invoke SetMenuItemInfo, hMENU_Program, IDMI_INFO, FALSE, OFFSET MII


      ;-----------------------------------------------------------------------------------
      ;-- Redraw the menu bar.
      invoke DrawMenuBar, hDialogFrame


  .ELSEIF eax == IDD_TABLE
      ;-----------------------------------------------------------------------------------
      ;-- Dialog: Table

      ;-----------------------------------------------------------------------------------
      ;-- Change the texts of the static controls.
      invoke SendDlgItemMessage, hDialogTable, IDDI_S_ALGORITHMS, WM_SETTEXT, NULL, lpSTR_S_ALGORITHMS
      invoke SendDlgItemMessage, hDialogTable, IDDI_S_DATA, WM_SETTEXT, NULL, lpSTR_S_DATA
      invoke SendDlgItemMessage, hDialogTable, IDDI_S_ELEMENTS, WM_SETTEXT, NULL, lpSTR_S_ELEMENTS
      invoke SendDlgItemMessage, hDialogTable, IDDI_S_INITVALUE, WM_SETTEXT, NULL, lpSTR_S_INITVALUE


      ;-----------------------------------------------------------------------------------
      ;-- Change the texts of the buttons.
      invoke SendMessage, hTableDialog_B_SelectAll, WM_SETTEXT, NULL, lpSTR_B_SELECTALL
      invoke SendMessage, hTableDialog_B_SelectNone, WM_SETTEXT, NULL, lpSTR_B_SELECTNONE
      invoke SendMessage, hTableDialog_B_Options, WM_SETTEXT, NULL, lpSTR_B_OPTIONS
      
      .IF SortInfo.fSorting && !SortInfo.fGraphic
          mov    eax, lpSTR_B_CANCEL
      .ELSE
          mov    eax, lpSTR_B_SORT
      .ENDIF
      invoke SendMessage, hTableDialog_B_Start, WM_SETTEXT, NULL, eax


      ;-----------------------------------------------------------------------------------
      ;-- Change the item texts of the data combo box.
      
        ;---------------------------------------------------------------------------------
        ;-- Get the index of the selected item.
        invoke SendMessage, hTableDialog_CB_Data, CB_GETCURSEL, NULL, NULL
        push   eax
        
        
        ;---------------------------------------------------------------------------------
        ;-- Delete all items.
        invoke SendMessage, hTableDialog_CB_Data, CB_RESETCONTENT, NULL, NULL


        ;---------------------------------------------------------------------------------
        ;-- Insert the items.
        invoke SendMessage, hTableDialog_CB_Data, CB_ADDSTRING, NULL, lpSTR_UNSORTED
        invoke SendMessage, hTableDialog_CB_Data, CB_ADDSTRING, NULL, lpSTR_SORTEDASC
        invoke SendMessage, hTableDialog_CB_Data, CB_ADDSTRING, NULL, lpSTR_SORTEDDESC


        ;---------------------------------------------------------------------------------
        ;-- Select the previous selected item again.
        pop    eax
        invoke SendMessage, hTableDialog_CB_Data, CB_SETCURSEL, eax, NULL


      ;-----------------------------------------------------------------------------------
      ;-- Add the columns to the result list-view.
      mov    LVcol.imask, LVCF_TEXT

      mov    eax, OFFSET LVResultInfo
    @@:
      ;-----------------------------------------------------------------------------------
      ;-- Get the offset to the column title.
      add    eax, 4
      mov    ebx, DWORD PTR [eax]
      mov    ebx, DWORD PTR [ebx]
      mov    LVcol.pszText, ebx

      push   eax

        ;---------------------------------------------------------------------------------
        ;-- Get the column index and insert the column.
        mov    eax, DWORD PTR [eax + 4]
        invoke SendMessage, hTableDialog_LV_Result, LVM_SETCOLUMN, eax, OFFSET LVcol

      pop    eax

      ;-----------------------------------------------------------------------------------
      ;-- Have all columns been processed?
      add    eax, 8
      cmp    DWORD PTR [eax], NULL
      jnz    @B


      ;-----------------------------------------------------------------------------------
      ;-- Change the item texts of the menus. 
      mov    MII.cbSize, SIZEOF MII
      mov    MII.fMask, MIIM_STRING
      mov    MII.fType, MFT_STRING

      mov    eax, lpSTR_MENUI_DELETEALL
      mov    MII.dwTypeData, eax

⌨️ 快捷键说明

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