Powepoint: How to tweak progress bar so it is 100% on my "Thank you!" slide and not my extra slides? - powerpoint

I added a progress bar to my slides with the following code in macros:
Sub ProgressBar()
On Error Resume Next
With ActivePresentation
For X = 1 To .Slides.Count
.Slides(X).Shapes("PB").Delete
Set s = .Slides(X).Shapes.AddShape(msoShapeRectangle, _
0, .PageSetup.SlideHeight - 12, _
X * .PageSetup.SlideWidth / .Slides.Count, 12)
s.Fill.ForeColor.RGB = RGB(42, 0, 128)
s.Name = "PB"
Next X:
End With
End Sub
I do not want the progress bar to be 100% at the end of my slides (at my extra slides), but at my "Thank you" slide. Is there a way to do this?

Change this:
For X = 1 To .Slides.Count
to this
For X = 1 To .Slides(42)
But instead of 42, use the number of your thank you slide

Related

Visual Basic 6 add backcolor to statusbar panel

I am fixing an old application which built on top of Visual Basic 6 code. There is an requirement that adding a statusbar on the bottom of the form. My status bar is as below:
I can show the text correctly but I also want to add a red background color. I found out there is no such option for StatusBar Panel. When I open the property of StatusBar, it shows as below:
I found out I can add picture. But When I added the red color picture, the text will be cover by the picture. I am stuck. Any advice will be helpful. Thanks!!
UPDATE
I simply used the code from the link #Étienne Laneville provided in the comment. The background color added and also the text added.
Here is my code to call the function:
PanelText StatusBar1, 9, "ATM (" & cntATM & ")", QBColor(12), QBColor(0)
But the text position is like below:
I have to make the text like below to position it, because this task was urgent for now and I have no time to investigate more.
PanelText StatusBar1, 9, "ATM (" & cntATM & ") ", QBColor(12), QBColor(0)
Below is my output:
UPDATE 2
I tried the code provided by Brian M Stafford. But I got the same results. The text is still not at the center (Or to the Left). Below are my code and screenshot of status bar:
The function:
Private Sub PanelText(sb As StatusBar, pic As PictureBox, Index As Long, aText As String, bkColor As Long, _
fgColor As Long, lAlign As Integer)
Dim R As RECT
SendMessage sb.hWnd, SB_GETRECT, Index - 1, R
With pic
Set .Font = sb.Font
.Move 0, 0, (R.Right - R.Left + 2) * Screen.TwipsPerPixelX, (R.Bottom - R.Top) * Screen.TwipsPerPixelY
.BackColor = bkColor
.Cls
.ForeColor = fgColor
.CurrentY = (.Height - .TextHeight(aText)) \ 2
Select Case lAlign
Case 0 ' Left Justified
.CurrentX = 0
Case 1 ' Right Justified
.CurrentX = .Width - .TextWidth(aText) - Screen.TwipsPerPixelX * 2
Case 2 ' Centered
.CurrentX = (.Width - .TextWidth(aText)) \ 2
End Select
pic.Print aText
sb.Panels(Index).Text = aText
sb.Panels(Index).Picture = .Image
End With
End Sub
The API:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const WM_USER = &H400
Private Const SB_GETRECT = (WM_USER + 10)
Private Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" (ByVal hWnd As _
Long, ByVal wMsg As Long, ByVal wParam As _
Long, lParam As Any) As Long
Calling the function:
PanelText StatusBar1, picPanel, 9, "Test1", vbRed, vbBlack, 2
PanelText StatusBar1, picPanel, 10, "DFM (" & cntDFM & ")", vbRed, vbBlack, 2
I do not know why. May be I missed something or may be I set some property values to the StatusBar1 or picPanel(PictureBox).
SOLUTION
I set pictureBox, property AutoRedraw = True, and StatusBar, Panel, Alignment = sbrLeft. And everything works.
Here's the code referenced in a comment with some enhancements. One enhancement is a parameter to specify text alignment:
Private Sub StatusBarPanelText(sb As StatusBar, pic As PictureBox, index As Long, aText As String, bkColor As Long, fgColor As Long, lAlign As Integer)
Dim r As RECT
SendMessage sb.hWnd, SB_GETRECT, index - 1, r
With pic
Set .Font = sb.Font
.Move 0, 0, (r.Right - r.Left + 2) * Screen.TwipsPerPixelX, (r.Bottom - r.Top) * Screen.TwipsPerPixelY
.BackColor = bkColor
.Cls
.ForeColor = fgColor
.CurrentY = (.Height - .TextHeight(aText)) \ 2
Select Case lAlign
Case 0 ' Left Justified
.CurrentX = 0
Case 1 ' Right Justified
.CurrentX = .Width - .TextWidth(aText) - Screen.TwipsPerPixelX * 2
Case 2 ' Centered
.CurrentX = (.Width - .TextWidth(aText)) \ 2
End Select
pic.Print aText
sb.Panels(index).Text = aText
sb.Panels(index).Picture = .Image
End With
End Sub
Here's the Windows API code:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, lParam As Any) As Long
Private Const WM_USER = &H400
Private Const SB_GETRECT = (WM_USER + 10)
The code is then used like this:
Picture2.AutoRedraw = True
Picture2.Visible = False
StatusBarPanelText sbConfig, Picture2, 4, & _
Format(Value / 1024, "#,###") & " KB", vbRed, vbWhite, 0
I know I'm late arriving here and this particular issue may no longer matter, but here I am anyway. In trying to write a VB6 program for all versions of Windows from W-95 on, I ran into some color issues related to Microsoft's decision to change named color schemes for subsequent releases of Windows. What I have found is that using a virtual machine with Windows-98 and VB6 installed I can change the backgound color of status bars natively. That property is in the Properties box when using Win-98 but not XP and beyond. I guess the boys in Redmond wanted to enforce their look on our work and so removed that choice. I know this isn't a perfect solution, but it may be something you can live with.
Sorry, but this was my mistake. When I copied my files over from Win-7 to Win-98, VB6 replaced the status bar control with a picture box and named it statusbar1. I'm not sure why because the common controls option is checked and the status bar appears in the toolbox. Looks like the above solutions are the valid ones and mine isn't.

