Mac to Windows

Is it normal that if you create an project on a Mac, it either doesn’t look right on Windows, or plain doesn’t work? I have completed two Projects in Xojo on the Mac now. The first had many problems with the UI when moved over to Windows 9, so I finished the project on a Windows VM partition on my Mac. (I do wonder if it is a problem that I am using Parallels to run Windows on my Mac?)

My second Project doesn’t work too well. I have a one column ListBox which contains years. When clicked there is a popup menu which contains months that are included in that year. By included I mean in the finished app, not every year will contain all the months. When I click on a month, the Title Bar of the window changes to reflect the selected month, but not the information on the screen.

I have to say that I am not a trained programmer. One reason I like Xojo is that it allows me to design the UI, and then, sometimes through trial and error, make it do what I want. I would be the first to admit that my code is probably terrible from an aesthetic and/or OOP stance, but it works, and is fast.

So, do I have to be more careful with my code to make it work on both Macs and Windows? My first project I had to practically rework it in my Windows environment to make it work properly on Windows 8. I am just thankful that the Xojo licence is available on two machines, in my case one Mac and one Windows.

I meant to say, I have tried both building the Windows App on the Mac, and also shifting the project over to Windows to be built there.

Regarding the “look”, this is the drawback of all development tools aiming at the “native platform GUI” paradigm.

Ultimately, when you start dealing with elaborated applications - not just a Window with a few buttons - then you basically end up reworking your GUI 3 times, that is, if you target Mac, Windows and Linux.

There are always little, painful differences - font size, padding here, padding there, different sizes, alignments, etc… that makes your GUI completely wrong on one platform after having carefully designed it on another one.

That’s why all major professional and cross-platform applications use non-native GUI in order to have a consistent look & feel across platforms and to reduce the workload of adjusting it on each one of them. (there are also other considerations, for instance “dark themes” are not only for aesthetics, they address power consumption issues that natives GUI seem to not care at all).

I realize I’m not helping much here, but my point is: the fact that your project - carefully crafted on Mac - does not look right on Windows is to be expected if you did not anticipated it. This is not a Xojo issue, this is just a cross-platform development one.

Now, the fact that it plain doesn’t work on Windows is another matter…

Thanks Guy

That’s half of my problems out of the way. I can understand that, and am prepared to deal with (in fact have done so in one of my projects).

I guess just plain doesn’t work was a little strong - typed in the heat of a disappointing moment. Generally it does work. It reads the database to get the first window set up and displaying correctly (except for the fact that I have to tweak the typesize of my text). But then, because the ListBox popup selection is not working, then that is all that the app displays. I should be able to select other months, and they will display their details on the window.

What do you mean by “the ListBox popup selection is not working”’ ?

You mean on both platforms when you click on a ListBox row a PopupMenu appears with a list of months, then when you hover with the Mouse the selection is changing in the list but when you click on one month, nothing happen on Windows while the rest works as expected on Mac ?

Yes that is precisely what is happening. On the Mac, when I click on one of the months in the popup it displays the data from that month (the data is the daily readings of a rain gauge).

If this month selection doesn’t work (which it doesn’t on Windows) then you can only view the current month’s readings as this data is populated by the application window’s Open Event.

Maybe it does not work well because Windows 9 is not to be released before 2015 ? Just joking :wink:

Thanks Michel,

It sure helps to have a sense of humour.

Guy,

I re-read your last post. The Window Title doesn’t change until you have clicked on a month in the popup. So, you click on a month, the Window Title changes, and that is all that happens.

That would mean your issue is not GUI related, as the event is received and, at least, you are able to change the Window Title from your code. Have you investigated what’s happening next, in your code, after having changed the Window Title ?

As you are dealing with a Database, are you checking for errors after your queries ?

Actually I’m not checking for errors, mostly because it is working on the Mac. I guess I will fire up Xojo on Windows and add some checks.

I am having a little trouble stepping through my code when it comes to the popup click. I go into the code editor after clicking on one of the months, and as I step through the code, I am back in the app, not in the code editor. I will have to try putting breakpoints in different areas of the code.

Thanks for your help, Guy.

I think I might have found the problem. On the Mac when I use ParseDate my date string is “01/03/2014” for the March 1, 2014.
When I run through the debugger on Windows, I get January 3, 2014. No error, because that is a valid date. In fact, no matter what date string I enter, I am sure it will be a valid date.

So what’s with Windows? Does it expect 03/01/2014 for the third of March? Is this a Preference in Windows Date and Time Control Panel (if there is such a thing)? If this is the case how am I to know what the unknown target machine is set up for.

