i wnana create an app which can post the text of text1.text in mig33 minibolg(www.mig33.com)
how? help me
how? help me
Private Sub cmdPrint_Click()
'Print the StdPicture Pic centered on the selected rrinter (Pr)
'with the selected paper (lstPapers) at the selected quality
'(lngResolutions) within set margins.
Dim MarginsLR As Single
Dim MarginsTB As Single
Dim PrintableWidth As Single
Dim PrintableHeight As Single
Dim ScaleFactor As Double
Dim ScaledWidth As Double
Dim ScaledHeight As Double
Set Printer = Pr
With Printer
'Set up paper:
.PaperSize = intPaperIds(lstPapers.ListIndex)
.PrintQuality = lngResolutions(2 * lstResolutions.ListIndex) 'We can only set one
'value DPI value, just
'use X here.
If optOrientation(1).Value Then
.Orientation = vbPRORLandscape
Else
.Orientation = vbPRORPortrait
End If
'Scale to paper, using 0.5" margins all around. Could also crop
'the image here:
MarginsLR = .ScaleX(0.5, vbInches, .ScaleMode)
MarginsTB = .ScaleY(0.5, vbInches, .ScaleMode)
PrintableWidth = .Width - 2 * MarginsLR
PrintableHeight = .Height - 2 * MarginsTB
ScaleFactor = PrintableWidth / .ScaleX(Pic.Width, vbHimetric, .ScaleMode)
If ScaleFactor * .ScaleY(Pic.Height, vbHimetric, .ScaleMode) > PrintableHeight Then
ScaleFactor = PrintableHeight / .ScaleY(Pic.Height, vbHimetric, .ScaleMode)
End If
ScaledWidth = ScaleFactor * .ScaleX(Pic.Width, vbHimetric, .ScaleMode)
ScaledHeight = ScaleFactor * .ScaleY(Pic.Height, vbHimetric, .ScaleMode)
'Paint (print) the image, scaled. Could also do the actual cropping
'here if any were desired by specifying additional arguments:
.PaintPicture Pic, _
(.Width - ScaledWidth) / 2, _
(.Height - ScaledHeight) / 2, _
ScaledWidth, _
ScaledHeight
.NewPage
.EndDoc
End With
End Sub
Public Sub OpenDbDefineCommands(ByVal NewDb As Boolean)
Set conDB = New ADODB.Connection
conDB.Open strConn
If NewDb Then
Set cmndInsert = New ADODB.Command
With cmndInsert
.Name = "InsertPic"
.CommandType = adCmdText
.CommandText = "INSERT INTO [PicTable] " _
& "([Description], [Picture]) " _
& "VALUES (?, ?)"
.Parameters.Append .CreateParameter(, adVarWChar, adParamInput, 255)
.Parameters.Append .CreateParameter(, adLongVarBinary, adParamInput, MAX_PHOTO_BYTES)
.Prepared = True
Set .ActiveConnection = conDB
End With
End If
Set cmndUpdate = New ADODB.Command
With cmndUpdate
.Name = "UpdatePic"
.CommandType = adCmdText
.CommandText = "UPDATE [PicTable] " _
& "SET [Picture] = ? " _
& "WHERE [ID] = ?"
.Parameters.Append .CreateParameter(, adLongVarBinary, adParamInput, MAX_PHOTO_BYTES)
.Parameters.Append .CreateParameter(, adInteger, adParamInput)
.Prepared = True
Set .ActiveConnection = conDB
End With
End Sub
Public Function UpdatePic(ByVal PicFileName As String, ByVal ID As Long) As Boolean
'Returns True if the operation fails.
On Error Resume Next
conDB.UpdatePic LoadPicBlob(PicFileName), ID
If Err Then
conDB.Errors.Clear
Err.Clear
UpdatePic = True
End If
End Function
Private Function LoadPicBlob(ByVal PicFileName As String) As Byte()
Dim PicFile As Integer
Dim PicBlob() As Byte
PicFile = FreeFile(0)
Open PHOTOS_FOLDER & PicFileName For Binary Access Read As #PicFile
ReDim PicBlob(LOF(PicFile) - 1)
Get #PicFile, , PicBlob
Close #PicFile
LoadPicBlob = PicBlob
End Function
'needs a reference to the free vbRichClient5-lib, which is located and available on:
'http://www.vbRichClient.com/#/en/Downloads.htm
Option Explicit
Private Srf As cCairoSurface, NumPoints As Single
Private pntX() As Single, pntY() As Single, sgnX() As Single, sgnY() As Single
Private WithEvents tmrRefresh As cTimer
Private Sub Form_Load()
Dim i As Long
' Rnd -1 'uncomment, if you want to always start from the same "randomness"
Me.ScaleMode = vbPixels
Me.Caption = "Left-Click for Start/Stop, Right-Click to clear"
NumPoints = 7
ReDim pntX(1 To NumPoints): ReDim pntY(1 To NumPoints)
ReDim sgnX(1 To NumPoints): ReDim sgnY(1 To NumPoints)
For i = 1 To NumPoints
pntX(i) = ScaleWidth * Rnd
pntY(i) = ScaleHeight * Rnd
sgnX(i) = IIf(i Mod 2, 1, -1)
sgnY(i) = IIf(i Mod 2, -1, 1)
Next i
Set tmrRefresh = New_c.Timer(10, True)
End Sub
Private Sub Form_DblClick()
tmrRefresh.Enabled = Not tmrRefresh.Enabled
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then tmrRefresh.Enabled = Not tmrRefresh.Enabled
If Button = 2 Then Set Srf = Cairo.CreateSurface(ScaleWidth, ScaleHeight) 'reset the surface
End Sub
Private Sub Form_Resize()
Set Srf = Cairo.CreateSurface(ScaleWidth, ScaleHeight)
End Sub
Private Sub Form_Terminate()
If Forms.Count = 0 Then New_c.CleanupRichClientDll
End Sub
Private Sub tmrRefresh_Timer()
Dim i As Integer, cc As Long
For cc = 1 To 100 'just to perform some more operations within a single timer-event
For i = 1 To NumPoints 'the next two lines influence the erratic point-movement (just play around)
pntX(i) = pntX(i) + sgnX(i) * 0.0004 * Abs(pntY(i) - pntX(i))
pntY(i) = pntY(i) + sgnY(i) * 0.1 / Abs((33 - pntY(i)) / (77 + pntX(i)))
If pntX(i) < ScaleLeft Then pntX(i) = ScaleLeft: sgnX(i) = 1
If pntX(i) > ScaleLeft + ScaleWidth Then pntX(i) = ScaleLeft + ScaleWidth: sgnX(i) = -1
If pntY(i) < ScaleTop Then pntY(i) = ScaleTop: sgnY(i) = 1
If pntY(i) > ScaleHeight + ScaleTop Then pntY(i) = ScaleHeight + ScaleTop: sgnY(i) = -1
Next i
Static j As Long, k As Single
k = k + 0.34: If k > 255 Then k = 0: j = j + 1: If j > 5 Then j = 0
Select Case j
Case 0: draw RGB(k, 255 - k, 255)
Case 1: draw RGB(255, k, 255 - k)
Case 2: draw RGB(255 - k, 255, k)
Case 3: draw RGB(0, 255 - k, k)
Case 4: draw RGB(0, 0, 255 - k)
Case 5: draw RGB(255 - k, k, 0)
End Select
If cc Mod 10 = 0 Then Srf.DrawToDC hDC
Next cc
End Sub
Private Sub draw(ByVal Color As Long)
Dim i As Long, PolyArr() As Single
ReDim PolyArr(0 To (NumPoints + 3) * 2 - 1)
For i = 0 To NumPoints - 1 'this is just a normal copy-over
PolyArr(2 * i) = pntX(i + 1) 'the dst-array has x at even indexes...
PolyArr(2 * i + 1) = pntY(i + 1) 'and the y-coord at the uneven ones
Next i
For i = 0 To 2 'now we add 3 additional points, to "close the circle" (so to say)
PolyArr(2 * (NumPoints + i)) = PolyArr(2 * i) 'those extra-points are copies ...
PolyArr(2 * (NumPoints + i) + 1) = PolyArr(2 * i + 1) '...of the first 3 points
Next i
With Srf.CreateContext 'once we have filled our PolyArr, the rest is pretty simple
.SetSourceColor Color, 0.05
.SetLineWidth 0.5
.PolygonSingle PolyArr, False, splNormal '... using the powerful Poly-call
.Stroke
End With
End Sub
Option Explicit
Private WithEvents W As cWidgetBase, WithEvents tmrTick As cTimer
Private ClockSrf As cCairoSurface
Private PatHour As cCairoPattern, PatMinute As cCairoPattern, PatSecond As cCairoPattern
Private Sub Class_Initialize()
Set W = Cairo.WidgetBase '<- this is required in each cwImplementation...
W.Moveable = True
Set tmrTick = New_c.Timer(490, True)
End Sub
Public Property Get Widget() As cWidgetBase
Set Widget = W
End Property
Public Property Get Widgets() As cWidgets
Set Widgets = W.Widgets
End Property
Private Sub tmrTick_Timer()
W.Refresh
End Sub
Private Sub W_Paint(CC As vbRichClient5.cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)
Dim CCclk As cCairoContext, D As Date
If Not Cairo.ImageList.Exists(W.ImageKey) Then Exit Sub
W.ToolTip = W.Key & vbCrLf & "You can drag me around..."
If ClockSrf Is Nothing Then InitClockSurfaceAndClockHandPatterns
Set CCclk = ClockSrf.CreateContext
CCclk.Operator = CAIRO_OPERATOR_SOURCE
CCclk.RenderSurfaceContent W.ImageKey, 0, 0 'clear the last contents with a fresh copy from the Imagelist-Key
CCclk.Operator = CAIRO_OPERATOR_OVER
CCclk.TranslateDrawings ClockSrf.Width / 2, ClockSrf.Height / 2 'shift the coord-system from the TopLeft-Default to the center
D = Now()
DrawPat CCclk, PatHour, ((Hour(D) Mod 12) + Minute(D) / 60) * 5 * 6, 1.5
DrawPat CCclk, PatMinute, (Minute(D) + Second(D) / 60) * 6, 2.75
DrawPat CCclk, PatSecond, Second(D) * 6, 3.75
With Cairo.CreateRadialPattern(0, 0, 7, 2.2, -2.2, 0)
.AddGaussianStops_TwoColors &HAA, vbWhite, , 0.6
CCclk.ARC 0, 0, 7
CCclk.Fill , .This
End With
CC.RenderSurfaceContent ClockSrf, 0, 0, dx_Aligned, dy_Aligned, , W.Alpha
End Sub
Private Sub InitClockSurfaceAndClockHandPatterns()
Set ClockSrf = Cairo.ImageList(W.ImageKey).CreateSimilar(CAIRO_CONTENT_COLOR_ALPHA)
Set PatHour = Cairo.CreateSurfacePattern(Cairo.CreateSurface(15, ClockSrf.Height))
DrawLineHands PatHour.Surface.CreateContext, ClockSrf.Height, vbBlack, 9, 0.066, 0.22
Set PatMinute = Cairo.CreateSurfacePattern(Cairo.CreateSurface(15, ClockSrf.Height))
DrawLineHands PatMinute.Surface.CreateContext, ClockSrf.Height, vbBlack, 6, 0.1, 0.29
Set PatSecond = Cairo.CreateSurfacePattern(Cairo.CreateSurface(15, ClockSrf.Height))
DrawLineHands PatSecond.Surface.CreateContext, ClockSrf.Height, &HAA, 2, 0.044, 0.34
DrawLineHands PatSecond.Surface.CreateContext, ClockSrf.Height, &HAA, 4, 0.044, -0.17
End Sub
Private Sub DrawLineHands(CC As cCairoContext, SrfHeight, Color, LineWidth, DownFac, TopFac)
CC.TranslateDrawings CC.Surface.Width / 2, SrfHeight / 2
CC.DrawLine 0, SrfHeight * DownFac, 0, -SrfHeight * TopFac, , LineWidth + 2, Color, W.Alpha * 0.33 'a thin outer-border with more alpha
CC.DrawLine 0, SrfHeight * DownFac, 0, -SrfHeight * TopFac, , LineWidth, Color, W.Alpha
End Sub
Private Sub DrawPat(CC As cCairoContext, Pat As cCairoPattern, ByVal Deg As Double, Optional ByVal ShadowOffs As Single)
Dim M As cCairoMatrix
Set M = Cairo.CreateIdentityMatrix
M.TranslateCoords Pat.Surface.Width / 2, Pat.Surface.Height / 2
M.RotateCoordsDeg -Deg
Set Pat.Matrix = M 'we do not rotate the Coord-System of the CC, but instead we rotate that of the pattern
If ShadowOffs Then
CC.Save
CC.TranslateDrawings -ShadowOffs, ShadowOffs
CC.Paint W.Alpha * 0.25, Pat
CC.Restore
End If
CC.Paint W.Alpha, Pat 'so what we do in this line, is only "a Blit" (using the already rotated Pattern-Matrix)
End Sub
Option Explicit
Private WithEvents Panel As cWidgetForm 'a cWidgetForm-based Panel-area (followed by 4 clock-Widget-Vars)
Private LaCrosse As cWidgetBase, Flower As cWidgetBase, Square As cWidgetBase, System As cWidgetBase
Private Sub Form_Load()
ScaleMode = vbPixels
Caption = "Resize Me... (the four Clock-Widgets are individually moveable too)"
LoadImgResources
Set Panel = Cairo.WidgetForms.CreateChild(Me.hWnd)
Panel.WidgetRoot.ImageKey = "BackGround"
Set LaCrosse = Panel.Widgets.Add(New cwClock, "LaCrosse", 0.015 * ScaleWidth, 0.16 * ScaleHeight, 501, 501).Widget
LaCrosse.ImageKey = "ClockLaCrosse" 'same as with the Background of the Panel above - just specify an ImageKey
Set Flower = Panel.Widgets.Add(New cwClock, "Flower", 0.73 * ScaleWidth, 0.01 * ScaleHeight, 501, 501).Widget
Flower.ImageKey = "ClockFlower" 'same as with the Background of the Panel above - just specify an ImageKey
Set Square = Panel.Widgets.Add(New cwClock, "Square", 0.528 * ScaleWidth, 0.65 * ScaleHeight, 501, 501).Widget
Square.ImageKey = "ClockSquare" 'same as with the Background of the Panel above - just specify an ImageKey
Set System = Panel.Widgets.Add(New cwClock, "System", 0.3405 * ScaleWidth, 0.726 * ScaleHeight, 501, 501).Widget
System.ImageKey = "ClockSystem" 'same as with the Background of the Panel above - just specify an ImageKey
System.Alpha = 0.75 '<- just to show, that this would work too of course
Move Left, Top, Screen.Width / 2, Screen.Width / 2 * 0.66
End Sub
Private Sub Panel_BubblingEvent(Sender As Object, EventName As String, P1 As Variant, P2 As Variant, P3 As Variant, P4 As Variant, P5 As Variant, P6 As Variant, P7 As Variant)
If TypeOf Sender Is cwClock And EventName = "W_Moving" Or EventName = "W_AddedToHierarchy" Then
Sender.Widget.Tag = Array(Sender.Widget.Left / ScaleWidth, Sender.Widget.Top / ScaleHeight) 'the Widgets Tag-Prop is a Variant - and can store anything
End If
End Sub
Private Sub Form_Resize()
Panel.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub Panel_ResizeWithDimensions(ByVal NewWidth As Long, ByVal NewHeight As Long)
'that doesn't really have anything to do with the analog-clock-widgets, it's just normal "percentual positioning-tricks"
LaCrosse.Move LaCrosse.Tag(0) * NewWidth, LaCrosse.Tag(1) * NewHeight, NewWidth * 0.25, NewHeight * 0.4
Flower.Move Flower.Tag(0) * NewWidth, Flower.Tag(1) * NewHeight, NewWidth * 0.16, NewHeight * 0.25
Square.Move Square.Tag(0) * NewWidth, Square.Tag(1) * NewHeight, NewWidth * 0.18, NewHeight * 0.29
System.Move System.Tag(0) * NewWidth, System.Tag(1) * NewHeight, NewWidth * 0.032, NewHeight * 0.058
End Sub
Private Sub LoadImgResources() 'just plain image-loading from disk (into the global ImageList, from where it is accessible by Key)
Cairo.ImageList.AddImage "BackGround", App.Path & "\BackGround.jpg"
Cairo.ImageList.AddImage "ClockLaCrosse", App.Path & "\ClockLaCrosse.png"
Cairo.ImageList.AddImage "ClockFlower", App.Path & "\ClockFlower.png", 251, 251
Cairo.ImageList.AddImage "ClockSquare", App.Path & "\ClockSquare.png", 401, 401
Cairo.ImageList.AddImage "ClockSystem", App.Path & "\ClockSystem.png", 401, 401
End Sub
Private Sub Form_Terminate()
If Forms.Count = 0 Then New_c.CleanupRichClientDll
End Sub
Option Explicit
Private Const FADF_AUTO As Integer = &H1 'An array that is allocated on the stack.
Private Const FADF_FIXEDSIZE As Integer = &H10 'An array that may not be resized or reallocated.
Private Type SAFEARRAY1D 'Represents a safe array. (One Dimensional)
cDims As Integer 'The count of dimensions.
fFeatures As Integer 'Flags used by the SafeArray.
cbElements As Long 'The size of an array element.
cLocks As Long 'The number of times the array has been locked without a corresponding unlock.
pvData As Long 'Pointer to the data.
cElements As Long 'The number of elements in the dimension.
lLbound As Long 'The lower bound of the dimension.
End Type 'http://msdn.microsoft.com/en-us/library/ms221482(v=vs.85).aspx
Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (ByRef ArrayVar() As Any) As Long
Private Declare Sub PutMem4 Lib "msvbvm60.dll" (ByVal Addr As Long, ByVal NewVal As Long)
Private Ptr As Long
Private SA1D As SAFEARRAY1D
Private Sub Class_Initialize()
With SA1D
.cDims = 1
.fFeatures = FADF_AUTO Or FADF_FIXEDSIZE
.cbElements = 2&
.cLocks = 1&
.lLbound = 1&
End With
End Sub
'This should be the first method called right after instantiating
'the class and should be invoked only once per class instance.
'Pass the Integer array that will substitute for the String.
Public Sub InitArray(ByRef IntArray_OUT() As Integer)
Erase IntArray_OUT
Ptr = VarPtrArray(IntArray_OUT())
PutMem4 Ptr, VarPtr(SA1D)
End Sub
'This function typecasts the passed String into an Integer array.
'That is, the characters of the String can be treated as elements
'of the Integer array. Any number of Strings can be typecast to
'the Integer array by calling this function repeatedly. However,
'the array should not be Erased when assigning another String.
'This function fails (returns False) if passed an empty string.
Public Function CastString(ByRef String_IN As String) As Boolean
Dim StrLen As Long
If Ptr Then
StrLen = Len(String_IN)
If StrLen Then
With SA1D
.pvData = StrPtr(String_IN)
.cElements = StrLen
CastString = .pvData <> 0&
End With
End If
End If
End Function
Private Sub Class_Terminate()
If Ptr Then PutMem4 Ptr, 0&
End Sub
Option Explicit
Private Sub Main()
Dim aintChars() As Integer, i As Long
Dim sControlChars As String, sPrintableChars As String
sControlChars = Space$(31&)
sPrintableChars = String$(224&, 0)
With New clsStrToIntArray
.InitArray aintChars()
If .CastString(sPrintableChars) Then
For i = LBound(aintChars) To UBound(aintChars)
aintChars(i) = i + 31&
Next
Debug.Print """" & sPrintableChars & """"
End If
If .CastString(sControlChars) Then
For i = LBound(aintChars) To UBound(aintChars)
aintChars(i) = i
Next
Debug.Print """" & sControlChars & """"
End If
End With
End Sub
13-Aug-2013
- Fixed a bug that the application will crash when there is an empty string in the custom source.
12-Aug-2013
- First release.