PrintPreviewControl & Form Design working differently on another OS. VB.NET

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

How to use print method

I have a file called worker.dat, and in that file, a list of information is stored as variables "Income","Promotion", "Age" etc.
And I want to read that information from the file and print on the screen.
So I used
Open App.Path & "worker.DAT" For Input As #1
and using the Print method, printed the information.
However for the sake of emphasis, I want to print some information in a bigger size and in different font etc.
So I wrote this.
Printer.FontSize = 16
Printer.Print "Income = "; Income
However this didn't work. Does anyone how to fix this problem?
Set the size on the font object:
Dim pt As Long
With Printer.Font
pt = .Size
Printer.Print "default text"
.Size = 16
Printer.Print "larger text"
.Size = pt
.Bold = True
Printer.Print "bold ";
.Bold = False
Printer.Print "in default size"
Printer.EndDoc
End With

Get start of line without taking soft line breaks into account

In a RichTextBox, when sending EM_LINEINDEX to get the index of the first character of a line, the index will be affected by soft line breaks. Consider the following text box:
Calling SendMessage hWnd, EM_LINEINDEX, 1, 0 will result in 25, while I would expect it to return 45 (line 1 should be "this is another line" not "and continues here").
Is there a way to get the real first char index of the second line using WinAPI calls?
This is from a working program. I play with right margin.
Sub mnuWordWrap_Click()
'On Error Resume Next
If txtNote.RightMargin = 0 Then
txtNote.RightMargin = &HFFFE&
mnuWordWrap.Checked = False
Else
txtNote.RightMargin = 0
mnuWordWrap.Checked = True
End If
txtNote.SetFocus
txtNote_SelChange
End Sub
In another program I do this, though this is Vista's RTF window (not a control so not the old ANSI version of RTF as in VB6)
If mnuViewWordWrap.Checked = True Then
Ret = SendMessageByVal(gRtfHwnd, EM_SETTARGETDEVICE, GetDC(gRtfHwnd), -1800)
If Ret = 0 Then ReportError "Form Resize", "Set Target Device"
Else
Ret = SendMessageByVal(gRtfHwnd, EM_SETTARGETDEVICE, GetDC(gRtfHwnd), 4000000)
If Ret = 0 Then ReportError "Form Resize", "Set Target Device"
End If

AutoIT script - Compare Paint's Rotated Image with GDI's rotated image

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

Resources