You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Smily

Beginner

  • "Smily" started this thread

Posts: 1

Date of registration: Jan 31st 2013

  • Send private message

1

Thursday, January 31st 2013, 7:19pm

SendMessage

Hallo Community,
ich bin ein Newbie in Sachen Jacobo (Java), habe bisher mit VB6 und VBA gearbeitet.
Habe ein bisschen mit Jabaco probiert und finde es einfach Klasse!
Jetzt bin ich am überlegen, ob ich mein nächstes Project mit Jabaco ertelle, bin mir aber noch nicht ganz im Klaren, wie die eine oder andere Hürde zu nehmen ist.
In meinen entwickelten Vb6-Projecten sind u.a. zahlreiche API's vorhanden und ich weiss nicht, wie das in Jacobo umzusetzen ist, oder ob eine neue Entwicklung dieser Routinen vorzuziehen ist? Habe etwas in diesem Forum zu NativeCall gelesen, aber dann bin ich wieder von Windows abhängig und das ist nicht gerade Plattformunabhängig?
Da ich mich noch nicht mit Java beschäftigt habe, ist es schwierig und zeitintensiv für mich die entsprechenden Bibliotheken zu finden, bzw. richtig zu laden.
Mein nächstes Project soll eine umfangreiche Datenbank-Anwendung werden, Jetzt die Frage, ob ins kalte Wasser springen oder nicht? Beim Kunden solls später ja auch ohne Probleme laufen, ohne lang herumzuwursteln. Auf der anderen Seite reizt die unabhängigkeit von Windows und teilweise einfachere Handhabung.
Wie würde man z.B. am besten das nachfolgende VB6 Beispiel in Jacobo umsetzen?

Grüße
Smily

Source code

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
                                 	ByVal hwnd As Long, _
                                 	ByVal wMsg As Long, _
                                 	ByVal wParam As Long, _
                                 	ByVal lParam As Any) _
                                 	As Long

Const WM_VSCROLL = &H115

Const SB_LINEUP = 0
Const SB_LINEDOWN = 1
Const SB_PAGEUP = 2
Const SB_PAGEDOWN = 3
Const SB_TOP = 6
Const SB_BOTTOM = 7

Private Sub Command1_Click()

	Dim i       	As Long
	'If Index = 0 Then
	For i = List1.ListCount To List1.ListCount + 14
    	List1.AddItem "neuer eintrag " & i
	Next i
	'End If

End Sub

Private Sub Command2_Click(Index As Integer)

	If Index = 0 Then
    	SendMessage List1.hwnd, WM_VSCROLL, SB_BOTTOM, 0&
	ElseIf Index = 1 Then
    	SendMessage List1.hwnd, WM_VSCROLL, SB_TOP, 0&
	ElseIf Index = 2 Then
    	SendMessage List1.hwnd, WM_VSCROLL, SB_PAGEUP, 0&
	ElseIf Index = 3 Then
    	SendMessage List1.hwnd, WM_VSCROLL, SB_PAGEDOWN, 0&
	ElseIf Index = 4 Then
    	SendMessage List1.hwnd, WM_VSCROLL, SB_LINEUP, 0&
	ElseIf Index = 5 Then
    	SendMessage List1.hwnd, WM_VSCROLL, SB_LINEDOWN, 0&
	End If

End Sub

Private Sub Form_Load()

	Command1.Caption = "neue Einträge hinzufügen"
	Command2(0).Caption = "Ende"
	Command2(1).Caption = "Anfang"
	Command2(2).Caption = "PageUp"
	Command2(3).Caption = "PageDown"
	Command2(4).Caption = "LineUp"
	Command2(5).Caption = "LineDown"

End Sub

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

2

Friday, February 1st 2013, 2:55am

Hallo Smily, willkommen im Forum.
Hat es einen Grund, weshalb Dein Nickname ohne "e" geschrieben wird? :)

Ich mag Dein Beispiel.
Ich kenne mich nicht so gut mit VB6 und der Windows API aus. Daher finde ich Dein Programm doch sehr integressant. :)

Vor allem habe ich bisher nicht gewußt, daß man von den Controls ein Array erstellen kann und auch in den Funktionen den Array-Index verwenden kann ("Private Sub Command2_Click(Index As Integer)"). Wußte gar nicht, daß auch Jabaco soetwas unterstützt.


In Jabaco/Java wird viel mit einem ViewPort gearbeitet. Da sieht das Beispiel nicht ganz so einfach aus,

Hier eine Portierung auf Jabaco:

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Option Explicit

Private Sub Command1_Click()

	Dim i       	As Long
	'If Index = 0 Then
	For i = List1.ListCount To List1.ListCount + 14
    	List1.AddItem "neuer eintrag " & i
	Next i
	'End If

