News:

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

Using '%S' to set word

Started by hfheatherfox07, April 28, 2011, 03:58:05 AM

Previous topic - Next topic

hfheatherfox07

Hi, I saw this used in an example here on the MASM Forum for displaying your computer serial...
So I started messing with the concept,
and I was wondering why does it only work to display the word you enter correctly if you use one line ... and not more???

Please enter a word or some random text into the edit box and you will see what I mean....




donkey

Well, I would suspect this to start with:

invoke SendMessage,szString,WM_GETTEXT,sizeof szString,addr szString

SendMessage requires a handle in the first parameter.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hfheatherfox07

Thank you for your response.... I love your Avatar by the way , just love those offset eyes ...

I don't know what you mean by what you said ... but I will definitely try to change that line and use something else....

P.S

I noticed that you are a TASM kind of guy

I found this example that is written in tasm and I wanted to make it for MASM but with a rsrc.rc ...
Would it be possible?

Sorry I figured you for the TASM Guru

This was so interesting but it is beyond my capabilites to uderstand...

dedndave

what Edgar means is...
invoke SendMessage,WindowHandleGoesHere,WM_GETTEXT,sizeof szString,addr szString
you can enter the name of the function into google - the MSDN page is usually the first thing to come up
http://msdn.microsoft.com/en-us/library/ms644950%28v=vs.85%29.aspx
then, on the left, click around for more info   :U

in this case, it is also handy to look up the docs on the specific message
http://msdn.microsoft.com/en-us/library/ms632627%28v=vs.85%29.aspx

as for the other program, that is an old DOS 16-bit program   :P

hfheatherfox07

I am going to try that...

I also seen an example  GetDlgItemInt was used

http://msdn.microsoft.com/en-us/library/ms645485(v=vs.85).aspx

I might try this as well ....


dedndave

i used this message to get text from the edit control
        mov word ptr LineBuf,sizeof LineBuf-1
        INVOKE  SendMessage,hEdit,EM_GETLINE,0,offset LineBuf

http://msdn.microsoft.com/en-us/library/bb761584%28v=vs.85%29.aspx
you have to place the length of the buffer in the first word of the buffer
which is a little unusual for win32   :wink

dedndave

the trick is to know when they hit the enter key   :bg

hfheatherfox07

Quote from: dedndave on April 29, 2011, 03:35:03 AM
i used this message to get text from the edit control
        mov word ptr LineBuf,sizeof LineBuf-1
        INVOKE  SendMessage,hEdit,EM_GETLINE,0,offset LineBuf

http://msdn.microsoft.com/en-us/library/bb761584%28v=vs.85%29.aspx
you have to place the length of the buffer in the first word of the buffer
which is a little unusual for win32   :wink

I tried this and still got the same results in the 2nd and 3rd line?

hfheatherfox07

Quote from: donkey on April 28, 2011, 07:06:42 AM
Well, I would suspect this to start with:

invoke SendMessage,szString,WM_GETTEXT,sizeof szString,addr szString

SendMessage requires a handle in the first parameter.

I tried this and adding a handle seams to crash the app when you press "get text" button ... what am I doing wrong?

I looked at this post on  Obtaining the handle of a console window and got further confused:
http://www.masm32.com/board/index.php?PHPSESSID=9382dac5dec0e8908a744043597e6309&topic=11042;prev_next=next

it is something simple that I am over looking but what?

I tried

.data?

buffer db 512 dup(?)
bufout LPSTR ? <- instead of finalszString

invoke GetDlgItemText, hwnd, hedit1, addr buffer, 512

I am even thinking of a sacrificial edit box to copy the text there first?

Now that I started this it will bug me until a solution is found  :(

dedndave

when you create a window or control the handle is returned in EAX
if the control is created in resource, you may use GetDlgItem to get the handle
that function works for all windows or controls - it does not have to be a dialog or dialog item
the only handle i have found that i was unable to get so far is the caps lock tooltip handle in ES_PASSWORD controls - lol

hfheatherfox07

can you get  that working ?? I am beat duno what else to do ... it does not make any sense that the word "%s" is only replaced once and not multiple times why??

Gunner

I was bored...  I didn't use wsprintf, I used szRep from the Masm32 lib... should get you started...
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

hfheatherfox07


Gunner

To answer your question as to why wsprintf only replaced 1 %s.. you have 3 format types you want wsprintf to replace, so you have to give it 3 strings to replace with....

invoke  wsprintf,addr FinalszString,addr szString,addr buffer, addr buffer, addr  buffer  works... I just prefer szRep from the MASM lib  :bg
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

hfheatherfox07

Thanks I am going through yours to try and fix mine so I can understand it ( not just copy it)


You commented this
COMMENT #
These should be in .data because they are initialized
buffer2 db 100 dup(0)
buffer   db 100 dup(0);this buffer is used to "hold" what we enter in the text box!
FinalszString   db 100 dup(0); buffer2 holds buffer + szString #

That would explain why I kept getting warnings at those address's I thought it was :

buffer2 db 100 dup(0)  instead of buffer2 db 100 dup(?)

I never realized that I needed to initialize them
I thought that because we do not know the  buffer size but know a max of 100 bytes ...they go into .data?

This might help me with some other examples that I am working on
I thought  that data that is defined "fixed" goes to .data
and data that is unknown but defined goes to .data?

Thank you so much again :bg