News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Create a Array

Started by ragdog, October 21, 2012, 07:51:58 AM

Previous topic - Next topic

ragdog

Hi @All

I work on a tool this have many Check boxes and options
But Gives for it a better sulotion?


.const
IDC_Option1 equ 1001
IDC_Option2 equ 1002
...
..
.
.data
szOptionString db "Option1",0
szOptionString2 db "Option2",0
...
..
.

Option1 dd offset szOptionString ,IDC_Option1 ,TRUE,0   
Option2 dd offset szOptionString2 ,IDC_Option2 ,TRUE,0   
...
..
.

MyProcs \
dd offset Option1
dd offset Option2
...
..
.
.code
lea esi,MyProcs


Greets,

qWord

You may be able to create a macro that simplifies the declaration ... or you simply use a Dialog that is build with a Resource editor.
MREAL macros - when you need floating point arithmetic while assembling!

Tedd

For creation..
IDC_Option1 equ 1001

.const
optStr1 db "Arm",0
optStr2 db "Leg",0
...

optStrs dd OFFSET optStr1, OFFSET optStr2, ..., 0


.code
  mov esi,OFFSET optStrs
  mov ebx,IDC_Option1
@@:
  mov eax,[esi]
  test eax,eax
  jz @F

  ;create your checkbox -- szLabel=eax, ID=ebx, ..something for position?

  add esi,4
  inc ebx
  jmp @B

@@:
  ;...etc...


Checking their states can be done in a similar way.
Potato2

jj2007

Quote from: qWord on October 21, 2012, 08:22:03 AM
You may be able to create a macro that simplifies the declaration

Here is one, just for fun...

include \masm32\include\masm32rt.inc
include SetArray.inc  ; attached

.data?
TheArray   dd 100 dup(?)

.code
txStrings   db "File", 0
   db "New", 0
   db "Open", 0
   db "Save", 0
   db "Save As", 0
   db 0

start:
   mov esi, offset TheArray
   ; also valid: SetArray TheArray, txStrings
   SetArray esi, txStrings
   xor ebx, ebx
   .While 1
      lodsd
      .Break .if !eax
      push eax
      print "#"
      inc ebx
      print str$(ebx), 9
      pop eax
      print eax, 13, 10
   .Endw
   inkey
   exit
end start

ragdog

Hi thanks to all

very nice tips

I have figured out a other solution like TBBUTTON struct

OptionStruct Struct     
pszText     DWORD ?
idCommand   DWORD ?
lParam      DWORD ?
OptionStruct ends


pOption          Option <offset szOption1,IDC_CHECKBOX1,offset Option1>
                       Option <offset szOption2,IDC_CHECKBOX2,offset Option2>
nbrOfPatches equ ($-offset pOption) / size OptionStruct

lea esi,pOption


And works very nice