new game is to create a new charictar,
to view stats goto home.
---
edit--
---
omg!
hahah i feel dumb, it was staring my right in the face,
instad of hWnd its hWin :o :o :o :o :o :o
ok it works now

but then it brings me to my next questions, how do i tenn is a check box has been checked, and then add the value of that check box with another and then the sum with a number?


njkt
Posted on 2003-08-07 15:14:38 by njkt809

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

The font is not saved in the exe, unless you add a FONT resource type and use that one. If you do that, make sure it is not a copyrighted one.

But even in that case, if the user has selected large fonts instead of small fonts in control panel, the dialog box sizes will mess up... I didn't tell you to try that because it needs a reboot to show the changes, but changing the font size in the resource script has a similar effect.

There are some threads in this board about this problem, I think... and some examples on using skins that show how to circumvent it.
Posted on 2003-08-07 15:18:08 by QvasiModo

new game is to create a new charictar,
to view stats goto home.
---
edit--
---
omg!
hahah i feel dumb, it was staring my right in the face,
instad of hWnd its hWin :o :o :o :o :o :o
ok it works now


It can happen to anyone :grin:

but then it brings me to my next questions, how do i tenn is a check box has been checked, and then add the value of that check box with another and then the sum with a number?


Not sure what you mean... check boxes don't have values, but states: checked, unchecked, and undetermined. Maybe what you want to do is have pairs of edit boxes and check boxes, when the check box is checked add the number in the edit box?

The APIs (look in http://msdn.microsoft.com):
IsDlgButtonChecked
CheckDlgButton (I'm not sure I remember the correct name of this one...)
Posted on 2003-08-07 15:22:04 by QvasiModo
ok if u goto store, u will see the check boxes,
i want to be able to see if those are checked and if they are add a sertain value (specific to the check box) to a main number.

---edit
ok never mind im going to try and use an editbox instead, its easier hahaha.

---

njkt
Posted on 2003-08-07 15:24:12 by njkt809
Gotcha. Try something like this:


push ebx ;we use ebx to store the number, because the APIs will not touch it
xor ebx,ebx ;initial value: 0
invoke IsDlgButtonChecked,hWin,IDC_CHECK1
.if eax == BST_CHECKED
add ebx,VALUE1
.endif
invoke IsDlgButtonChecked,hWin,IDC_CHECK2
.if eax == BST_CHECKED
add ebx,VALUE2
.endif

;etc...

pop ebx ;restore ebx old value

It would be more "elegant" to do it in a loop, though...


.data
ValueArray dd VALUE1, VALUE2, (etc...), LAST_VALUE

.code
push ebx
push esi
push edi
xor ebx,ebx
mov esi,NUMBER_OF_CHECKBOXES
mov edi,ID_OF_FIRST_CHECK_BOX
.repeat
invoke IsDlgButtonChecked,hWin,edi
.if eax == BST_CHECKED
add ebx,[offset ValueArray + (esi * 4)]
.endif
dec esi
.until zero?
pop edi
pop esi
pop ebx
Posted on 2003-08-07 15:33:47 by QvasiModo

---edit
ok never mind im going to try and use an editbox instead, its easier hahaha.

Read it too late... now my last post is useless... :grin:
Seriously, consider using checkboxes... unless you want the user being able to change your values...
Posted on 2003-08-07 15:35:05 by QvasiModo
i might just use check boxes,
i was considering editboxes because if the user wants to change the quantity of the item,
but then i remembed its a loop so i could use check boxes instead.
Posted on 2003-08-07 15:39:25 by njkt809
You could have both edit boxes and check boxes. Then for each check box, if it is checked, read the quantity of items and multiply by it's price (or something like that). You can do it in a loop, as well (but it's a little more work).
Posted on 2003-08-07 16:00:06 by QvasiModo
ok that sounds good,
i made it more readable for source files and editing.

now im going to start working on the store so i will probably be using ur post alot for code alot.

njkt
Posted on 2003-08-07 16:10:21 by njkt809

ok that sounds good,
i made it more readable for source files and editing.

now im going to start working on the store so i will probably be using ur post alot for code alot.

njkt


Cool :cool:

So, how will you solve the bitmaps issue? I remembered another solution to it, you could have two sets of images, one for small fonts, another for large fonts... there are several skinning examples around here, you might want to check those too...
Posted on 2003-08-07 16:15:09 by QvasiModo
for now im using a control instead, this is until the game fully works then i will use that skinning thing.

anyways,
about the check boxes,





invoke IsDlgButtonChecked,hWin,IDC_CHECK1
.if eax == BST_CHECKED
add ebx,VALUE1
mov sum, ebx
invoke SetDlgItemInt,hWin,IDC_EDT5,sum,TRUE




would that work to display the amount of money used if that check box is checked?
Posted on 2003-08-07 16:29:28 by njkt809
Sure, you can also use EBX instead of "sum" in your example, since they have the same value. Pushing a register is shorter and faster than pushing a variable. However, if you cut & paste that line of code somwhere else, you'll have to remember to replace "bex" for "sum" again (I know it sounds like a stupid recomendation, but it happens a lot if you're not paying much attention).
Posted on 2003-08-07 16:36:42 by QvasiModo
ok thinking in loops right now,
if i use this code


