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

📄 ewcalc.asm

📁 -Win32 Assembly写的小程式,含 Source Code! -工程计算机,可达112 bits !
💻 ASM
📖 第 1 页 / 共 5 页
字号:
         cmp     eax, 3
         je      wmclr
      .if eax == 19
            mov     T, 1
         INVOKE     SendMessage, hRad, BM_SETCHECK, BST_UNCHECKED, 0 ; Sets rad to unchecked
      .endif
      .if eax == 20
            mov     T, 2
         INVOKE     SendMessage, hDeg, BM_SETCHECK, BST_UNCHECKED, 0 ; Sets deg to unchecked
      .endif

; -------* 21=Dec * 22=Hex * 23=Oct * 24=Bin *-------
         and     sw2, 0
      .if eax == 21                ; Dec
         .if Base != 10
             MOVmd     PrevBase, Base
               mov     Base, 10
               mov     sw2, 10
              call     DsplyConv 
         .endif
      .endif
      .if eax == 22                ; Hex
         .if Base != 16
             MOVmd     PrevBase, Base
               mov     Base, 16
               mov     sw2, 16
              call     DsplyConv 
         .endif 
      .endif
      .if eax == 23                ; Oct
         .if Base != 8
             MOVmd     PrevBase, Base
               mov     Base, 8
               mov     sw2, 8
              call     DsplyConv
         .endif 
      .endif
      .if eax == 24                ; Bin
         .if Base != 2
             MOVmd     PrevBase, Base
               mov     Base, 2
               mov     sw2, 2
              call     DsplyConv
         .endif 
      .endif
      .if eax > 20 && eax < 25
            and     I, 0
      .endif
      .if eax == 43
            and     Float, 0
         INVOKE     SendMessage, hFloat, BM_GETCHECK, 0, 0
         .if eax == 1
               or     Float, 1
         .endif
            jmp     wmclr
      .endif
      .if eax == 50
            and     ArcOn, 0
         INVOKE     SendMessage, hArc, BM_GETCHECK, 0, 0
         .if eax == 1
               or     ArcOn, 1
         .endif
      .endif
         jmp     defwndproc

wmcreate:
      INVOKE     GetSysColor, COLOR_MENU
         mov     BackGC, eax

      INVOKE     lstrcpy, ADDR lf.lfFaceName, ADDR FontName
         mov     lf.lfHeight, -12
         mov     lf.lfWeight, 500
      INVOKE     CreateFontIndirect, ADDR lf
         mov     hFont,eax

      INVOKE     lstrcpy, ADDR lf.lfFaceName, ADDR FontName1
         mov     lf.lfHeight, -12
         mov     lf.lfWeight, 500
      INVOKE     CreateFontIndirect, ADDR lf
         mov     hDspF,eax

      INVOKE     CreateWindowEx,NULL, ADDR Butt,ADDR float,
                 WS_CHILD or WS_VISIBLE or BS_AUTOCHECKBOX,
                 4,4,130,12,hwnd,43,hInst,NULL    ; Floating Point
         mov     hFloat, eax
      INVOKE     SendMessage, hFloat, WM_SETFONT, hFont, 0

      INVOKE     CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditPT,NULL,
                 WS_CHILD or WS_VISIBLE or WS_BORDER or ES_RIGHT or ES_AUTOHSCROLL or ES_SAVESEL,
                 135,0,315,22,hwnd,44,hInst,NULL  ; Edit window
         mov     hEdit,eax
      INVOKE     SetWindowLong, hEdit, GWL_WNDPROC, EditProc
         mov     SubEdit, eax

      INVOKE     CreateWindowEx,NULL, ADDR Butt,ADDR arc,
                 WS_CHILD or WS_VISIBLE or BS_AUTOCHECKBOX,
                 182,32,40,12,hwnd,50,hInst,NULL  ; Arc for trig
         mov     hArc, eax
      INVOKE     SendMessage, hArc, WM_SETFONT, hFont, 0

      INVOKE     CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditPT,NULL,
                 WS_CHILD or WS_VISIBLE or WS_BORDER or ES_CENTER or ES_READONLY,
                 239,26,25,21,hwnd,88,hInst,NULL  ; Memory window
         mov     hMem,eax

      INVOKE     CreateWindowEx,NULL, ADDR Butt, ADDR BackS,
                 WS_CHILD or WS_VISIBLE,
                 271,26,80,20,hwnd,1,hInst,NULL   ; Backspace button
         mov     hBkSp, eax
      INVOKE     SendMessage, hBkSp, WM_SETFONT, hFont, 0

      INVOKE     CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditPT,NULL,
                 WS_CHILD or WS_VISIBLE or WS_BORDER or ES_CENTER or ES_READONLY,
                 363,26,25,21,hwnd,89,hInst,NULL  ; Operator window
         mov     hOpr,eax

      INVOKE     CreateWindowEx,NULL, ADDR Butt,ADDR CE,
                 WS_CHILD or WS_VISIBLE,
                 399,26,20,20,hwnd,2,hInst,NULL   ; Clear error button
         mov     hCE, eax
      INVOKE     SendMessage, hCE, WM_SETFONT, hFont, 0

      INVOKE     CreateWindowEx,NULL, ADDR Butt,ADDR CLR,
                 WS_CHILD or WS_VISIBLE,
                 429,26,20,20,hwnd,3,hInst,NULL   ; Clear button
         mov     hCLR, eax
      INVOKE     SendMessage, hCLR, WM_SETFONT, hFont, 0

