You are not logged in.

Tegwin15

Beginner

  • "Tegwin15" started this thread

Posts: 6

Date of registration: Dec 10th 2013

  • Send private message

1

Tuesday, December 10th 2013, 8:59am

Detect Operating System

Hello
I am new to Jabaco.. What I am looking for is something to detect OS and do something based on that

ie if using Mac OSX then make the backround blue or if Windows make the Buttons larger.. Etc ..

is there an easy way to so this and how ?

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

2

Tuesday, December 10th 2013, 10:20am

Hey there,

Jabaco Source

1
2
3
Public Sub Form_Load()
   Debug.Print System.getProperty("os.name")
End Sub


...should do!

Dani

Tegwin15

Beginner

  • "Tegwin15" started this thread

Posts: 6

Date of registration: Dec 10th 2013

  • Send private message

3

Tuesday, December 10th 2013, 6:03pm

Thanks for this.
I have tried this
"Label1.Caption = System.getProperty("os.name")

If Label1.Caption =
"Windows 7" Then

Command1.Height = 400
Command1.Width = 100"



End If

is this the correct way to do it, or is there a better way. Essentially I want the button (or anything else) changed based on OS.
Also there seems to be a lack of documentation, anyone know where I can get some from .

Tegwin15

Beginner

  • "Tegwin15" started this thread

Posts: 6

Date of registration: Dec 10th 2013

  • Send private message

4

Wednesday, December 11th 2013, 10:41pm

Anyone have any ideas on this ?

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

5

Wednesday, December 11th 2013, 11:25pm

Hey there,

what exactly are you looking for?

You can find more about detecting the OS here:
http://www.mkyong.com/java/how-to-detect…propertyosname/

If you are looking for documentation, use this website and its search ability.
Have a look at the various code-samples in this forum.

Understand that programming with Jabaco you are addressing Java through a VB dialect; therefore searching the web, e.g. sun.com, stackoverflow.com, will help with most of your issues behind the scenes of Jabaco.
And after all there is still MS with documentation on VB6:
http://msdn.microsoft.com/en-us/library/…28VS.60%29.aspx

I can highly recomment studying the Jabaco Framework itself:
https://code.google.com/p/jabacoframewor…ramework/src/VB


Dani

Tegwin15

Beginner

  • "Tegwin15" started this thread

Posts: 6

Date of registration: Dec 10th 2013

  • Send private message

6

Thursday, December 12th 2013, 4:57pm

Yes I saw that article thank you but the syntax is very different.. I need the syntax for VB not Java

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

7

Friday, December 13th 2013, 1:57am

Yes I saw that article thank you but the syntax is very different.. I need the syntax for VB not Java


Here is a port of the program, to which Dani linked to:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Private OS As String = LCase(System.getProperty("os.name"))

Public Sub Command1_Click()
  Dim s As String
  
  s = OS + vbNewLine

  If isWindows() Then
    s = s + "This is Windows"
  Elseif isMac() Then
    s = s + "This is Mac"
  Elseif isUnix() Then
    s = s + "This is Unix or Linux"
  Elseif isSolaris() Then
    s = s + "This is Solaris"
  Else
    s = s + "Your OS is not support!!"
  End If
  
  MsgBox s
End Sub

Public Function isWindows() As Boolean
  isWindows = False
  If InStr(OS, "win")>= 1 Then isWindows = True
End Function


Public Function isMac() As Boolean
  isMac = False
  If InStr(OS, "mac")>= 1 Then isMac = True
End Function

Public Function isUnix() As Boolean
  isUnix = False
  If InStr(OS, "nix")>= 1 OR InStr(OS, "nux")>= 1 Or InStr(OS, "aix")>= 1  Then isUnix = True
End Function

Public Function isSolaris() As Boolean
  isSolaris = False
  If InStr(OS, "sunos")>= 1 Then isSolaris = True
End Function


But it is strogly recommend to make no difference between the systems in case of the size of the controls.

Depending of the Java LookAndFeel, the used Look and Feel of the native system and the installed fonts, the fonts on the controls needs more or less space on each platform.
The same is with the colors. If the native LookAndFeel changed, other colors are needed.

For example: For the colors you can use the default colors of the current Java-LookAndFeel (which can differ to the colors Jabaco used).

Here an example:

Jabaco Source

1
2
3
4
5
Public Sub Command1_Click()
   Dim b As New javax#swing#JButton()
   Command1.BackColor = ColorToRGB(b.getBackground)
   Me.BackColor = ColorToRGB(b.getBackground)
End Sub



Greatings
theuserbl

This post has been edited 2 times, last edit by "theuserbl" (Dec 13th 2013, 2:11am)


Rate this thread
WoltLab Burning Board