.data
ValueArray dd VALUE1, VALUE2, (etc...), LAST_VALUE

.code
push ebx
push esi
push edi
xor ebx,ebx
mov esi,NUMBER_OF_CHECKBOXES
mov edi,ID_OF_FIRST_CHECK_BOX
.repeat
invoke IsDlgButtonChecked,hWin,edi
.if eax == BST_CHECKED
add ebx,[offset ValueArray + (esi * 4)]
.endif
dec esi
.until zero?
pop edi
pop esi
pop ebx

how the computer know what the values are of the array?
(sorry i havent used arrays ever)
and how would i continue the loop until the button Buy is clicked?
Posted on 2003-08-07 16:43:28 by njkt809
Arrays are simple. The key is in the instruction that fetches the value:
add ebx,[offset ValueArray + (esi * 4)]

That means the esi has the index to the array item, the items are 4 bytes long, and the array starts at offset ValueArray. So if you want to read the third value in an array of DWORDs (4 bytes each), the offset is:


Start_of_array + (Element_number * Element_size)

This math works only when you have an array of elements all with the same size, naturally. Also you can see why arrays in assembly begin with index 0...


Start_of_array + (0 * Element_size) = Start_of_array

The loop I showed to you as an example gets the check state of each checkbox from Number_of_checkboxes to 0 (it's easier to write loops backwards, you don't have to check if the index passed the maximum number, instead you check if it reaches zero). When the checkbox is checked, it adds the value from the array. If you want to, you can modify this by reading a value from an edit box, then multiplying with the value in the array, then adding the result.


.data
; Item prices
ValueArray dd VALUE1, VALUE2, (etc...), LAST_VALUE

.code
push ebx
push esi
xor ebx,ebx
mov esi,NUMBER_OF_CHECKBOXES
.repeat
mov eax,esi
add eax,ID_OF_FIRST_CHECKBOX
invoke IsDlgButtonChecked,hWin,eax
.if eax == BST_CHECKED
mov eax,esi
add eax,ID_OF_FIRST_EDITBOX
invoke GetDlgItemInt,hWin,eax,0,0
mul dword ptr [offset ValueArray + (esi * 4)]
add ebx,eax ;watch out! with VERY big values it overflows (> 2 billion or so)
.endif
dec esi
.until zero?
mov eax,ebx ;Don't forget to keep the result, like I did :)
pop esi
pop ebx

You can call that code when the Buy button is pushed. You will have the result in EAX.

Ok, I'm off now (I have to go home... I've been here for hours :grin: ). See ya tomorrow. :alright:
Posted on 2003-08-07 17:00:30 by QvasiModo
I've been looking more closely into your source code at home, and this suggestions came to my mind:

1) All the bitmaps have been defined using the same constant! It works because the constant is redefined, but it is really confusing, and triggers a compiler warning... try using a different constant for each bitmap, and then define the same values as equates in your asm source. It it more readable. Trust me, if you ever try to come back to this project after it's finished, you won't be able to know what you did here :grin: it happened to me a lot... the best thing to do when programming is to pretend you are coding for someone else. Keep your code commented, and don't mix up variable and constants names. :)

2) Another coding "etiquette" detail: instead of hWin and hWnd, use different names. Those two are so similar it leads to confusion... :)

3) You really need to compress your pictures. There are two ways to do it:
a) EXE packer. Grap a copy of UPX, it's free, and your file will be reduced from 1.10 MB to 160 Kb.
b) GIF or JPG images. If you use this image formats, remember to include them in your resource scripts as IMAGE type (BITMAP will not work). You can load them with the BitmapFromResource function in masm32.lib, it's very similar to LoadBitmap. Or you can use BitmapFromFile in the same library, if you want to keep your images in separated files.

There were still two bitmap pictures in the file you uploaded, but they were not shown... The file size would have been 8 Kb instead :grin: Very cool pictures, BTW :alright:

4) How about using a resource ID instead of a name for "MyMenu"? It saves some space and time when loading -and there's no real advantage in using names if you're not programming in C. Same goes for MyDialog.

5) How about using the same dialog box for "Attack" and "Defense", but different dialog procedures? Since you have the advantage of keeping all your text in the background bitmap, just changing the background archieves the same effect.