End Sub

Private Sub Command2_Click(Index As Integer)

 Dim vp As javax#swing#JViewport = List1.getViewport
 Dim CellHeight As Integer
 Dim MaxYPos = vp.getViewSize.getHeight-vp.getViewRect.getHeight

  If Index = 0 Then
    'List1.ListIndex = List1.ListCount-1
    vp.setViewPosition(New Point(0,MaxYPos))
  ElseIf Index = 1 Then
    'List1.ListIndex = 0
    vp.setViewPosition(New Point(0,0))
  ElseIf Index = 2 Then
    If vp.getViewPosition.y-vp.getViewRect.getHeight > 0 Then
      vp.setViewPosition(New Point(0,(vp.getViewPosition.y-vp.getViewRect.getHeight)))
    Else
      vp.setViewPosition(New Point(0,0))
    End If
  ElseIf Index = 3 Then
    If vp.getViewPosition.y-vp.getViewRect.getHeight < MaxYPos Then
      vp.setViewPosition(New Point(0,(vp.getViewPosition.y+vp.getViewRect.getHeight)))
    Else
      vp.setViewPosition(New Point(0,MaxYPos))
    End If
  ElseIf Index = 4 Then
    If vp.getViewSize.getHeight > vp.getViewRect.getHeight Then
      CellHeight = vp.getViewSize.getHeight / List1.ListCount
      If vp.getViewPosition.y-CellHeight > 0 Then
        vp.setViewPosition(New Point(0,(vp.getViewPosition.y-CellHeight)))
      Else
        vp.setViewPosition(New Point(0,0))
      End If
    End If
  ElseIf Index = 5 Then
    If vp.getViewSize.getHeight > vp.getViewRect.getHeight Then
      CellHeight = vp.getViewSize.getHeight / List1.ListCount
      If vp.getViewPosition.y-CellHeight < MaxYPos Then
        vp.setViewPosition(New Point(0,(vp.getViewPosition.y+CellHeight)))
      Else
        vp.setViewPosition(New Point(0,MaxYPos))
      End If
    End If
  End If

  List1.setViewport(vp)

End Sub

Private Sub Form_Load()

	Command1.Caption = "neue Einträge hinzufügen"
	Command2(0).Caption = "Ende"
	Command2(1).Caption = "Anfang"
	Command2(2).Caption = "PageUp"
	Command2(3).Caption = "PageDown"
	Command2(4).Caption = "LineUp"
	Command2(5).Caption = "LineDown"

End Sub


Aber Du wirst ja wohl nicht nur solche Programme haben, die die Windows-API verwenden, oder?

Btw: Hier das einzige mir bekannte Programm hier im Forum, das ohne zusätzliche externe Bibliotheken von der Windows-API Gebrauch macht:
[ http://www.jabaco.org/board/p416-eigenes…ln.html#post416 ]

Grüße
theuserbl

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

3

Friday, February 1st 2013, 10:58am

Hey there,

here is another approach

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
Public Sub Command1_Click(Index As Integer)
   Select Case Index
      Case 0
      'move first
         List1.Parent.getSelectionModel().setSelectionInterval(0, 0)
         List1.ensureIndexIsVisible(0)
      Case 1       
      'first visible
         List1.Parent.getSelectionModel().setSelectionInterval(0, List1.getFirstVisibleIndex)
         List1.ensureIndexIsVisible(List1.getFirstVisibleIndex) 
      Case 2            
      'move previous
         If List1.Selected(0) Then Exit Sub
         List1.Parent.getSelectionModel().setSelectionInterval(0, List1.ListIndex - 1)
         List1.ensureIndexIsVisible(List1.ListIndex - 1)
      Case 3
      'move next
         If List1.Selected(List1.ListCount - 1) Then Exit Sub
         List1.Parent.getSelectionModel().setSelectionInterval(0, List1.ListIndex + 1)
         List1.ensureIndexIsVisible(List1.ListIndex + 1)
      Case 4
      'last visible
         List1.Parent.getSelectionModel().setSelectionInterval(0, List1.Parent.getLastVisibleIndex)
         List1.ensureIndexIsVisible(List1.Parent.getLastVisibleIndex)
      Case 5
      'move last
         List1.Parent.getSelectionModel().setSelectionInterval(0, List1.ListCount - 1)
         List1.ensureIndexIsVisible(List1.ListCount - 1)
   End Select
End Sub


EDIT:
Oh,is ja auf Deutsch hier ... also, hier ein etwas simplerer Ansatz ... :D

Dani

This post has been edited 2 times, last edit by "Dani" (Feb 1st 2013, 11:14am)


Rate this thread
WoltLab Burning Board