News:

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

Question about a masm default example

Started by Eric4ever, April 13, 2006, 05:20:12 AM

Previous topic - Next topic

Eric4ever

\masm32\examples\exampl09\tables


Any Explaination would be appreciate.
I get the main point but puzzled by some sentences and usage.


1.
      checkarray MACRO cnt1,cnt2,spc,lft,top:REQ
        LOCAL idnum,hstep,vstep,lspc,stcnt,var
          idnum = 500
          stcnt = 400
          hstep = 0
          vstep = 0
        REPEAT cnt1
          DlgStatic 0,SS_RIGHT,3,top+vstep,15,8,stcnt
          stcnt = stcnt + 1
            REPEAT cnt2
              DlgCheck 0,0,lft + hstep,top + vstep,8,8,idnum
              idnum = idnum + 1
              hstep = hstep + spc
            ENDM
          vstep = vstep + spc
          hstep = 0
        ENDM
      ENDM

2.
mov hInstance, FUNC(GetModuleHandle,NULL) ---- FUNC() ?

3.
main proc ---- What's the habit/usage to create window? Why not use .rc file?

    Dialog "Create Character Table", \      ; caption
           "MS Sans Serif",10, \            ; font,pointsize
            WS_OVERLAPPED or \              ; styles for
            WS_SYSMENU or DS_CENTER, \      ; dialog window
            256 + 16 + 8, \                 ; number of controls
            50,50,203,240, \                ; x y co-ordinates
            32768                           ; memory buffer size

    DlgButton "Numbers",   WS_TABSTOP, 21,185,50,13,100

4.
CallModalDialog hInstance,0,DlgProc,NULL ---- CallModalDialog? Where is the defination?
free pMem

5.
mov str1, ustr$(ccntr) ---- ustr$(ccntr) ?
fn SetWindowText,FUNC(GetDlgItem,hWin,nrange),str1 ---- fn?
mov str1,cat$(str1,"Ascii ",str$(ctrl)," Hex ",right$(hex$(ctrl),2)," Character ",str2)

hutch--

Eric,

The example is an in memory template for a dialog and is a standard API for creating a dialog. This example will not run on win98se because it appears to use too many controls for the win98se dialog engine. It was designed on Win2000 and should only be used for win2000 or later.

It uses a variety of macros for different tasks, the dialogs are created using the macros from "dialogs.inc", the others are in the macros.asm file in the macros directory.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MichaelW

Eric,

I think you could find the answer to most of your questions in the MASM32 help files, in particular hlhelp.hlp and dialogs.hlp. For help in understanding how the macros work, see the MASM documentation available here, MASM Programmer's Guide, Chapter 9: Using Macros.

eschew obfuscation

Eric4ever

THX  :toothy

I Got it more or less :bdg

Eric4ever

There is a question about the AutoCheckBox:

the macro define 256 autocheckbox

      checkarray MACRO cnt1,cnt2,spc,lft,top:REQ ; checkarray 16,16,10,22,20
        LOCAL idnum,hstep,vstep,lspc,stcnt,var
          idnum = 500
          stcnt = 400
          hstep = 0
          vstep = 15
        REPEAT cnt1 ; cnt1=16
          DlgStatic 0,SS_RIGHT,3,top+vstep,15,8,stcnt ; static control, ty=top+vstep=20
          stcnt = stcnt + 1
            REPEAT cnt2 ; cnt2=16
              DlgCheck 0,0,lft + hstep,top + vstep,8,8,idnum ; check box, tx=lft+hstep=22
              idnum = idnum + 1
              hstep = hstep + spc ; spc=10
            ENDM
          vstep = vstep + spc
          hstep = 0
        ENDM
      ENDM


I just want to SetTimer when the 1st(any of the 256) autocheckbox checked, the question is How can I use the IsDlgButtonChecked to check it? There is no handle of autocheckbox, and define 256 handle too boring and stupid..

MichaelW

You can intercept the BN_CLICKED notification in DlgProc, checking the low-order word of wParam for a control identifier in the range 500-755.

Also, the check box handles are not available within the macro, but the handles are being obtained in a loop in DlgProc.


eschew obfuscation

Eric4ever

Quote from: MichaelW on April 14, 2006, 09:16:54 AM
You can intercept the BN_CLICKED notification in DlgProc, checking the low-order word of wParam for a control identifier in the range 500-755.

Also, the check box handles are not available within the macro, but the handles are being obtained in a loop in DlgProc.


Hi MichaelW,

Do I made some mistakes? I'm puzzled by the memory template for a dialog and BN_CLICKED notification.

      Case WM_COMMAND
        Switch wParam
          Case IDOK                       ; clear
            mov nrange, 500
            .while nrange <= 755
              invoke SendMessage,FUNC(GetDlgItem,hWin,nrange),BM_SETCHECK,BST_UNCHECKED,0
              add nrange, 1
            .endw
          Case IDCANCEL
            jmp quit_dialog
          Case BN_CLICKED
            mov eax,wParam
           mov nrange, 500
            .while nrange <= 755
              invoke  IsDlgButtonChecked,FUNC(GetDlgItem,hWin,nrange),nrange
              .if eax == BST_CHECKED
              invoke  SetTimer,hWin,ID_TIMER,5000,NULL
              jz @F
              .endif
              add nrange, 1
            .endw
            @@:
          Default
       
        EndSw



MichaelW

From the page I linked:
Quote
The low-order word contains the button's control identifier. The high-order word specifies the notification message.

So you could use something like this (without the MessageBox):

mov eax, wParam
shr eax, 16
.IF eax == BN_CLICKED
  mov eax, wParam
  and eax, 0ffffh
  MsgBox 0,ustr$(eax),"ControlID",MB_TOPMOST
.ENDIF

eschew obfuscation

Eric4ever

Quote from: MichaelW on April 20, 2006, 06:23:55 AM
From the page I linked:
Quote
The low-order word contains the button's control identifier. The high-order word specifies the notification message.

So you could use something like this (without the MessageBox):

mov eax, wParam
shr eax, 16
.IF eax == BN_CLICKED
  mov eax, wParam
  and eax, 0ffffh
  MsgBox 0,ustr$(eax),"ControlID",MB_TOPMOST
.ENDIF



MichaelW,

I get it. But I'm still puzzled by the non-handle autocheckbox. I tried it several times but failed. how can I receive the message and SetTimer when the 1st(any of the 256) autocheckbox checked.
any snipplet would be appreciate.
Thanks in advanced.

MichaelW

You could get a handle for each of the check boxes and then use IsDlgButtonChecked to determine the state of each one, but doing so would be inefficient. The snippet I posted shows how to get the control ID for any button that the user clicks. Instead of displaying the ID in a message box as I did, you could check the ID to determine if the user clicked a check box (ID >= 500 and <= 755), and if so call SetTimer. I don't know what you are doing with the timer(s), but if you intend to have only one timer then you will need some way for the code that calls SetTimer to determine if the timer is already running.

eschew obfuscation