6) I've attached a sample of how it looks with small and large fonts configured in control panel... this is what I meant in those posts before. Sorry for nagging you with that, it's just that a lot of people has large fonts configured (specially when they have small monitors with big resolutions), and it might piss off your users if they have to reconfigure Windows and restart the PC to use your program... :(

7) How about processing WM_COMMAND -> IDCANCEL events? That way the user can close the dialog boxes with the "close" button in the caption bar. Works just like a "Cancel" button.

Ok, that's all I could think of... hope it helps :)
Posted on 2003-08-08 11:12:30 by QvasiModo
ok well ive made many adjustments to the source code,
more commects, and better definitions.
and instead of using check boxes and numbers i used buttons to keep things simple for now.

where do i get an exe packer?

(sounds dumb)
but where do u get the wm_command list, sorry i dont really have any resources on my comp.


new source code, it will assemble although the bitmaps are still just experimental probably wont work since i was using it for testing purposes.
Posted on 2003-08-08 12:51:02 by njkt809
about the font resource,
how would i go about makeing one?
any examples
(my font isnt copyrighted)

njkt
Posted on 2003-08-08 18:14:44 by njkt809

ok well ive made many adjustments to the source code,
more commects, and better definitions.
and instead of using check boxes and numbers i used buttons to keep things simple for now.

where do i get an exe packer?

(sounds dumb)
but where do u get the wm_command list, sorry i dont really have any resources on my comp.


new source code, it will assemble although the bitmaps are still just experimental probably wont work since i was using it for testing purposes.


The best resource for the Windows API is Microsoft itself, http://msdn.microsoft.com.

This following URLs will get you going too. If you need more info, try google, there's a lot there :)
Also Iczelion's webpage has great links.

This one is the full API specs, but it's a little old (Win98 and NT 4 only). But if you have a dialup connection at home (like me) it's a good resource to have offline.
ftp://ftp.cs.virginia.edu/pub/lcc-win32/win32hlp.exe

These are some other docs:
http://www.friends-of-fpc.org/tools/api/opengl/oglhlp.zip
http://webster.cs.ucr.edu/Page_win32/win32apidoc.zip
http://www.tlsecurity.net/Textware/Programming/ole.zip
http://www.df.lth.se/~john_e/archive/allgems.zip
http://webster.cs.ucr.edu/Page_TechDocs/MASMReference.pdf
http://webster.cs.ucr.edu/Page_TechDocs/MASM-programmersguide611.zip

About the EXE packers, there are many out there, but the best I know of are PEtite, UPX and ASpack. PEtite is freeware, but I think you need a license if you're distributing your programs packed with it. UPX is 100& free, I think, and also has an option to uncompress. PECompact is very good too, has many options, but I've seen a few bugs so I try to avoid it (perhaps there's a new version... I have quite an old one).

UPX homepage: http://www.upx.sourceforge.net
PEtite 2.2 download: http://www.un4seen.com/petite/petite22.zip
ASpack 2.12 download: http://www.aspack.com/files/aspack212.zip

Bear in mind that EXE packers compress the resources too. That means the exe file size will be smaller, but the drawback is that compressed resources are only accesible to your program. For example, if you compress all of the icons, they will not be shown in explorer. Same thing happens with HTML and version resources. Usually the exe packer will have an option to select wich resources to compress and wich resources to leave alone.

Have fun! :alright:
Posted on 2003-08-09 11:21:10 by QvasiModo

about the font resource,
how would i go about makeing one?
any examples
(my font isnt copyrighted)

njkt

I'm afraid I have no idea of how to do that, except that you need to put your font in a FONT resource, and it needs to be loaded in a special way. But there are numerous examples on this in the board (god bless the search function :grin: ) and MASM comes with a help file on resource scripts (in the \masm32\bin directory). I have never done it, but I have the feeling it must be easy. :)
Posted on 2003-08-09 11:47:16 by QvasiModo
hey,
i dont plan on distributing my .exe except to those who want it,


FONT Resource

nameID FONT filename
The FONT resource-definition statement specifies a file that contains a font.
For a font resource, nameID must be a number; it cannot be a name.

Parameters

nameID

Specifies either a unique name or a 16-bit unsigned integer value identifying the resource.

load-mem

Specifies loading and memory attributes for the resource. For more information, see "Common Resource Attributes".

filename

Specifies the name of the file that contains the resource. The name must be a valid filename; it must be a full path if the file is not in the current working directory. The path can either be a quoted or non-quoted string.

Example

The following example specifies a single font resource:

5 FONT CMROMAN.FNT

from the rc.hlp
-------------------

also,
now i need some help with a list box, ive looked at the other thread ands they seems the be using windows instead of dialogs,

i have my list box made, how do i put text inside? i know i gotta use a string but i dono how to make the text get into the list box.


njkt
Posted on 2003-08-09 14:36:11 by njkt809