;--------[ Check boxes and radio buttons ]-----------------------------
      INVOKE     CreateWindowEx,NULL, ADDR Butt,0,
                 WS_CHILD or WS_VISIBLE or BS_GROUPBOX,
                 178,43,85,28,hwnd,14,hInst,NULL  ; Deg & Rad group box

      INVOKE     CreateWindowEx,NULL, ADDR Butt,0,
                 WS_CHILD or WS_VISIBLE or BS_GROUPBOX,
                 271,43,178,28,hwnd,15,hInst,NULL ; Base group box
         xor     ebx, ebx
         mov     XP, 182
         mov     N, 19
         
BuildRadio:

	.if N < 21
		INVOKE	CreateWindowEx,NULL, ADDR Butt,ADDR DegT[ebx],
                    WS_CHILD or WS_VISIBLE or BS_AUTOCHECKBOX,
                    XP,55,39,12,hwnd,N,hInst,NULL ; Deg & Rad check boxes
                    
		sub     XP, 3
		
	.else
      
        INVOKE	CreateWindowEx,NULL, ADDR Butt,ADDR DegT[ebx],
                    WS_CHILD or WS_VISIBLE or BS_AUTORADIOBUTTON,
                    XP,55,40,12,hwnd,N,hInst,NULL ; Base radio buttons
	.endif
      
	mov     hDeg[ebx], eax
	
	INVOKE 	SendMessage, hDeg[ebx], WM_SETFONT, hFont, 0
	
	.if N < 24
		add     ebx, 4
		add     N, 1
		
		.if N == 21
			add     XP, 13
		.endif
        
        add     XP, 43
        jmp     BuildRadio
	.endif
	
	INVOKE	SendMessage, hDeg, BM_SETCHECK, BST_CHECKED, 0 ; Sets deg to checked
	INVOKE  SendMessage, hDec, BM_SETCHECK, BST_CHECKED, 0 ; Sets dec to checked

;--------[ Toolbars ]--------------------------------------------------
		xor     ebx, ebx
		mov     XP, 178
		mov     YP, 74
		mov     Row, 0
		mov     I, 9
		mov     N, 17
		mov     W, 272
         
BuildTB:
      	INVOKE  CreateWindowEx,NULL, ADDR Stat, 0,
                 	WS_CHILD or WS_VISIBLE,
                 	XP,YP,W,24,hwnd,1,hInst,NULL     ; Toolbars   
                 	
        mov     hTB01,eax
         
		INVOKE  SetWindowLong, hTB01, GWL_WNDPROC, ToolbarProc
        mov     SubTool, eax
        
		INVOKE	CreateToolbarEx,hTB01,WS_CHILD or WS_VISIBLE or CCS_NODIVIDER,
                 	IDT[ebx],I, hInst, IDT[ebx], tb[ebx], N, 16, 16, 16, 16, tbl[ebx]
                 	
      .if Row < 4
            add     ebx, 4
            add     YP, 29
            add     Row, 1
            jmp     BuildTB
      .endif
      
         and     I, 0

;--------[ Display area ]----------------------------------------------
      INVOKE     CreateWindowEx,NULL, ADDR Butt,0,
                 WS_CHILD or WS_VISIBLE or BS_GROUPBOX,
                 4,18,161,196,hwnd,55,hInst,NULL  ; Display area
         mov     hDspl, eax
         jmp     returnP

wmnotify:
         jmp     returnP

idmcut:
      INVOKE     SendMessage, hEdit, WM_CUT, 0 ,0
         jmp     wmclr

idmcopy:
      INVOKE     SendMessage, hEdit, WM_COPY, 0 ,0
         jmp     returnP

idmpaste:
           call     ClearValues
         INVOKE     SendMessage, hEdit, WM_PASTE, 0 ,0
;         INVOKE     ToolbarProc, hTB01, WM_COMMAND, 288 ,0
         jmp     returnP

idminfo:
      INVOKE     MessageBox, hwnd, offset Info, offset AppName, MB_OK
         jmp     returnP
idmabout:
         mov     eax, offset InfoAbDlg
         mov     ebx, IDD_ABOUT
         jmp     DialogBox
DialogBox:                         ; Modal dialog box
      INVOKE     DialogBoxParam, hInst, ebx, hwnd, eax, 0
         jmp     returnP

