| Main > Software Forum |
| Can Johnny5 do rotated text? |
| (1/2) > >> |
| Spartan:
...specifically for dual control panels on cocktail tables? |
| Howard_Casto:
Nope, not yet. |
| Spartan:
damn -- any plans for it? |
| Howard_Casto:
"Not yet" doesn't give you any clue? |
| headkaze:
Well, just for the "fun of it" I decided to dust out the old VB6 and try and write something that would rotate a form 90 degrees. From memory Johnny5 uses form controls like labels to draw the CP. To rotate a GDI+ created CP would be very easy using one line of code. To rotate the contents of a form with user controls it's a little more tricky. I'll paste my code here for demonstration purposes. It uses the very slow GetPixel() and SetPixel() methods as I think the Direct Memory Access routines written by BillSoo require a picture loaded using LoadPicture() but I could be wrong. Anyway, it may give you a starting point if you havn't tried it already. The form must have AutoRedraw set to false and ScaleMode set to 3 - Pixel... --- Code: ---Private Declare Function BitBlt Lib "gdi32" (ByVal hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long Private Declare Function SetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long Dim hDCSour As Long, hBMPSour As Long Dim hDCDest As Long, hBMPDest As Long Private Sub Form_Load() ' Show form and refresh form Me.Show Me.Refresh ' Create DC's for reading & writing the pixels hDCSour = CreateCompatibleDC(Me.hDC) hBMPSour = CreateCompatibleBitmap(Me.hDC, Me.ScaleWidth, Me.ScaleHeight) hDCDest = CreateCompatibleDC(Me.hDC) hBMPDest = CreateCompatibleBitmap(Me.hDC, Me.ScaleWidth, Me.ScaleHeight) SelectObject hDCSour, hBMPSour SelectObject hDCDest, hBMPDest ' BitBlt the form's pixels to the source DC BitBlt hDCSour, 0, 0, Me.ScaleWidth, Me.ScaleHeight, Me.hDC, 0, 0, vbSrcCopy ' Rotate the pixels using slow GetPixel() and SetPixel() For Y = 0 To Me.ScaleHeight - 1 For X = 0 To Me.ScaleWidth - 1 Dim Col As Long Col = GetPixel(hDCSour, X, Y) SetPixel hDCDest, Me.ScaleHeight - Y - 1, X, Col Next Next ' Remove form controls so they stop being painted Dim Control As Control For Each Control In Me Control.Visible = False Next Control ' Refresh form to call Form_Paint() Me.Refresh End Sub Private Sub Form_Paint() ' BitBlt the rotated form to the forms hDC BitBlt Me.hDC, 0, 0, Me.ScaleWidth, Me.ScaleHeight, hDCDest, 0, 0, vbSrcCopy End Sub Private Sub Form_Unload(Cancel As Integer) DeleteObject hBMPSour DeleteDC hDCSour DeleteObject hBMPDest DeleteDC hDCDest End Sub --- End code --- |
| Navigation |
| Message Index |
| Next page |