News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Converting hotkey values (dec) to string

Started by Mark Jones, July 20, 2005, 02:08:21 PM

Previous topic - Next topic

Mark Jones

Hotkeys are fun. :)

Here's a way I managed to manually convert a returned VKey into ASCII characters so it can be displayed or stored in an .ini file or whatever. Here the hotkey was F3 (VKEY=72h) A normal hex-to-string conversion will not work because the 72h represents a DECIMAL 72d, but in hex notation. Confusing!


        invoke SendDlgItemMessage,hWnd,IDC_HOT1,HKM_GETHOTKEY,0,0   ; result in eax
        mov ecx,offset szBuffer             ; dest buffer pointer as ecx
        shl eax,24                          ; strip off all but al (72h)
        shr eax,24                          ; move lone value back to al
        shl eax,4                           ; put each nibble in own byte (07h,20h)
        shr al,4                            ; correct al (07h,02h)
        add ax,3030h                        ; add 30h to each to make ASCII
        mov dh,al                           ; swap bytes
        mov dl,ah                           ; (32h,37h)
        mov word ptr [ecx], dx              ; output two bytes (in logical order)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

pro3carp3

I'm not very familer with the SendDlgItemMessage function, but does the following do the same thing?


invoke SendDlgItemMessage,hWnd,IDC_HOT1,HKM_GETHOTKEY,0,0   ; result in eax
        mov ecx,offset szBuffer             ;??????????????????????
        mov ah, al
        shr al, 4
        and F0Fh
        add ax, 3030h
        mov word ptr [ecx], ax

LGC

Jeff


pro3carp3

Quote
i think you mean and ax,0F0Fh  ;)

Oops...

I was in a hurry to go to lunch.  Thanks.
LGC

comrade

can't u use BCD instructions for that... if 72h represents 72d then thats a bcd