wmbs:                              ; Backspace
      INVOKE     SendMessage, hEdit, WM_GETTEXT, 35, ADDR Buff
      INVOKE     lstrlen, ADDR Buff
      .if eax == 0
            jmp     returnP
      .endif 
      INVOKE     lstrcpyn, ADDR ConvO, ADDR Buff, eax
      INVOKE     SendMessage, hEdit, WM_SETTEXT, NULL, ADDR ConvO
      INVOKE     SendMessage, hEdit, EM_SETSEL, 33, 33
      INVOKE     SetFocus, hWnd
      INVOKE     lstrcpy, ADDR Buff, ADDR ConvO
        call     AsciiToBase
      INVOKE     lstrcpy, ADDR Buff, ADDR ConvO
        call     AsciiToFloat
         mov     edx, offset RNum10
        call     FloatToAscii
        call     Display
         jmp     returnP

wmce:                              ; Clear error
         mov     ConvO, 0h
      INVOKE     SendMessage, hEdit, WM_SETTEXT, NULL, offset ConvO
      INVOKE     SetFocus, hWnd
         jmp     returnP

wmclr:                             ; Clears all Fields
        call     ClearValues
         jmp     returnP

;******************************************************************************
defwndproc:
      INVOKE     DefWindowProc, hwnd, wmsg, wparam, lparam
         jmp     finish

wmdestroy:
         push    0
         call    PostQuitMessage   ; Quit
         jmp     returnP
returnP: xor     eax,eax
finish:  RET
WndProc  ENDP

;=========================================================================|
;                        Clear Values.                                    |
;=========================================================================|
ClearValues proc
         mov     ConvO, 0
         mov     ConvI, 0
         mov     Buff, 0
         mov     LBuff, 0
         mov     RBuff, 0
         mov     PLBuff, 0
         mov     PRBuff, 0
         and     HPress, 0
         and     NPress, 0
         and     RPress, 0
         and     BPress, 0         ; 1=add, 2=sub, 3=mul, 4=div
         and     DP, 0
      INVOKE     SendMessage, hEdit, WM_SETTEXT, NULL, offset ConvO
      INVOKE     SetFocus, hWnd
      INVOKE     SendMessage, hOpr, WM_SETTEXT, NULL, ADDR Clear
         mov     Len, 0
      INVOKE     CLRMW, offset R, 32
        call     Display 
         and     First, 0
        fldz
        fstp     RNum10
        fldz
        fstp     RWrk10
         ret
ClearValues endp

;=========================================================================|
;                        About Box Dialog Procedure.                      |
;=========================================================================|
InfoAbDlg proc    hdlg:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
      .if wmsg != WM_COMMAND
            jmp     AboutDone
      .endif
         mov     eax, wparam
      .if eax == 1 || eax == 2        ; CANCEL or OK
         INVOKE     EndDialog, hdlg, wparam
            mov     eax, TRUE         ; Return
            jmp     AboutRet          ; with TRUE
      .endif
AboutDone:
         mov     eax, FALSE           ; Return with FALSE
AboutRet:
         ret
InfoAbDlg endp

;=========================================================================|
;                        Processes keyboard input.                        |
;=========================================================================|
EditProc   PROC  hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD

         mov     Key, 0
      .if wmsg == WM_KEYDOWN
         INVOKE     SendMessage, hEdit, EM_GETSEL, addr w1, addr w2
            mov     eax, w1
         .if w2 > eax
              call     ClearValues
         .endif
      .endif
      .if wmsg == WM_PASTE
           call     ClearValues
            mov     Key, 288
            jmp     pass
      .endif

      .if wmsg == WM_CHAR
         .if wparam == 2bh
               mov     wmsg, WM_KEYUP
               mov     wparam, 6bh
         .endif
         .if wparam == 2ah
               mov     wmsg, WM_KEYUP
               mov     wparam, 6ah
         .endif
      .endif

      .if wmsg == WM_KEYUP
;         INVOKE     SetFocus, hWnd
         INVOKE     SendMessage, hEdit, WM_GETTEXT, 35, ADDR Buff
         INVOKE     lstrlen, ADDR Buff
         .if eax > 16 && BPress == 3
            INVOKE     MessageBeep, MB_OK
               mov     Buff + 15, 0
            INVOKE     SendMessage, hEdit, WM_SETTEXT, NULL, ADDR Buff
         .endif
         .if eax > 19 && BPress == 4 || eax > 19 && Float == 1
            INVOKE     MessageBeep, MB_OK
               mov     Buff + 18, 0
            INVOKE     SendMessage, hEdit, WM_SETTEXT, NULL, ADDR Buff
         .endif

         .if wparam > 2fh && wparam < 3ah
             MOVmd     Key, wparam
               sub     Key, 48

⌨️ 快捷键说明

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