Is there another way to ParseDate that will work on either platform?

Hmm… you mean you let the user enter a Date in plain text in a text input field or something ?

Never do that. ParseDate depends on the user locales settings. This means your application may not even work on a Mac OS X if a user has different locales than yours.

That’s why so much efforts are put in date pickers such as: https://forum.xojo.com/11102-xojo-calendar-time-picker-version-1-6

You should use something like that, or at least, display 3 text input fields each one specifically asking for either day, month or year.

This way you should be safe.

I don’t let the user key in any date. But as part of my app I want to find the day name of the first day of the month, so that I can set up the Labels below the canvas fields that display the data for each day. So, if the first day is a Monday and there are 28 days in the month, the control set of day names will be set up as: Mon Tue Wed Thu Fri Sat Sun Mon, etc, until the 28th day.

I get the first day of the month by knowing the month and year then on the Mac:

Dim firstDay As Boolean Dim d As New Date firstDay = ParseDate("1/"+Str(i)+"/"+Str(j), d) 'Get the first day of the current month
Where i is the month number and j is the year number.

I have never had anything to do with Date and Time on a Mac (my usual platform) I just thought that was the way it worked, because it was set up the way I use it. I have since had a look at the Date and Time in System Preferences and see that of course, it is set up for New Zealand.

So if I shouldn’t use ParseDate, how am I to get the day name of the first of a selected month and year? There must be a way to do this that is foolproof no matter what machine or where in the world your app is working.

I would really appreciate any help on this.

Why don’t you bypass ‘ParseDate’ completely and do:

Dim d As New Date d.Year = j d.Month = i d.Day = 1 firstDay = d.DayOfWeek

BTW, firstDay shouldn’t be a Boolean, but an Integer, but I guess it’s just a typo thing here.

Thanks Guy

That is exactly what I will do.

The following is from the Language Reference:

[code]Dim theDate as New Date
Dim converted as Boolean

// Attempt to convert the string “12/31/2013” to a date. If
// the conversion succeeds, theDate variable contains the converted date.
converted = ParseDate(“12/31/2013”, theDate)[/code]

Thanks for all your patience and your help. Now I am sure my app will work on both Windows and Macintosh. I am about to change every ParseDate code I have

Your welcome Cliff.

So the problem was not a Mac/Windows issue, but a Locales setting issue that has nothing to do with the fact the app is running on Mac or on Windows. You should say: now my app will work on all platforms even if the Locales are not set to New Zealand :wink:

In fact it seems in New Zealand you have the same date standard as in UK or in France, that is dd/mm/yyyy while in US it’s mm/dd/yyyy.

What strange is why your Windows has US Locales instead of New Zealand one, albeit this allowed you to discover the issue.

I think that my Windows is using US Locales because it is running inside a Parallels VM, Parallels being a US company.

The only other “programming” I have been exposed to is using PHP for websites. I remember from that experience that Locales was a source of all sorts of frustration at times. Like so many things in this world, it is a pity that there is a more rigid setting of standards. Oh well, you are right in that the Locales setting on my Windows did allow me to find the problem.

Thanks again.

[quote=83136:@Guy Rabiller]Hmm… you mean you let the user enter a Date in plain text in a text input field or something ?
Never do that.[/quote]
Sometimes you have to, for example in accounting software, where people would be to slow entering dates by clicking around with the mouse.

[quote=83139:@Guy Rabiller]Why don’t you bypass ‘ParseDate’ completely and do:

Dim d As New Date
d.Year = j
d.Month = i
d.Day = 1
firstDay = d.DayOfWeek[/quote]

Why not use the constructor?

Dim d As New Date(theYear, theMonth, 1) ...

In this case you have to enforce the user to enter the date in a specific format (like yyyy/mm/dd) and do the parsing/checking yourself. Or use 3 separated text input fields. But relying on ParseDate is a big risk of getting in a lot of troubles.

[quote=83152:@Eli Ott]Why not use the constructor?

Dim d As New Date(theYear, theMonth, 1) ...[/quote]
Indeed.

[quote=83146:@Cliff Strange]I think that my Windows is using US Locales because it is running inside a Parallels VM, Parallels being a US company.

The only other “programming” I have been exposed to is using PHP for websites. I remember from that experience that Locales was a source of all sorts of frustration at times. Like so many things in this world, it is a pity that there is a more rigid setting of standards. Oh well, you are right in that the Locales setting on my Windows did allow me to find the problem.

Thanks again.[/quote]

i use virtual box on my mac osx and i am able to set the regional setting to UK instead of US. if you didn’t make any changes, it will default to US.