yes,
for the name only.
but the name is going to be a perminemt string
because its going to be called everytime the user clicks on the button.

Just saw your edited version.
What do you mean "permanent string"? I was assuming you had something like a dialog box asking the user for a name, then you call GetDlgItemInt store it in some buffer when the user clicks the OK button, and the dialog box is closed.
Are you using an edit box to show the name to the user, or to ask the user to type a name?
Posted on 2003-08-07 13:44:22 by QvasiModo
ok so then it would be
invoke GetDlgItemText,IDD_DLG8,IDC_EDTNG,ADDR nbuffer,16

right?
-----
edit
-----

ok this is what i wanna do,
i have a dialog box that asks for the name,
when the user clicks ok it stores the name so when the user clicks the next button
i.e. name
a dialog will pop up with there stats,
when the user clicks close,
it closes the dialog, so then when they click name again the dialog opens and the same info is there.
-------

njkt
Posted on 2003-08-07 13:46:41 by njkt809
Remember there is a difference, a dialog box handle is not the same as the dialog box ID. The ID is the number you use in the resource script, and you get to choose it at compile time. The handle is a number assigned by Windows on runtime. In your dialog box procedure, the hWnd member is the dialog box handle (that is, the window handle of the dialog box). I think CreateDialogBoxParam also returns the handle, when you use modeless dialog boxes (but I think this is not your case).

So it would be:
invoke GetDlgItemText,hWnd,IDC_EDTNG,addr nbuffer,sizeof nbuffer

You can use 16 instead of sizeof nbuffer... I prefer the last one, because if you change the buffer size, the GetDlgItemText call changes automatically. Less work, less bugs :)
Posted on 2003-08-07 13:52:05 by QvasiModo

ok this is what i wanna do,
i have a dialog box that asks for the name,
when the user clicks ok it stores the name so when the user clicks the next button
i.e. name
a dialog will pop up with there stats,
when the user clicks close,
it closes the dialog, so then when they click name again the dialog opens and the same info is there.

Gotcha. So you need to store the name in a buffer in your .data or .data? section, NOT in the stack. So instead of defining your buffer as a LOCAL, put it in those sections. If your buffer is large, put it in .data?, or it will increase the size of your executable filling it with zeroes.


.data
nbuffer db 16 dup (0)

If it's big:


.data?
nbuffer db 1024 dup (?)

So you don't add 1024 bytes of useless zeroes to your EXE file.

Also consider this:


.data
nbuffer "Default name", 16-12 dup (0) ;12 bytes string, 16 bytes buffer.
Posted on 2003-08-07 13:56:15 by QvasiModo
ok i have all that down now,
so then how do i display that into the edit box?

invoke SetDlgItemText,hWin,IDC_EDT1,OFFSET nbuffer

right?


----
edit----
----
ok heres the code i have so far,
the button-
.elseif eax==IDC_NGOK
invoke GetDlgItemText,hWnd,IDC_EDTNG,addr nbuffer,sizeof nbuffer

display-
invoke SetDlgItemText,hWin,IDC_EDT1,OFFSET nbuffer

----

njkt
Posted on 2003-08-07 13:58:35 by njkt809
Right. :alright:
Posted on 2003-08-07 13:59:11 by QvasiModo
ok it doesnt work still.

heres what i got



.data
nbuffer db "Default name", 16-12 dup (0)


.elseif eax==IDC_NEWGAME
invoke DialogBoxParam,hInstance,IDD_DLG8,hWnd,OFFSET DlgProc,NULL



DlgProc proc hWin:HWND,iMsg:UINT,wParam:WPARAM,lParam:LPARAM

.if iMsg==WM_INITDIALOG
;set your name
invoke SetDlgItemText,hWin,IDC_EDT1,offset nbuffer
;attack points
invoke SetDlgItemInt,hWin,IDC_EDT3,attackp,TRUE
;defence
invoke SetDlgItemInt,hWin,IDC_EDT4,defencep,TRUE
;Evasion
invoke SetDlgItemInt,hWin,IDC_EDT5,evp,TRUE
;Life
invoke SetDlgItemInt,hWin,IDC_EDT6,hp,TRUE
;MaxLife
invoke SetDlgItemInt,hWin,IDC_EDT8,mhp,TRUE


.elseif iMsg==WM_COMMAND
mov eax,wParam
mov edx,eax
shr edx,16
.if dx==BN_CLICKED
.if eax==IDC_OK
invoke EndDialog,hWin,0
.elseif eax==IDC_NGOK
invoke GetDlgItemText,hWnd,IDC_EDTNG,addr nbuffer,sizeof nbuffer
.endif

(very condenced version.)
it compiles but when i click open the dialog with the edit boxes, there is nothing in for name.

njkt
Posted on 2003-08-07 14:11:41 by njkt809
heres the source, it might make more sence.

njkt
Posted on 2003-08-07 14:18:32 by njkt809
I should work... perhaps the IDs are wrong? chack that the numbers are the same, and you are defining your IDs as constants, not strings:
In rsrs.rc:


#define IDC_EDT1 1000

In Main.asm:

IDC_EDT1 equ 1000


If you forget the "#define" part, the resource compiler will take "IDC_EDT1" as a string, not a constant integer.

And here is a little optimization, too :)



.data
nbuffer db "Default name", 16-12 dup (0)


.elseif eax==IDC_NEWGAME
invoke DialogBoxParam,hInstance,IDD_DLG8,hWnd,OFFSET DlgProc,NULL



