You are not logged in.

Mark

Beginner

  • "Mark" started this thread

Posts: 1

Date of registration: Dec 12th 2009

  • Send private message

1

Saturday, December 12th 2009, 12:56pm

(1) hDC for a picture box? (2) AddressOf? (3) App.Instance?

Hi,

I just downloaded Jabaco, and to try it out I started with converting a (relatively simple) program from VB6 (a small tool that was first written in VB3, and that I've been updating and whenever necessary).
I hit quite a lot of errors.

unimportant:
  • had to remove DefLNG (and declare all my variables as Long) -> is there a Jabaco equivalent for DefLNG, DefINT

things I couldn't solve
:
  • <picturebox>.hDC wasn't recognized. In VB6 (and lower) a picturebox has a handle to its own Device Context. In Jabaco a picturebox doesn't seem to have a DC?
I can't use API-functions like BitBlt and StretchBlt in a picturebox without a Device context. Is there another approach?
Anyway - I replaced <picturebox>.hDC with Jabaco's <picturebox>.ImageBuffer for now (would that work?) but I still can't test my program...

  • ... because the next error occured in my mousehook-module:

Source code

1
hHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, App.hInstance, 0)


The compiler stops at AddressOf MouseProc, saying it expects a closing bracket )
What am I doing wrong? Is AddressOf not supported?
  • also, App.Instance doesn't seem to be recognized anymore?


Thanks for any help you can give me.

  • "StefanSchnell" is male

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

2

Monday, December 28th 2009, 11:55am

Hello Mark,
welcome at Jabaco.

Your questions are not easy to answer, because they are very Windows specific and also the topic is very complicated. I will try to give you a DC answer:

The hDC of a PictureBox in VB is very easy to find out. VB create a PictureBox as a window with CreateWindowEx and the class ThunderPictureBox. So you can use the API functions GetDC and GetWindowDC. The device context is Windows specific, look here for further explanation. It is in Jabaco (Java) not the same. Java use an abstraction layer between his language - AWT - and the OS. So far, so good. I think one way is, if you want to use the block transfer functions of the GDI, to create your own PictureBox. Another (better) way is - for OS indenpendency -, to use equivalent Java functions. So far I know, Jabaco does not support DC, now it is necessary to help yourself. I do not know a solution.

I think you do nothing wrong. It is a difference to use VB or Java - in Jabaco disguise.

Your questions give an interesting perspective: Where is the frontier to convert VB projects with Jabaco to Java? Under which circumstances is a conversion still be worth? How many amd which Windows specific commands can be use until a conversion is to extensive and complex? What is an equivalent from a WinAPI command to a Java command?

I am so sorry that I cannot say more, but hope that helps a little.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

  • "StefanSchnell" is male

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

3

Tuesday, December 29th 2009, 6:58am

Hello Mark,
here is a small solution to get the hInstance and a little bit more:

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
'-Begin-----------------------------------------------------------------

  '-External functions--------------------------------------------------
    Private WinAPI Function GetWindowLong Lib "user32.dll" _
      Alias "GetWindowLongA" (ByVal hwnd As Long, _
      ByVal nIndex As Long) As Long

    Private WinAPI Function GetCurrentThreadId Lib "kernel32.dll" _
      () As Long
      
    Private WinAPI Function GetCurrentProcessId Lib "kernel32.dll" _
      () As Long
      
    Private WinAPI Function FindWindow Lib "user32.dll" _
      Alias "FindWindowA" (ByVal lpClassName As String, _
      ByVal lpWindowName As String) As Long

  '-Constants-----------------------------------------------------------
    Private Const GWL_HINSTANCE As Long = -6

  '-Function hInstance--------------------------------------------------
    Public Function hInstance() As Long
      Dim hWnd As Long
      If LCase(Left(java#lang#System.getProperty("os.name"), 3)) = "win" Then
        hWnd = FindWindow("SunAWTFrame", Form1.Caption)
        If hWnd Then
          hInstance = GetWindowLong(hWnd, GWL_HINSTANCE)
        Else
          hInstance = vbNull
        End If
      Else
        hInstance = vbNull  
      End If
    End Function
  
  '-Function ProcessID--------------------------------------------------
    Public Function ProcessID() As Long
      If LCase(Left(java#lang#System.getProperty("os.name"), 3)) = "win" Then
        ProcessID = GetCurrentProcessId()
      Else
        ProcessID = vbNull  
      End If  
    End Function    
  
  '-Function ThreadID---------------------------------------------------
    Public Function ThreadID() As Long
      If LCase(Left(java#lang#System.getProperty("os.name"), 3)) = "win" Then
        ThreadID = GetCurrentThreadId()
      Else
        ThreadID = vbNull  
      End If  
    End Function  
  
'-End-------------------------------------------------------------------


Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

jayess

Trainee

  • "jayess" is male

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

4

Thursday, February 18th 2010, 12:05am

Almost Bitblt

Hi guys,

These work quite well for me...

picDest.PaintPicture picSrc.Image,X1,Y2,OpCode

OR

picDest.PaintPicture picSrc.Image,X1,Y2,Width,Height,X2,Y2,Width2,Height2


This mimics Bitblt, and since its an built in 'function/method' in Jabaco, I would hope to assume its OS independent?

Thanks,
Jason

This post has been edited 1 times, last edit by "jayess" (Feb 18th 2010, 12:14am)


OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

5

Thursday, February 18th 2010, 10:06pm

Answers

Hi,

Quoted

* Where is the frontier to convert VB projects to Jabaco/Java?
* Under which circumstances is a conversion still be worth?
* How many and which Windows specific commands can be use until a conversion is to extensive and complex?
* What is an equivalent from a WinAPI command to a Java command?
excellent!
Is there really anybody that can answer this questions except oneself?
The answer could be short: we do not know until we try.

Another question that should be added:
What shifts the frontier?
The more needs you will have to make your program independent from the operating system the more you are willing to try it.
How many Operating systems do exist?
* MacOS-X
* Linux (SUSE, Ubuntu...)
* Windows (..., XP, Vista, 7)
(sorry for the short lists;)

And how many solutions do exist to create programs that dance on all the worlds?
JavaVM, Qt, .Net+Mono
These somewhat big frameworks give you a layer above the operating system.
More or less they are a kind of operating system themselves.

Quoted

The compiler stops at AddressOf MouseProc, saying it expects a closing bracket )
What am I doing wrong? Is AddressOf not supported?
It would be great to have AddressOf and it could be possible if the compiler would support it.

regards
OlimilO

Rate this thread
WoltLab Burning Board