Maze Solver - Updated Version 06 Oct 07
Hello All,
I'm posting an updated version of the Maze Solver application.
I've tried to put in some re-sizing functionality, but I'm not sure if I did it correctly. It seems to work OK on my computer.
Somehow, while modifying the code for the re-sizing, I believe I fixed the multiple re-draw problem. Don't know what I did that fixed it.
Nothing else is new, but please try this version and let me know if the resizing works for you.
I'll update the original post with this new version.
Thanks,
Randall
Re: Maze Solver - Updated Version 06 Oct 07
Randall,
more window refresh is still there but window resize is a great addition!
I've "stiky" you post containing the source code (so it will always remain above all other posts) and added a note area to it so people knows when updates have taken place.
Thanks a lot
Eros
Re: Maze Solver - Updated Version 06 Oct 07
Hi Randall,
new version works perfectly !
Just one thing - about dialog is opened twice ( ? ). When I click about box and then close, it re-appears. When I press close again, then it is gone as it should.
The same applies to help file.
But the new resizing feature is very good, and I think now it must work even in 640*480 :)
Thanks,
Petr
Re: Maze Solver - Updated Version 06 Oct 07
Double messages seems a bug in GetMessage function when used with notification structure.
When used in standard way, GetMessage(hDlg, wParam, lParam), all seems ok.
I will check UI module.
1 Attachment(s)
Re: Maze Solver - Updated Version 06 Oct 07
Can you please confirm that attached new thinBasic_UI.dll solve the double message firing?
Thanks
Eros
Re: Maze Solver - Updated Version 06 Oct 07
Also this code should remove all multiple refreshing generated by the many %WM_PAINT and %WM_SIZE messages:
Code:
CASE %WM_PAINT
ClearMessages(hDlg)
Call Paint_Grid_Window()
Call Paint_Draw_Mode_Legend()
CASE %WM_SIZE
ClearMessages(hDlg)
Call Dialog_Resize_Event_Handler()
Re: Maze Solver - Updated Version 06 Oct 07
Quote:
Originally Posted by ErosOlmi
Can you please confirm that attached new thinBasic_UI.dll solve the double message firing?
Yes, I believe this fixes the multiple message firing. After installing, I did not get the "about", "open", and "save-as" dialogs appearing twice.
Thanks Eros.
Re: Maze Solver - Updated Version 06 Oct 07
Quote:
Originally Posted by ErosOlmi
Also this code should remove all multiple refreshing generated by the many %WM_PAINT and %WM_SIZE messages:
[code=thinbasic]
CASE %WM_PAINT
ClearMessages(hDlg)
Call Paint_Grid_Window()
Call Paint_Draw_Mode_Legend()
CASE %WM_SIZE
ClearMessages(hDlg)
Call Dialog_Resize_Event_Handler()
[/code]
I added this code and I do believe the multiple re-paints are gone. I'm so tired and bleary-eyed (as I was last night) that maybe I'm just not seeing it. Looks good to me.
Thanks again, Eros!
Re: Maze Solver - Updated Version 06 Oct 07
Randall,
possibly, keep the original source code updated.
Sorry for asking that, but it is important for all other users following your development on this nice example.
Thanks a lot.
Eros
Re: Maze Solver - Updated Version 06 Oct 07
Thanks to Maze Solver example I've also improved calling of API functions.
In your script I saw the following code:
Code:
function Draw_Grid() as long
dim col_count as dword
dim row_count as dword
dim x1,x2,y1,y2 as dword
dim pt as POINT_TYPE
SelectObject(hdc, GetStockObject(%BLACK_PEN) )
'x2 = gridRight
for row_count = 0 to astar_RowCount
x1 = gridLeft
y1 = gridTop + (row_count * cellHeight)
MoveToEx(hdc,x1,y1,pt)
y2 = y1
LineTo(hdc,gridRight,y2)
next
'y2 = gridBottom
for col_count = 0 to astar_ColumnCount
x1 = gridLeft + (col_count * cellWidth)
y1 = gridTop
MoveToEx(hdc,x1,y1,pt)
x2 = x1
LineTo(hdc,x2,gridBottom)
next
end function
Now, you defined "DIM pt as POINT_TYPE" only because "MoveToEx" need a POINT_TYPE structure. In other languages you can pass both a structure BYREF or a value representing the memory address where the structure is located. From next preview version this will be possible also in thinBasic, that is if parser will find a structure, its memory address will be passed otherwise if parser will find a numeric expression, the result of the numeric expression will be passed. In this way script can be
[code=thinbasic]
MoveToEx(hdc,x1,y1,%NULL) '---Here %NULL means no UDT is passed
[/code]
or
[code=thinbasic]
MoveToEx(hdc,x1,y1,0) '---Here 0 means no UDT is passed
[/code]
without the need to declare a structure.
Feature will be present in next thinBasic preview 1.4.0.1 release
Regards
Eros