Differences in my app between Windows and Mac


I am creating an app that will eventually run on Windows, but as I have a Mac I prefer to work on it on the Mac.

When I turn it over to Window 7 (which is running as a Parallels virtual disk) There are a couple of problems.

Even though on the Mac I marked labels and other controls to be transparent, in the Windows version I have to change that again - not a big deal, but annoying.

A similar thing happens with the position of some controls. They shift to different left-top co-ordinates.

But worst of all is the fact that I have a class whose super is Text Field. A TextChange event triggers the class. Here is its method:

if me.Text = Str(5) Then me.TextColor = RGB(239,109,5) ElseIf me.Text = Str(6) Then me.TextColor = RGB(255,0,0) End If if me.Text > Str(6) Then me.Text = "6" End If

On the Mac it works as it should. When the number reaches 5 it turns orange; when it reaches 6 it turns red and any further additions to that Text Field are ignored.

On Windows, the colour changes are complete ignored but it does stop getting additional numbers once it reaches six. I have watched the progress in the debugger, and it steps through all of the method’s code, it just doesn’t change colour?

What’s going on. I am not sure I can change the “me” because there are 14 text boxes which are a control set.

I guessed there might be a difference between str(5) and “5” … pretty sure I expected there to be a leading space with STR()

But both worked for me.
I note that you don’t change the text colour back if the number goes down…


if me.Text > "6" Then me.Text = "6" select case me.Text case "5" me.TextColor = RGB(239,109,5) case "6" me.TextColor = RGB(255,0,0) case else me.TextColor = RGB(0,0,0) end select

I can’t believe that I put your code in, and and still it didn’t change color. The funny thing is that once the numbers get to 6 they won’t increase. To clear up any confusion, this is part of a selection process and there are two rounds. In the first round each of 14 clubs is only allowed six selections (out of 363 possible candidates). Then in the second round, it is open slather and each club can apply for any class they wish.

The numbers don’t ever go down once the program is running.

try adding a me.refresh

And to make sure the object is the one you expect to be doing this, why not also temporarily add

me.left = val(me.text) * 20

that way you can see that the code is executing, and is affecting the control you expect it to?

No, don’t use refresh. Only in rare cases is refresh called for. If you ever think “I need to get the control to update” then you want the Invalidate method. If you need to do so before the end of the event loop (rare) then that is when you use refresh.

Your solution is simple: cast to numbers. Strings don’t compare that way. Use CDbl to convert to a double and compare using actual numbers.

Hi Thom

I changed my Method (just in the Windows version) to:

Dim checkNum As Double checkNum = Val(me.Text) if checkNum > 6 Then me.Text = "6" Select case checkNum case 5 me.TextColor = RGB(230,109,5) case 6 me.TextColor = rgb(255,0,0) case else me.TextColor = RGB(0,0,0( end Select

Another odd thing I have noticed is that in Xojo’s project I have set the color of the figures to green, and they show up as green in the project view. But when I run the program, they are black. I do have another text field (which is a real text field, not subclassed) in which the digits are blue, and they show as blue when the program runs.

Is there something I haven’t learnt about subclassing? Or, perhaps more likely, is there something about colour in Windows that I don’t understand?

Thanks to all for all the help up to now. It is so frustrating that it works on the Mac, but I am having trouble on Windows, where the program is destined for.

I have managed to fix the problem. I noticed when the value of the TextEdit subclass got to six, it didn’t increase further, so therefore, it recognised the value of the input, so therefore the problem had to be with the colour. I looked at the properties of the field and noticed it was set to read-only (which I actually want). I turned off read-only for all the 14 TextField subclasses, and they worked as expected. When the number in the individual field got to 5, it turned orange; and when it got to six it turned red, and then even when that club number was chosen, the field didn’t advance further.

So I guess my question now is “what does the read-only property have to do with this?” I really need those TextFields to be readonly (excepting I really don’t expect anyone to play with them). Any ideas?

Try return True in the KeyDown event handler to prevent changes in the field.

Hi Paul

That didn’t work, nothing happened. So I deleted the KeyDown event and now the whole thing doesn’t work :frowning:

Nevermind, I will debug it and find out where I did something wrong and fix it.

As an aside, is it usual that a program for Mac and for Windows may always have differences like this? (What I mean is this works on the Mac, but when I transferred the project file to Windows, I have had all these problems.)

[h]Very Sorry![/h] At the same time as setting KeyDown to True I made another change, and that mucked things up. Thanks to the debugger it is easy to find coding errors.

So thank you Paul, it is now working how I want.

I would still like to ask the question about differences between projects on a Mac and Windows. But actually, I am going to continue developing this on my Windows 7 Parallel’s partition. I only hope there is not going to be huge differences between Windows 7 and 8, as that actually is the target operating system.

Thanks again to all for the help. I’ve said it before, but this is a fantastic forum.

Sure, there are always some platform differences. For example, Xojo often uses native controls, which means that behaviors cannot match 100% across platforms.

Thanks Paul

This may be interesting, its not a Xojo thing:




It seems that changing the backcolor may ‘fix’ the forecolor change issue.

That is interesting. Great find Jeff. I have since implemented Paul’s solution using the KeyDown event, but I will keep this in mind for future projects.