Talking about coding and apparent bug(s)

Hi all

I was starting a brand new project (a simple data displayer from in a specific master folder in a window).

Things were going fine, looking nice on screen, no flickering, all went well…

Then, I needed to store a bit more data in the folders, more folders to hold data.

I continued to code stuff to display data.

Then a need for organization (instead of flat data display using a timer *) comes to light.

So I added a PopupMenu to place a ToC in my displayed window.

And then the troubles were starting.

Before adding the PopupMenu, my project was holding two windows and each window only had a Canvas where I put code in its Paint Event.
The first window displayed a Table of Contents (not clickable yet) while the second window display the data sequencially (now).

What was the problem ? The PopupMenu (PM) ListIndex property was always -1, the .Text property was always empty.

Quit, Shutdown, a nap, etc.

Sometimes later, I decided to create a brand new project to check if the PM works fine. It does.
Back in the project, I get an awful idea: what if it is because the Event where I put the code in ?
Yes, that is a good question. Where do I put the code in ?

The code, all the code in the window was located… in the Paint Event.

How can that be ? I started to put code there to set common graphics (graphics that will appears all the time (date, main title, etc.), then because everythingw ent OK, I continued to place code there (code to get Icons from each data folder, etc. in the same Event.

After an hour or two, my display windows (now two) are working fine… (with all code located in the Cavas’ Paint event).

And this is where the trouble with the PopupMenu lies !

I extracted the PopupMenu code (and the Code that reads in the folders for data) from the Paint Event and all is working fine: the bug was mine (and in fact, there was no bug at all, I just loose my point while codeing !).

Alays take some minutes in the development process to check you still are in the right tracks: it is so easy to forget something (like add more Events, Methods, Functions, Offscreen Pictures, etc.) while…
It’s so easy to get lost on a bike, with your head in the handlebar, pedaling to the finish line!

And the code ?
It was nice looking code, elegant, with comments, explanations, code against Nil and not .Exists, etc. :frowning:

The project is a very simple presentation application specialized on a single project. It is 70KB right now (no data).