Author Topic: help please: masm32 input dialog box  (Read 2020 times)

Mads379

  • Regular Member
  • *
  • Posts: 1
help please: masm32 input dialog box
« on: September 16, 2018, 10:08:47 PM »
how can i change the display into dialog input box instead of cmd.

Code: [Select]

TITLE my program ()

INCLUDE irvine32.inc
INCLUDE Macros.inc

.data
str1 BYTE "Enter two integers: ", 0
str4 BYTE "The highest integer: ", 0dh, 0ah, 0
str6 BYTE "The smallest integer: ",0dh, 0ah, 0

arrInt DWORD 2 dup(?)
arrLen = LENGTHOF arrInt

.code
main PROC
call getIntUser
call Crlf
call printInt
call Crlf
exit
main ENDP

getIntUser PROC
mov ecx, arrLen
mov edx, OFFSET str1
mov esi, OFFSET arrInt
L1:
   call WriteString
   call ReadInt
   mov [esi], eax
   add esi, TYPE arrInt
   loop L1
   ret
getIntUser ENDP

printInt PROC
mov ecx, arrLen
mov esi, OFFSET arrInt

mov eax, [esi]
add esi, TYPE arrInt
mov ebx, [esi]
.IF eax > ebx
mov edx, OFFSET str4
call WriteString
call WriteDec
call Crlf
mov edx, OFFSET str6
call WriteString
mov eax, ebx
call WriteDec

.ELSE
xchg eax, ebx
mov edx, OFFSET str4
call WriteString
call WriteDec
call Crlf
mov edx, OFFSET str6
call WriteString
mov eax, ebx
call WriteDec
.ENDIF

ret
printInt ENDP

END main

[code]

AW

  • Member
  • *****
  • Posts: 1606
  • Let's Make ASM Great Again!
Re: help please: masm32 input dialog box
« Reply #1 on: September 18, 2018, 05:20:24 PM »
It will not be easy what you want from a console application. Try a windows application.

Vortex

  • Member
  • *****
  • Posts: 1873
Re: help please: masm32 input dialog box
« Reply #2 on: November 15, 2018, 06:59:30 AM »
Hi Mads379,

Attached is an example for you. You can check test.bat to see how it works.

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: help please: masm32 input dialog box
« Reply #3 on: November 15, 2018, 12:39:48 PM »
Interesting, but maybe you should announce that the example creates a key in the registry...

Code: [Select]
    invoke  InputBox,DWORD PTR [esi+4],\    ; address of the text
                     DWORD PTR [esi+8],\    ; address of the title of the input box
                     edx,\                  ; address of the buffer receiving the input text
                     edi,\                  ; x-coordinate of the input box
                     eax,\                  ; y-coordinate of the input box
                     ADDR StrLength         ; pointer to the number of characters received to the input box

    mov     result,eax

    invoke  RegOpenKeyEx,HKEY_CURRENT_USER,ADDR subKey,0,\
            KEY_ALL_ACCESS,ADDR key1

    invoke  RegSetValueEx,key1,ADDR valName,0,\
            REG_SZ,ADDR buffer,StrLength

AW

  • Member
  • *****
  • Posts: 1606
  • Let's Make ASM Great Again!
Re: help please: masm32 input dialog box
« Reply #4 on: November 15, 2018, 07:10:49 PM »
Interesting, but maybe you should announce that the example creates a key in the registry...

I know it is not important, for you it is all the same, but the example does not create a key it creates a value or sets it if exists.

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: help please: masm32 input dialog box
« Reply #5 on: November 15, 2018, 07:26:14 PM »
I know it is not important, for you it is all the same

You are right, José. Btw will you ever be able to post something without an insult?

AW

  • Member
  • *****
  • Posts: 1606
  • Let's Make ASM Great Again!
Re: help please: masm32 input dialog box
« Reply #6 on: November 15, 2018, 08:30:34 PM »
You are right, José. Btw will you ever be able to post something without an insult?

Dear victimized narcissist,
I believe it is all in your head.  :icon_rolleyes:
« Last Edit: November 15, 2018, 09:41:59 PM by AW »

Vortex

  • Member
  • *****
  • Posts: 1873
Re: help please: masm32 input dialog box
« Reply #7 on: November 19, 2018, 04:09:03 AM »
Hi Jochen,

Interesting, but maybe you should announce that the example creates a key in the registry...

Why should I announce that my example creates a key in the registry when I attach the source code? Is it improper to add a key in the section HKEY_CURRENT_USER?

I am not a big fan of the registry but setting a DOS variable to the output of a command is not a very comfortable task. Here is an alternative version not using the registry :

Code: [Select]
FOR /F %%A in ('InputBox.exe "Type yes to continue, no to exit" "Hello" 100 100') do SET string=%%A
BusyBox, the tiny UNIX\Linux shell is easier to use for the same purpose :

https://frippery.org/busybox/

Code: [Select]
string=$(InputBox.exe "What is your name?" "Hello" 100 100)

echo Your name is $string

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: help please: masm32 input dialog box
« Reply #8 on: November 19, 2018, 05:21:37 AM »
Hi Jochen,

Interesting, but maybe you should announce that the example creates a key in the registry...

Why should I announce that my example creates a key in the registry when I attach the source code? Is it improper to add a key in the section HKEY_CURRENT_USER?

Hi Erol,

Please don't be offended, it was not meant to. Your code is fine, but it came without any explanation - and as an assembly coder, I have that reflex "hey, he is fumbling my registry, why that?". My machine is getting slower and slower, and I am getting more and more sensitive to programs that add more stuff to my registry. Yours is a tiny bit indeed, not worth mentioning except for the good cause, i.e. you should explain to us n00bs in a few words what you did there ;-)
 :icon14:

Vortex

  • Member
  • *****
  • Posts: 1873
Re: help please: masm32 input dialog box
« Reply #9 on: November 21, 2018, 05:24:27 AM »
Hi Jochen,

You are right, some explanation is required. The previous version of InputBox.exe copied the keyboard input to the registry. The command is simple :

Code: [Select]
InputBox.exe "Type yes to continue, no to exit" "Hello" 100 100
Code: [Select]
InputBox PROTO pText:DWORD,\      ; address of the text to be displayed in the static control
               pCaption:DWORD,\   ; address of the title of the input box
               pBuffer:DWORD,\    ; address of the buffer receiving the input text
               xpos:DWORD,\       ; x-coordinate of the input box
               ypos:DWORD,\       ; y-coordinate of the input box
               pStringLen:DWORD   ; pointer to the number of characters received to the input box

A separate tool was required to read the string stored in the registry :

Code: [Select]
FOR /F "delims=" %%A in ('ReadInputBox.exe') do SET choice=%%A
The output of ReadInputBox.exe is assigned to the variable choice.

A better solution is to write the string received by the input box to the console ( v1.02 ) :

Code: [Select]
FOR /F %%A in ('InputBox.exe "Type yes to continue, no to exit" "Hello" 100 100') do SET string=%%A
No need of ReadInputBox. The FOR loop sets the variable string to the output of InputBox.exe.


hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5944
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: help please: masm32 input dialog box
« Reply #10 on: December 13, 2018, 06:11:02 PM »
JJ,

It may be worth looking for a registry cleaner that tests and ditched unused registry entries. Some better quality AV scanners will also clean out some junk from your registry database.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: