the code below is what I have, with the help of others on this board, up to so far... when I hardcode the indexes in as commented out in the code at the bottom of the listing, it works great. When I increment a local variable pntr inside a .repeat/.until loop, and do an ADD pntr,28... then invoke pushbutton, it blows up with a 'cannot read' error. see below for details.

NOTES: I hardcoded the '28', which is the size of the structure, for now for debugging and hair-pulling purposes. I've tried it with and without ADDRing the PcPt and I get the same results. When I uncomment out the code at the bottom and take out the looping invoke, it works prefectly. Thank you for your continuing support.


.486
.model flat,stdcall
option casemap:none

include <\masm32\rlibinc\gio.inc>
; contains all the includes/prototypes/etc..,.

PANEL_CONTROL struct DWORD
PcPb DWORD ? ;Command
PcPq DWORD ? ;Response ie 400=open,402=close,404=exit,etc
PcPt DWORD ? ;Text on button
PcX1 DWORD ? ;x,y,wid,hgt of button
PcY1 DWORD ?
PcX2 DWORD ?
PcY2 DWORD ?
PANEL_CONTROL ends

; DB = db and C=command
PC_PB equ 0015
QuitDBC equ 500
LaunchDBC equ 600
TestDBC equ 650
OpenDBC equ 651

.data

FontText2 db "with this script type of font...",0
FontName db "Roman",0
F_Comic db "Comic Sans MS",0
MouseClik db 0 ;0=no click yet
BUFA1 db " ",0
QuitDB db "EXIT",0
LaunchDB db "Launch",0
TestDB db "TEST",0
OpenDB db "OPEN",0


;Pc PANEL_CONTROL 16h dup (<>)
Pc PANEL_CONTROL <PC_PB, TestDBC, offset TestDB, 25, 400, 64, 64>,
<PC_PB, OpenDBC, offset OpenDB, 25, 466, 64, 64>,
<PC_PB, LaunchDBC, offset LaunchDB, 25, 530, 64, 64>,
<PC_PB, TestDBC, offset TestDB, 25, 594, 64, 64>

sizeOfPanelControls dd ( $ - Pc ) / sizeof PANEL_CONTROL

.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?

.const

.code

start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine, eax

; FillPC 0, PC_PB, TestDBC, offset TestDB, 25,400,64,64
; FillPC 1, PC_PB, OpenDBC, offset OpenDB, 25,466,64,64

xor eax,eax
mov eax,sizeOfPanelControls
; invoke wsprintf, addr BUFA1, SADD("Size of Buffer: %d"), eax
; invoke MessageBox, NULL, addr BUFA1, SADD("size of panel ctlrs"), MB_OK

;invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT

; invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
invoke ExitProcess,eax


WinMain proc
<blah blah blah>
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL ps:PAINTSTRUCT
LOCAL rect:RECT
LOCAL lcolor:DWORD


.IF uMsg==WM_DESTROY
StopRun

.ELSEIF uMsg == WM_COMMAND
pushad
.if wParam == QuitDBC
StopRun
.endif
.if wParam == LaunchDBC
invoke MessageBox, hWnd, Pc[56].PcPt, SADD("Please Wait"), MB_OK
.endif
.if wParam == TestDBC
invoke MessageBox, hWnd, Pc[0].PcPt, SADD("TESTDBC"), MB_OK
.endif
.if wParam == OpenDBC
invoke MessageBox, hWnd, Pc[28].PcPt, SADD("OpenDBC"), MB_OK
.endif

popad

.ELSEIF uMsg == WM_CREATE
invoke Draw_Panel_Command, hWnd

.ELSEIF uMsg==WM_CHAR
push wParam
pop char
invoke InvalidateRect, hWnd,NULL,TRUE

.ELSEIF uMsg==WM_PAINT
invoke BeginPaint, hWnd, ADDR ps
mov hdc,eax

RGB 192,192,192
mov lcolor,eax
invoke DrawGDI,hdc,0,0,1024,768,GDI_RECT,BS_SOLID,lcolor

invoke EndPaint, hWnd, ADDR ps

.Else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp

Draw_Panel_Command PROC hWnd:HWND
LOCAL pntr:DWORD
mov pntr, 0

.Repeat
invoke wsprintf, addr BUFA1, SADD("Size of pntr: %d"),pntr
invoke MessageBox, NULL, addr BUFA1, SADD("size of pointer ctlrs"), MB_OK

invoke PushButton, Pc.PcPt, hWnd, Pc.PcX1, Pc.PcY1, Pc.PcX2,\
Pc.PcY2, Pc.PcPq
add pntr, 28

.Until pntr >= 112

