im writing an app for accountings of small hotel, i'm working with Visual Studio 2013, on OS: windows 10 (Laptop). After finishing the app just published it using publish wizard, then everything was going great till i copied the published files to another computer contains OS: Windows 7 SP1, the app worked successfully but with a little changes in form design and while preview reports printing.
Here's two pictures to explain what is exactly the problem...
If anyone could explain what's going on and what to do to solve this issue would be respected.
Here's my class which contains printpreviewcontrol code:
Private mRow As Integer = 0
Private newpage As Boolean = True
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Try
Dim font36 = New Font("Playball", 36, FontStyle.Regular)
Dim font8 = New Font("Lora", 8, FontStyle.Regular)
Dim font20 = New Font("Lora", 20, FontStyle.Underline)
Dim font16 = New Font("Lora", 16, FontStyle.Regular)
e.Graphics.DrawString("Riviera Beach Chalets", font36, Brushes.Black, New Rectangle(150, 25, 800, 100))
e.Graphics.DrawString("Accounting Reports", font20, Brushes.Black, New Rectangle(650, 45, 300, 50))
e.Graphics.FillRectangle(Brushes.MistyRose, New Rectangle(101, 741, 19, 19))
e.Graphics.DrawString("Accommondation Revenue or Beach Revenue or CoffeeShop Revenue is 0", font8, Brushes.Black, New Rectangle(125, 745, 500, 30))
e.Graphics.DrawString("Amount Received Total :", font16, Brushes.Black, New Rectangle(570, 735, 500, 50))
e.Graphics.DrawString(Report_Database.reporttot, font16, Brushes.Black, New Rectangle(850, 735, 500, 50))
' sets it to show '...' for long text
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
fmt.LineAlignment = StringAlignment.Center
fmt.Trimming = StringTrimming.EllipsisCharacter
Dim y As Int32 = e.MarginBounds.Top
Dim rc As Rectangle
Dim x As Int32
Dim h As Int32 = 0
Dim row As DataGridViewRow
' print the header text for a new page
' use a grey bg just like the control
If newpage Then
row = Report_Database.DataGridView1.Rows(mRow)
x = 50
For Each cell As DataGridViewCell In row.Cells
' since we are printing the control's view,
' skip invidible columns
If cell.Visible Then
rc = New Rectangle(x, y, cell.Size.Width, cell.Size.Height)
e.Graphics.FillRectangle(Brushes.LightGray, rc)
e.Graphics.DrawRectangle(Pens.Black, rc)
' reused in the data pront - should be a function
Select Case Report_Database.DataGridView1.Columns(cell.ColumnIndex).DefaultCellStyle.Alignment
Case DataGridViewContentAlignment.BottomRight,
DataGridViewContentAlignment.MiddleRight
fmt.Alignment = StringAlignment.Far
rc.Offset(-1, 0)
Case DataGridViewContentAlignment.BottomCenter,
DataGridViewContentAlignment.MiddleCenter
fmt.Alignment = StringAlignment.Center
Case Else
fmt.Alignment = StringAlignment.Near
rc.Offset(2, 0)
End Select
e.Graphics.DrawString(Report_Database.DataGridView1.Columns(cell.ColumnIndex).HeaderText,
Report_Database.DataGridView1.Font, Brushes.Black, rc, fmt)
x += rc.Width
h = Math.Max(h, rc.Height)
End If
Next
y += h
End If
newpage = False
' now print the data for each row
Dim thisNDX As Int32
For thisNDX = mRow To Report_Database.DataGridView1.RowCount - 1
' no need to try to print the new row
If Report_Database.DataGridView1.Rows(thisNDX).IsNewRow Then Exit For
row = Report_Database.DataGridView1.Rows(thisNDX)
h = 0
' reset X for data
x = 50
' print the data
For Each cell As DataGridViewCell In row.Cells
If cell.Visible Then
rc = New Rectangle(x, y, cell.Size.Width, cell.Size.Height)
' SAMPLE CODE: How To
' up a RowPrePaint rule
If Val(row.Cells(2).Value) = 0 Or Val(row.Cells(3).Value) = 0 Or Val(row.Cells(4).Value) = 0 Then
Using br As New SolidBrush(Color.MistyRose)
e.Graphics.FillRectangle(br, rc)
End Using
End If
e.Graphics.DrawRectangle(Pens.Black, rc)
Select Case Report_Database.DataGridView1.Columns(cell.ColumnIndex).DefaultCellStyle.Alignment
Case DataGridViewContentAlignment.BottomRight,
DataGridViewContentAlignment.MiddleRight
fmt.Alignment = StringAlignment.Far
rc.Offset(-1, 0)
Case DataGridViewContentAlignment.BottomCenter,
DataGridViewContentAlignment.MiddleCenter
fmt.Alignment = StringAlignment.Center
Case Else
fmt.Alignment = StringAlignment.Near
rc.Offset(2, 0)
End Select
e.Graphics.DrawString(cell.FormattedValue.ToString(),
Report_Database.DataGridView1.Font, Brushes.Black, rc, fmt)
x += rc.Width
h = Math.Max(h, rc.Height)
End If
Next
y += h
' next row to print
mRow = thisNDX + 1
If y + h > e.MarginBounds.Bottom Then
e.HasMorePages = True
' mRow -= 1 causes last row to rePrint on next page
newpage = True
Button1.Enabled = True
Button4.Enabled = True
If mRow = Report_Database.DataGridView1.RowCount Then
e.HasMorePages = False
Exit Sub
End If
Return
End If
Next
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical)
End Try
Related
I have completed the main objective of dividing the day into "cycles". Now, I am having trouble with creating a "sub cycle" within each zone that is defined. I basically am trying to take a cycle (sesionTime1) and split that at 0.38 and 0.62 be it with a vertical line that only goes from the overall session high/low, or just create another box where the start of the box is at the 0.38 and the end of the box is at 0.62. I have tried defining sessionTime1 * 0.38, but thats not working for me. And, using bar_indez(X) only focuses on the bar movement which will change as the timeframe on chart is changed.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © hitmanict
//#version=5
indicator("AMD", overlay=true)
//Get boolean input value (on/off buttons)
//Accumulation
inputAcc = input.bool(title = "Accumulation", defval = true, tooltip = "Turn On/Off Accumulation & Select Color", inline = "1", group = "Accumulation")
inputAccColor = input.color(title = "Box", defval = color.new(#4caf50, 90), inline = "2", group = "Accumulation")
InputAccBorder = input.color(title = "Border", defval = color.rgb(0, 0, 0, 95), inline = "2", group = "Accumulation")
inputAccSub = input.bool(title = "Accumulation Fractal", defval = true, group = "Accumulation")
sessionTime1 = input.session("1845-0330", title = "Session Time")
sessionZone1 = input.string("GMT-5", title = "Session Time Zone")
//Manipulation
inputMan = input.bool(title = "Manipulation", defval = true, tooltip = "Turn On/Off Manipulation & Select Color", inline = "3", group = "Manipulation")
inputManColor = input.color(title = "Box", defval = color.new(#ffcc80,80), inline = "4", group = "Manipulation")
InputManBorder = input.color(title = "Border", defval = color.rgb(0, 0, 0, 95), inline = "4", group = "Manipulation")
sessionTime2 = input.session("0330-0900", title = "Session Time")
sessionZone2 = input.string("GMT-5", title = "Session Time Zone")
//Distribution
inputDistro = input.bool(title = "Distribution", defval = true, tooltip = "Turn On/Off Distribution & Select Color", inline = "5", group = "Distribution")
inputDistColor = input.color(title = "Box", defval = color.new(#2962ff,95), inline = "6", group = "Distribution")
InputDistBorder = input.color(title = "Border", defval = color.rgb(0, 0, 0, 95), inline = "6", group = "Distribution")
sessionTime3 = input.session("0900-1845", title = "Session Time")
sessionZone3 = input.string("GMT-5", title = "Session Time Zone")
//InSession() returns 'true' when the current bar happens inside
//the specified session, corrected for the given time zone (optional).
//Returns 'false' when the bar doesn't happen in that time period,
//or when the chart's time frame is 1 day or higher.
InSession1(sessionTime1, sessionZone1=syminfo.timezone) => not na(time(timeframe.period, sessionTime1, sessionZone1))
InSession2(sessionTime2, sessionZone1=syminfo.timezone) => not na(time(timeframe.period, sessionTime2, sessionZone2))
InSession3(sessionTime3, sessionZone1=syminfo.timezone) => not na(time(timeframe.period, sessionTime3, sessionZone3))
//See if the session is currently active and just started
inSession1 = InSession1(sessionTime1, sessionZone1) and timeframe.isintraday
session1Start = inSession1 and not inSession1[1]
inSession2 = InSession2(sessionTime2, sessionZone2) and timeframe.isintraday
session2Start = inSession2 and not inSession2[1]
inSession3 = InSession3(sessionTime3, sessionZone3) and timeframe.isintraday
session3Start = inSession3 and not inSession3[1]
//Create variables
var session1HighPrice = 0.0
var session1LowPrice = 0.0
var session2HighPrice = 0.0
var session2LowPrice = 0.0
var session3HighPrice = 0.0
var session3LowPrice = 0.0
//When a new session starts, set high/low to the data of the bar in the session.
if session1Start
session1HighPrice := high
session1LowPrice := low
if session2Start
session2HighPrice := high
session2LowPrice := low
if session3Start
session3HighPrice := high
session3LowPrice := low
//Else, during the session, track the highest high and lowest low
else if inSession1
session1HighPrice := math.max(session1HighPrice, high)
session1LowPrice := math.min(session1LowPrice, low)
else if inSession2
session2HighPrice := math.max(session2HighPrice, high)
session2LowPrice := math.min(session2LowPrice, low)
else if inSession3
session3HighPrice := math.max(session3HighPrice, high)
session3LowPrice := math.min(session3LowPrice, low)
//Create persistent variable for the box identifier
var box session1Box = na
var box session2Box = na
var box session3Box = na
//When a session begins, make a new box for that session
if session1Start
session1Box := inputAcc ? box.new(left=bar_index, top = na, right = na, bottom = na, bgcolor = inputAccColor, border_color = InputAccBorder) : na
if session2Start
session2Box := inputMan ? box.new(left=bar_index, top = na, right = na, bottom = na, bgcolor = inputManColor, border_color = InputManBorder) : na
if session3Start
session3Box := inputDistro ? box.new(left=bar_index, top = na, right = na, bottom = na, bgcolor = inputDistColor, border_color = InputDistBorder) : na
//During the session, update that session's existing box
if inSession1
box.set_top(session1Box, session1HighPrice)
box.set_bottom(session1Box, session1LowPrice)
box.set_right(session1Box, bar_index + 1)
if inSession2
box.set_top(session2Box, session2HighPrice)
box.set_bottom(session2Box, session2LowPrice)
box.set_right(session2Box, bar_index + 1)
if inSession3
box.set_top(session3Box, session3HighPrice)
box.set_bottom(session3Box, session3LowPrice)
box.set_right(session3Box, bar_index + 1)
*//Sub AMD Section*
//Create persistent variable for the sub box identifier
var box session1BoxSub = na
var box session2BoxSub = na
var box session3BoxSub = na
if session1Start
session1BoxSub := inputAcc == inputAccSub ? box.new(left = bar_index, top = na, right = na, bottom = na, bgcolor = color.rgb(0, 187, 212, 100), border_color = color.rgb(171, 173, 177), border_style = line.style_dotted, border_width = 2) : na
if inSession1
box.set_top(session1BoxSub, session1HighPrice)
box.set_bottom(session1BoxSub, session1LowPrice)
box.set_right(session1BoxSub, bar_index + 1)
I am attempting this addition at the very bottom unde3r SUB AMD SECTION. Any help/guidance is greatly appreciated.
I have created an array to store some excel cell addresses, but while running through a portion of the array with a For Loop (because the values are in order for that portion of the data and its easier than doing each one at a time), but I get an error at line 22,(saData(i,1) = "D" count), right at the "count" variable but I cant figure out why.
'LOADING EXCEL CELL ADDRESS INTO INPUT ARRAY
saData(0,1) = "C3"
saData(1,1) = "F3"
saData(2,1) = "C4"
saData(3,1) = "F4"
saData(4,1) = "F6"
saData(5,1) = "C7"
saData(6,1) = "F7"
saData(7,1) = "C8"
saData(8,1) = "C9"
saData(9,1) = "F9"
saData(10,1) = "C11"
saData(12,1) = "F11"
saData(13,1) = "C13"
saData(14,1) = "F13"
Dim count : count = 16
For i = 15 to 54
saData(i,1) = "D" count
count = count + 1
next'
saData(55,1) = "G59"
saData(56,1) = "F60"
saData(57,1) = "B64"
saData(58,1) = "E64"
For i = 0 to 59
Msgbox saData(i,1)
next
Just try concatenating saData(i,1) = "D"&count
Currently I have 6 images layered over top of each other, each with their own corresponding walk animation frame. Each time you walk the Visible property changes and allows the next animation frame to be seen.
The only problem is the bloody flickering when it is passing through any type of object be it, picturebox, form, command button, etc....
After a tiresome day of research I just can't come up with a solution to fix this.
a little snippet of my code if anyone want's to see:
Select Case CharFrame
Case 1
Avatar(0).Visible = True
Avatar(1).Visible = False
Avatar(2).Visible = False
CharFrame = CharFrame + 1
Case 2
Avatar(0).Visible = False
Avatar(1).Visible = True
Avatar(2).Visible = False
CharFrame = CharFrame + 1
Case 3
Avatar(0).Visible = False
Avatar(1).Visible = False
Avatar(2).Visible = True
CharFrame = 1
End Select
Sleep (Timer)
Avatar(0).Top = Avatar(0).Top + moveY
Avatar(1).Top = Avatar(1).Top + moveY
Avatar(2).Top = Avatar(2).Top + moveY
Avatar(3).Top = Avatar(0).Top
Avatar(4).Top = Avatar(1).Top
Avatar(5).Top = Avatar(2).Top
Avatar(6).Top = Avatar(0).Top
Avatar(7).Top = Avatar(1).Top
Avatar(8).Top = Avatar(2).Top
Avatar(9).Top = Avatar(0).Top
Avatar(10).Top = Avatar(1).Top
Avatar(11).Top = Avatar(2).Top
Loop
Avatar(0).Visible = True
Avatar(1).Visible = False
Avatar(2).Visible = False
Found this with Google:
Private Declare Function LockWindowUpdate Lib "USER32" (ByVal hwndLock As Long) As Long
When you like to stop window updating:
LockWindowUpdate <yourform>.hWnd
If you like to continue
LockWindowUpdate False
Found this, did not try it.
I have a EXGrid in a form and want to add button to a cell that either say "Edit" and "Remove", or Have icons for the two. Here is the code I have so far.
With grdGrade
.BeginUpdate
'.DataSource = objCo.DAL.Connection.Execute(sql)
.DefaultItemHeight = 21
.TreeColumnIndex = -1
.MarkSearchColumn = False
.FullRowSelect = exItemSel
.DrawGridLines = exAllLines
.SortOnClick = exNoSort
.BackColorHeader = grdGrade.BackColor
.Appearance = Flat
.BackColorAlternate = Me.BackColor
.SelBackColor = RGB(224, 224, 224)
.SelForeColor = vbBlack
.UseTabKey = True
.Font = Me.Font
.EndUpdate
End With
Set col = grdGrade.Columns.Add("Actions")
col.AllowDragging = False
col.Width = grdGrade.Width * 0.05
col.Editor.AddButton "Edit", , 0
col.Editor.AddButton "Remove", , 0
col.Editor.EditType = ButtonType
Thanks so much for all your help.
I finally got it. When loading the grid I used:
Me.grdGrade.Items.CellValue(h, "Actions") = " Edit "
Me.grdGrade.Items.CellHasButton(h, "Actions") = True
s = Me.grdGrade.Items.SplitCell(h, "Actions")
Me.grdGrade.Items.CellValue(0, s) = " Remove "
Me.grdGrade.Items.CellHasButton(0, s) = True
and it works like a charm
I have an image and rotate it with both MS Paint and GDI. I want to show that the rotated image from both methods are the same.
Here is the code I have to rotate image with GDI
#include <GDIPlus.au3>
_GDIPlus_Startup()
$hImage1 = _GDIPlus_ImageLoadFromFile(#ScriptDir & "\Picture.gif")
$hGraphic1 = _GDIPlus_ImageGetGraphicsContext($hImage1)
$hImage2 = _GDIPlus_BitmapCreateFromGraphics(_GDIPlus_ImageGetWidth($hImage1), _GDIPlus_ImageGetHeight($hImage1), $hGraphic1)
$hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hImage2)
$matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixRotate($matrix,90)
_GDIPlus_GraphicsSetTransform($hGraphic2, $matrix)
_GDIPlus_GraphicsDrawImage($hGraphic2, $hImage1, 0, -590)
_GDIPlus_ImageSaveToFile($hImage2, #ScriptDir & "\out.gif")
_GDIPlus_MatrixDispose($matrix)
_GDIPlus_GraphicsDispose($hGraphic1)
_GDIPlus_GraphicsDispose($hGraphic2)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_ShutDown ()
Then I used this code to compare 2 images:
$bm1 = _GDIPlus_ImageLoadFromFile(#ScriptDir & "\Picture1.gif")
$bm2 = _GDIPlus_ImageLoadFromFile(#ScriptDir & "\out.gif")
if ComparePicture($bm1, $bm2) == True Then
MsgBox(0, "Test result", "Same image!")
Else
MsgBox(0, "Test result", "Different image!")
EndIf
_GDIPlus_ImageDispose($bm1)
_GDIPlus_ImageDispose($bm2)
_GDIPlus_Shutdown()
Func ComparePicture($bm1, $bm2)
$Bm1W = _GDIPlus_ImageGetWidth($bm1)
$Bm1H = _GDIPlus_ImageGetHeight($bm1)
$BitmapData1 = _GDIPlus_BitmapLockBits($bm1, 0, 0, $Bm1W, $Bm1H, $GDIP_ILMREAD, $GDIP_PXF08INDEXED )
$Stride = DllStructGetData($BitmapData1, "Stride")
$Scan0 = DllStructGetData($BitmapData1, "Scan0")
$ptr1 = $Scan0
$size1 = ($Bm1H - 1) * $Stride + ($Bm1W - 1) * 4
$Bm2W = _GDIPlus_ImageGetWidth($bm2)
$Bm2H = _GDIPlus_ImageGetHeight($bm2)
$BitmapData2 = _GDIPlus_BitmapLockBits($bm2, 0, 0, $Bm2W, $Bm2H, $GDIP_ILMREAD, $GDIP_PXF08INDEXED)
$Stride = DllStructGetData($BitmapData2, "Stride")
$Scan0 = DllStructGetData($BitmapData2, "Scan0")
$ptr2 = $Scan0
$size2 = ($Bm2H - 1) * $Stride + ($Bm2W - 1) * 4
$smallest = $size1
If $size2 < $smallest Then $smallest = $size2
$call = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $ptr1, "ptr", $ptr2, "int", $smallest)
_GDIPlus_BitmapUnlockBits($bm1, $BitmapData1)
_GDIPlus_BitmapUnlockBits($bm2, $BitmapData2)
Return ($call[0]=0)
EndFunc
I tried changing the file type, color depth, etc. but I could not get the code to show that they are the same. When I do not rotate the picture i.e
_GDIPlus_MatrixRotate($matrix,0)
then it recognize the same image. When I rotate right 90, it doesn't. Does anyone knows what might be going on?
Thanks
For reference, this question has also been asked on the AutoIt forums here.
I think $GDIP_PXF08INDEXED is modifying the images differently. Try it without setting it and it should work.
Furthermore, you can use this code to flip the image:
$hImage1 = _GDIPlus_ImageLoadFromFile(#ScriptDir & "\Picture1.gif")
_GDIPlus_ImageRotateFlip($hImage1, 1) ;90°
_GDIPlus_ImageSaveToFile($hImage1, #ScriptDir & "\out.gif")
_GDIPlus_ImageDispose($hImage1)
Br,
UEZ