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.

turkulainen

Beginner

  • "turkulainen" is male
  • "turkulainen" started this thread

Posts: 20

Date of registration: Jun 30th 2009

Location: Turku, Finland

Occupation: engineer

  • Send private message

1

Sunday, August 2nd 2009, 5:18pm

Colours not working with Line?

I tried Form1.Line (x1,y1,x2,y2,0,RGB(255,0,0) but it draws in black. Some day I will have to draw several lines or curves for plots, and colours will be essential then. Is there a simple way to convert from twips to pixels, which I think Jabaco uses?

amitmarkel

Beginner

  • "amitmarkel" is male

Posts: 17

Date of registration: Jul 17th 2009

  • Send private message

2

Sunday, August 2nd 2009, 6:26pm

Hi,
I tried to Line() also, and I managed to change the colour by using the control's ForeColor property.

Regards,

Amit

  • "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

Sunday, August 2nd 2009, 8:51pm

Twips per Pixel

Hello turkulainen,
here are two functions to get pixel per twips to convert pixel to twips (multiply) and vis-a-vis (divide).

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
'-Begin------------------------------------------------------------------
  '-External Functions---------------------------------------------------
    Private WinAPI Function GetDC Lib "user32.dll" _
      (ByVal hwnd As Long) As Long
    Private WinAPI Function ReleaseDC Lib "user32.dll" _
      (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private WinAPI Function GetDeviceCaps Lib "gdi32.dll" _
      (ByVal hdc As Long, ByVal nIndex As Long) As Long
  '-Constants------------------------------------------------------------
    Private Const HWND_DESKTOP As Long = 0
    Private Const LOGPIXELSX As Long = 88
    Private Const LOGPIXELSY As Long = 90
  '-TwipsPerPixelX-------------------------------------------------------
    Private Function TwipsPerPixelX() As Float
      Dim hDC As Long
      Dim Result As Float
      hDC = GetDC(HWND_DESKTOP)
      Result = 1440 / GetDeviceCaps(hDC, LOGPIXELSX)
      ReleaseDC(HWND_DESKTOP, hDC)
      TwipsPerPixelX = Result
    End Function  
  '-TwipsPerPixelY-------------------------------------------------------
    Private Function TwipsPerPixelY() As Float
      Dim hDC As Long
      Dim Result As Float
      hDC = GetDC(HWND_DESKTOP)
      Result = 1440 / GetDeviceCaps(hDC, LOGPIXELSY)
      ReleaseDC(HWND_DESKTOP, hDC)
      TwipsPerPixelY = Result
    End Function  
  '-Main-----------------------------------------------------------------
    Public Sub Command1_Click()
      Debug.Print CStr(TwipsPerPixelX() & " " & TwipsPerPixelY())
    End Sub
'-End--------------------------------------------------------------------


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

Rate this thread
WoltLab Burning Board