; invoke PushButton, Pc[0].PcPt,hWnd, Pc[0].PcX1, Pc[0].PcY1, Pc[0].PcX2, Pc[0].PcY2, Pc[0].PcPq
; invoke PushButton, Pc[56].PcPt,hWnd, Pc[56].PcX1, Pc[56].PcY1, Pc[56].PcX2, Pc[56].PcY2, Pc[56].PcPq
; invoke PushButton, Pc[28].PcPt,hWnd, Pc[28].PcX1, Pc[28].PcY1, Pc[28].PcX2, Pc[28].PcY2, Pc[28].PcPq
; invoke PushButton, Pc[84].PcPt,hWnd, Pc[84].PcX1, Pc[84].PcY1, Pc[84].PcX2, Pc[84].PcY2, Pc[84].PcPq
ret
Draw_Panel_Command endp

end start
Posted on 2001-09-08 20:15:22 by drarem
Here's some modification of the frankenstein code per help from here, but still comes up with a read error.. doesn't like the indexing of the structure or so it appears..


Draw_Panel_Command PROC hWnd:HWND
LOCAL pntr:DWORD

xor eax,eax
xor ecx,ecx
mov pntr, 0

.Repeat
mov eax,
mul ecx
inc ecx
lea edi,
pushad
invoke PushButton, (PANEL_CONTROL PTR ).PcPt, hWnd, (PANEL_CONTROL PTR ).PcX1, (PANEL_CONTROL PTR ).PcY1,\
(PANEL_CONTROL PTR ).PcX2, (PANEL_CONTROL PTR ).PcY2, (PANEL_CONTROL PTR ).PcPq
popad

.Until pntr >= 112
Posted on 2001-09-09 20:38:51 by drarem
Looks like you've dropped the increment code for pntr, so it loops forever.
Posted on 2001-09-10 17:27:33 by tank
actually, I cleaned up all my commented code out so it is more readable and wiped out the add pntr,28

however it is there, trust me :) I still have no dice with this, I have tried it multiple ways to fix it.

if I hardcode the indexes as so:

; invoke PushButton, Pc[0].PcPt,hWnd, Pc[0].PcX1, Pc[0].PcY1, Pc[0].PcX2, Pc[0].PcY2, Pc[0].PcPq
; invoke PushButton, Pc[56].PcPt,hWnd, Pc[56].PcX1, Pc[56].PcY1, Pc[56].PcX2, Pc[56].PcY2, Pc[56].PcPq


it works fine. If I do all these invokes in a loop like in my reply above, it comes back with a memory read error. I have tried using ADDR, the loading the pointer to EDI and using PANEL_CONTROL PTR, and it still says memory read error with the PUSHAD and POPAD removed...

if they are left in (PUSHAD and POPAD), program goes into a vicious loop and I have to remove it with the task manager.
Posted on 2001-09-10 18:56:49 by drarem
I don't see how the code you posted could exit? Where does pntr get incremented? Also, this kind of code is begging for the assume directive! Also, look at the use of Pc_Size. Just offering another view...
PANEL_CONTROL struct DWORD

PcPb dd ?
PcPq dd ?
PcPt dd ?
PcX1 dd ?
PcY1 dd ?
PcX2 dd ?
PcY2 dd ?
PANEL_CONTROL ends

Pc PANEL_CONTROL <>,<>,<>,<>
Pc_Size = sizeof Pc / type Pc

.code

Draw_Panel_Command PROC hWnd:HWND
LOCAL pntr:DWORD

xor eax,eax
mov pntr, 0

assume edx:PTR PANEL_CONTROL
.Repeat
mov eax, [sizeof PANEL_CONTROL]
mul pntr
lea edx, [Pc + eax]
invoke PushButton, [edx].PcPt, hWnd, [edx].PcX1, [edx].PcY1, \
[edx].PcX2, [edx].PcY2, [edx].PcPq
inc pntr
.Until pntr >= Pc_Size
assume edx:NOTHING
ret
Draw_Panel_Command ENDP
Posted on 2001-09-10 20:06:38 by bitRAKE
well welll, don't know why it worked but it worked :)

I did have the ADD PNTR, 28 coded, just I removed it accidentally when I posted it to this board when I was cleaning up comments to make it more readable...

guess I can't do a: lea edx,
while incrementing pntr every 28 bytes (size of Pc) ?
I don't see why I can't, if the indexes can be hardcoded then why can't I add 28 to pntr every loop it makes and do that lea?


I'll put reads on everything and look at the edx, eax, etc to see where i went wrong


thanks again bitRake!!!
Posted on 2001-09-10 21:20:05 by drarem
could do:
Draw_Panel_Command PROC hWnd:HWND 

LOCAL pntr:DWORD, count:DWORD

mov pntr, offset Pc
mov count, 0

assume edx:PTR PANEL_CONTROL
.Repeat
mov edx, pntr
invoke PushButton, [edx].PcPt, hWnd, [edx].PcX1, [edx].PcY1, \
[edx].PcX2, [edx].PcY2, [edx].PcPq
add pntr, [sizeof PANEL_CONTROL]
inc count
.Until count >= Pc_Size
assume edx:NOTHING
ret
Draw_Panel_Command ENDP
Posted on 2001-09-10 21:32:00 by bitRAKE