Author Topic: Capitals of Europe  (Read 672 times)

jj2007

  • Member
  • *****
  • Posts: 10678
  • Assembler is fun ;-)
    • MasmBasic
Re: Capitals of Europe
« Reply #15 on: October 02, 2020, 07:59:30 PM »
New version attached above in the first post. It will grab the maps directly from the web:

Code: [Select]
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

  • Member
  • *****
  • Posts: 2385
Re: Capitals of Europe
« Reply #16 on: October 02, 2020, 08:50:13 PM »
Hi Jochen,

The second version works fine, thanks :thumbsup:

HSE

  • Member
  • *****
  • Posts: 1410
  • <AMD>< 7-32>
Re: Capitals of Europe
« Reply #17 on: October 02, 2020, 10:53:29 PM »
 :thumbsup:

A little problem with Zagreb.

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

jj2007

  • Member
  • *****
  • Posts: 10678
  • Assembler is fun ;-)
    • MasmBasic
Re: Capitals of Europe
« Reply #18 on: October 02, 2020, 11:11:43 PM »
A 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

  • Member
  • *****
  • Posts: 10678
  • Assembler is fun ;-)
    • MasmBasic
Re: Capitals of Europe
« Reply #19 on: October 03, 2020, 06:21:01 PM »
Perhaps you have to capture FileRead$ exceptions because is a problem also in FindOnDisk.

This is fixed in the latest MasmBasic version:
Code: [Select]
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

  • Member
  • *****
  • Posts: 1410
  • <AMD>< 7-32>
Re: Capitals of Europe
« Reply #20 on: October 04, 2020, 01:43:39 AM »
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:
Code: [Select]
** 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 ***

jj2007

  • Member
  • *****
  • Posts: 10678
  • Assembler is fun ;-)
    • MasmBasic
Re: Capitals of Europe
« Reply #21 on: October 04, 2020, 08:29:12 AM »
Strange that you get assembler errors, here it works. Can you attach your source?
« Last Edit: October 04, 2020, 02:03:41 PM by jj2007 »

HSE

  • Member
  • *****
  • Posts: 1410
  • <AMD>< 7-32>
Re: Capitals of Europe
« Reply #22 on: October 04, 2020, 09:45:19 AM »
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)

jj2007

  • Member
  • *****
  • Posts: 10678
  • Assembler is fun ;-)
    • MasmBasic
Re: Capitals of Europe
« Reply #23 on: October 04, 2020, 02:03:22 PM »
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

  • Member
  • *****
  • Posts: 10678
  • Assembler is fun ;-)
    • MasmBasic
Re: Capitals of Europe
« Reply #24 on: October 11, 2020, 09:55:55 PM »
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