DlgProc proc hWin:HWND,iMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,iMsg
.if eax==WM_INITDIALOG
;set your name
invoke SetDlgItemText,hWin,IDC_EDT1,offset nbuffer
;attack points
invoke SetDlgItemInt,hWin,IDC_EDT3,attackp,TRUE
;defence
invoke SetDlgItemInt,hWin,IDC_EDT4,defencep,TRUE
;Evasion
invoke SetDlgItemInt,hWin,IDC_EDT5,evp,TRUE
;Life
invoke SetDlgItemInt,hWin,IDC_EDT6,hp,TRUE
;MaxLife
invoke SetDlgItemInt,hWin,IDC_EDT8,mhp,TRUE


.elseif eax==WM_COMMAND
mov eax,wParam
.if eax==IDC_OK
invoke EndDialog,hWin,0
.elseif eax==IDC_NGOK
invoke GetDlgItemText,hWnd,IDC_EDTNG,addr nbuffer,sizeof nbuffer
.endif

I put the message code in EAX because it's faster and shorter (less bytes). If you use a variable name, that assembles as a pointer to memory. Using registers saves space and time.
The WM_COMMAND code works because BN_CLICKED == 0, so you can use the wParam value as the item ID, no need to check for the notification message in this case (less instructions).
Posted on 2003-08-07 14:20:40 by QvasiModo

heres the source, it might make more sence.

njkt

Looking at it...

EDIT:
Shouldn't it be better to use a separate dialog proc for each dialog box? That might make your code more readable (at the expense of extra bytes).

Also, there are 2 different controls with the name, one for the user to type in, another for the stats. If you want to first one to hold the name, you should call SetDlgItemText with that one too. Or you can make them both have the same control ID (so the same call works for both). That is if they are not together in the same dialog box... I didn't look so carefully. Perhaps you could include a compiled version? (I don't have masm here).
Posted on 2003-08-07 14:26:15 by QvasiModo
cant include a compiled version because of its size
1 mb without images included :rolleyes:

i can tell u wat its doing (sorry my modem is to slow to upload megabytes)
first u click on the home button, it brings up the stats with the default name vahn.
u click new game and it brings up a dialog with an editbox for the name, u click create and it should replace the default with the new,
but u click on home again and the name edit box is empty.

(i try to upload it)


njkt
Posted on 2003-08-07 14:39:25 by njkt809
Been thinking... you are using background images in your dialog boxes. But the size of a dialog box is defined at runtime, so you can't be sure if the image will look good. for example, if you change from small fonts to big fonts, all your dialog boxes will be bigger too (DBUs are calculated using the font height). Try using CreateWindow instead, so you can know the size and position of each control in pixels, always. Or you can paint the bitmap yourself using StretchBlt, instead of placing an image control (that way if the dialog box has a different size, the background picture will stretch to resize accordingly). You have an example of this in Iczelion's bitmap tutorial (but he uses BitBlt instead, you will have to change some code).

If the file is so big, don't worry trying to upload it (specially if you have a modem... I know your pain... :grin: ).

Just make sure that the IDs are correct, else add the SetDlgItemText calls you need. You know your own code better than me, and can test it... try it and let me know what happened.

EDIT: From 1 meg to 160K ??? You need an EXE packer, my friend! LOL
Try using GIF instead of BMP, masm32.lib has functions for this.
Posted on 2003-08-07 14:45:06 by QvasiModo
the resize is locked so it wouldnt matter i think if i used paint instead of a control.
and so is the maximise button.

njkt
Posted on 2003-08-07 14:47:40 by njkt809
Downloaded it twice, but didn't work... the zip file seems to be corrupted. Perhaps IE didn't upload it well? I had similar problems before, try uploading again...
Posted on 2003-08-07 14:48:57 by QvasiModo

the resize is locked so it wouldnt matter i think if i used paint instead of a control.
and so is the maximise button.

njkt

Not quite what I meant... even if the user doesn't resize, if you have big fonts instead of small fonts the dialog box will have a different size. And if you use a different font face, the proportions will change too. Try it... use a different font face in your resource script, you will see the dialog box has a different layout.
Posted on 2003-08-07 14:50:37 by QvasiModo
ok,

all of the words are in the images, i didnt use any static text.
Posted on 2003-08-07 14:52:36 by njkt809
Great, now NO zip file can be open. bug in the stupid computer I'm using now. Blame it on microsoft.
I will try downloading Winzip... please wait...
Posted on 2003-08-07 14:58:44 by QvasiModo

ok,

all of the words are in the images, i didnt use any static text.


While I wait I'll reply to your other post...

The problem is a dialog box resource ALWAYS uses a font face, even if you don't use static text. This is because Windows needs it to calculate the window sizes in dialog boxes. Look in your dialog box definitions in the resource script, you will see something like this:


FONT 8, "MS Sans Serif"

The is the size and face. Change either, and recompile, you will see what I mean... this is the biggest problem about using background images in dialog boxes. :(
Posted on 2003-08-07 15:02:49 by QvasiModo
but when will it need to change the font of the dialog?
i thought when it was an .exe that the font insn't called from the computer but its saved inside the exe


njkt
Posted on 2003-08-07 15:11:23 by njkt809
Quick toying with your program gives me a hint, perhaps the call to GetDlgItemText has a bug and is destroying the text in nbuffer. Make sure that all IDs are correct, just in case... maybe the program is trying to retrieve the text from the wrong control, or something like that. Clicking New Game, Ok, the New Game again does not show the user name...

Also:

IDC_EDTNG equ 10056
IDC_EDT1 equ 1012

You need to call SetDlgItemText twice, I think. If I undestood correctly, both IDC_EDT1 and IDC_EDTNG text boxes should show the user name when the dialog box starts.
Posted on 2003-08-07 15:13:19 by QvasiModo