News:

Masm32 SDK description, downloads and other helpful links

Main Menu

Capitals of Europe

Started by jj2007, September 25, 2020, 01:51:46 AM

Previous topic - Next topic

jj2007

New version attached above in the first post. It will grab the maps directly from the web:

GuiParas equ "Capitals of Europe", xr20, w1200, h600, m5, bLiteGrey, icon Globe ; right-align, width 1200px, margin 5px, grey background
; not needed: GuiMenu equ @File, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste ; creates a menu -> Event Menu
include \masm32\MasmBasic\Res\MbGui.asm ; OPT_Close Capitals of Europe ; close the window before building
.if !Exist("Capitals\euro5.dmi")
MsgBox 0, "Maps are missing. Ok to download them?", "Hi", MB_OKCANCEL
If_ eax==IDCANCEL Then Exit
UnzipInit "http://www.jj2007.eu/images/Capitals.zip" ; get the maps
For_ ecx=0 To edx-1 ; #files returned in edx
UnzipFile(ecx, Cat$(CurDir$()+"Capitals\")) ; extract to a new folder
Next
.endif
GuiControl TheImage, "canvas", w600 ; use the 3-letter shortcuts gcbutton, gcedit, gclistbox, gcrichedit, gcstatic to insert other controls, e.g typing gcb<space>
GuiControl TheMap, "canvas", x600, w400
GuiControl Sbar, "statusbar", wCat$(wDate$+", "+wTime$+" - click into the map")
ArrayLoadMap 0, "Capitals\euro5" ; *.dmi and *.map
MapColours(0, "gahebcdbfghgfgcdefghegaechfgaggfcdgfgceghaefabcdheg") ; set colours to map #0 (a=red, i=dark green, l=blue)
Recall "Capitals\Capitals.ini", pics$() ; info on jpg files

Event Message
  .if uMsg_==WM_MAPCLICKED && MapRegion>=0
SetWin$ hSbar=MapRegion$
invoke InvalidateRect, hTheImage, 0, 0 ; force image redraw
  .endif

Event CanvasPaint
  Switch_ ecx ; the canvas ID is in ecx
  Case_ TheImage
  .if MapRegion>=0
mov ecx, pics$(MapRegion) ; the image file, e.g. Capitals\00_Chisinau.jpg
GuiImage ecx, fit
void Extract$(ecx, "\", ".jpg") ; e.g. Capitals\Москва.jpg
GuiTextBox 100.0-114, 100.0-38, 110, auto, eax, bcol LiteGreen, font -20 ; lower right corner
.else
GuiTextBox 50.0-100, 50.0-80, 200, auto, "No country selected - click into the map", bcol LiteRed, font -40
.endif
  Case_ TheMap
ArrayPlot LiteBlue ; init and set background colour
PaintMap DarkGrey, lines=2 ; map with grey borders 2px thick
ArrayPlot exit, "Europe"
  Endsw_
GuiEnd


To build the source, use the latest MasmBasic version.

Vortex

Hi Jochen,

The second version works fine, thanks :thumbsup:

HSE

 :thumbsup:

A little problem with Zagreb.

Perhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on October 02, 2020, 10:53:29 PMA little problem with Zagreb.

Perhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.

Oops! Attached (and added to the online archive). You are right about the FileRead$ exceptions :thumbsup:

jj2007

Quote from: HSE on October 02, 2020, 10:53:29 PMPerhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.

This is fixed in the latest MasmBasic version:
include \masm32\MasmBasic\Res\MbGui.asm
Event Paint
  GuiImage "NoSuchImage.png", fit
GuiEnd


The solution costs a whopping 26 bytes of extra code and looks ugly, but it works :cool:

What exactly is the problem with FindOnDisk? Can you reproduce it? For me it works fine.

HSE

Quote from: jj2007 on October 03, 2020, 06:21:01 PM
What exactly is the problem with FindOnDisk? Can you reproduce it? For me it works fine.

If you miss something in "files to inclde in search" you have the exception

Trying to see if was solved:** Start D:\masm32\MasmBasic\Res\bldallRM.bat **
**** 32-bit assembly ****
OPT_Arg1: $ini=FindOnDisk.ini

*** Assemble, link and run FindOnDisk ***

*** Assemble using UASM32  ***
*** MasmBasic version 03.10.2020 ***
Tmp_File.asm(91) : Error A2102: Symbol not defined : dcRichEdit
DlgControl(41)[MasmBasic.inc]: Macro called from
  Tmp_File.asm(91): Main line code
Tmp_File.asm(91) : Error A2102: Symbol not defined : dcRichEdit
DlgControl(46)[MasmBasic.inc]: Macro called from
  Tmp_File.asm(91): Main line code
Tmp_File.asm(91) : Error A2102: Symbol not defined : dcRichEdit
DlgControl(87)[MasmBasic.inc]: Macro called from
  Tmp_File.asm(91): Main line code
Tmp_File.asm: 361 lines, 1 passes, 418 ms, 0 warnings, 3 errors
*** Assembly error ***
Equations in Assembly: SmplMath

jj2007

#21
Strange that you get assembler errors, here it works. Can you attach your source?

HSE

Hi JJ!

Perhaps you added some obsolete files in new installation. Setup ask for replacing files.

Binary was assembled with some previous MasmBasic version.

I think you don't have dcRichedit  :biggrin:  (well, I erased that)
Equations in Assembly: SmplMath

jj2007

Hi HSE,

Here is your modified source - search for changed (ini$, dcRichEdit, ...)

But I would strongly suggest to use the version in the second attachment.

There is also a bug in RichMasm: it adds °Bx bookmark tags when loading plain text files even if there is already a tag, so they accumulate with each save & reload. I never use plain text, so that little glitch evaded my attention. Will be fixed asap :cool:

jj2007

Version 3 of Capitals of Europe is attached to first post. No major changes, but
- the tooltips look nicer now, thanks to the XP manifest,
- they don't flicker any more (that is a genuine Windows bug),
- the names of Serbia and Russia are displayed in cyrillic to demonstrate that Unicode can be used