I'm not sure I understand what you are saying. If a API function requires a structure parameter, how can you get away with not passing that structure? I'm sorry I'm not understanding what you are saying, I've probably missed the point entirely.
However, thank you for subtly pointing out my inefficient coding! I coded the routine to get it working and never went back to optimize the code. My bad! You took out the "x2" and "y2" variables and substituted "gridRight" and "gridBottom", which I was assigning every iteration of the for/next loop. There are also other assignments that need to be refactored out.
Here is an updated version of the code:
function Draw_Grid() as long
dim col_number as dword
dim row_number as dword
dim x_pos,y_pos as dword
dim pt as POINT_TYPE
SelectObject(hdc,GetStockObject(%BLACK_PEN))
'draw horizontal lines
for row_number = 0 to astar_RowCount
y_pos = gridTop + (row_number * cellHeight)
MoveToEx(hdc,gridLeft,y_pos,pt)
LineTo(hdc,gridRight,y_pos)
next
'draw vertical lines
for col_number = 0 to astar_ColumnCount
x_pos = gridLeft + (col_number * cellWidth)
MoveToEx(hdc,x_pos,gridTop,pt)
LineTo(hdc,x_pos,gridBottom)
next
end function
I generally write my code to be easy to understand rather than optimized for speed (unless speed is required), and I think the code above is still clear, and more efficient.
Thanks Eros!
Bookmarks