VB user controls not resizing in windows 8 - windows-8

I'm updating a vb6 application to run in windows 8, and one of the issues is user control windows not resizing (via the window edge drag handles). It works fine under other OSes.
The same issue plagues the main project window.
The elements of the window are controlled in this function, but the window itself doesn't respond to resizing.
Private Sub UserControl_Resize()
If g_ShuttingDown Then Exit Sub
' Test for zero size
If ScaleWidth = 0 Or ScaleHeight = 0 Then Exit Sub
' Min size
'If ScaleWidth < iMIN_FORM_WIDTH Then UserControl.Width = iMIN_FORM_WIDTH
'If ScaleWidth < iMIN_FORM_HEIGHT Then UserControl.Height = iMIN_FORM_HEIGHT
' Form dimensions
Dim x, y, w, H As Long
x = ScaleLeft
y = ScaleTop
w = ScaleWidth
H = ScaleHeight
picTitleBar.Move 0, 0, w - 30, 240
imgTitleBar.Move 0, 0, picTitleBar.Width, 240
lblCaption.Move 45, 15
imgClose.Move picTitleBar.Width - imgClose.Width - 60, 60
chkVerbose.Move 15, picTitleBar.Top + picTitleBar.Height
cmdClear.Move chkVerbose.Left + chkVerbose.Width, chkVerbose.Top
chkPause.Move cmdClear.Left + cmdClear.Width, chkVerbose.Top
Messages.Move 15, chkVerbose.Top + chkVerbose.Height, w - 30, H - (chkVerbose.Top + chkVerbose.Height)
End Sub
Any ideas how I might get these windows to respond to the resize event properly?

maybe u need download new fixed dll for vb in win 8 or need access permision for vb6.exe to allow all actions .
and maybe u sholude be disabled win 8 theme to vb work good .
i have more problems with vb6in win8 but when i disabled themes in win 7 or win 8 many of my problems sloved .

Related

Programatically positioning a control in a VB.net user control

I have a user control in VB.Net VS2019. It is used to display a description, a value and units. It generally works if the description is not too large.
The controls in the user control are all labels.
In the resize event it sizes the descriptions width to 66% of the overall width, 22% for the value, and whatever is left over for the units.
Then it set the description's left to 0, the value's left to the width of the description (plus a little). For the unit's position, it adds the left position of the value plus its width and a little.
But when the program runs the controls overlap each other and do not take the entire space of the UserControl.
For example the UserControl is 236 wide, but it looks like everything is squished to about 1/2 or 2/3s.
I have set Anchor to none and docking to none.
I perform these calculations in the 'Resize' event as shown below. The code was ported from an old VB6 program.
Is the 'Auto' size property taking precedence over the width I specify?
Private Sub UserControl1_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize
Dim lblUnits_Size As Integer
Label1.Height = MyBase.Height
Label2.Height = MyBase.Height
lblUnits.Height = MyBase.Height
Label1.Width = CInt(MyBase.Width * 0.6167)
Label2.Width = CInt(MyBase.Width * 0.22)
' I want the width of the units to be whatever is left over
lblUnits_Size = MyBase.Width - (Label1.Width + Label2.Width) - 6
If lblUnits_Size <= 0 Then lblUnits_Size = 1
lblUnits.Width = lblUnits_Size ' was -> TwipsToPixelsX(lbUnits_Size)
Label1.Left = 0
Label2.Left = (Label1.Left + Label1.Width) + 3
lblUnits.Left = (Label2.Left + Label2.Width) + 3
End Sub
I found it, the resize code needs to be called after the description changes. I guess ole VB6 did this automatically or someway the resize's were called after.

Why Does It Make A Difference If A Macro is Run When Slide Show Has Started

Apologies if this is a basic question, but I am a newbie at VBA and have spent the past two weeks learning the language. I am trying to make a learning resource using PowerPoint.
I made a good macro which seems to work perfectly when it is run outside the slide show. (I typically just pressed F5 within my VBA Editor to see what the code was doing.) However, when I try running the macro when the slide show is running (using an action button) it does not work as intended. To be more precise it appears to stop running and not show any errors or provide reasons why the macro has stopped.
I tried doing a Google search on this topic, but could not find anything. I would be very grateful if anyone could provide any reasons or suggest any information sources as to why macros work differently when the slide show is running as opposed to not running? Are there any standard practices to ensure that the macros will work when the slide show is run?
Thank you for any comments!
EDIT 02/07/20 - responding to a comment I attach the code below and have explained what I am trying to do in comments below
Sub DataInputMacro()
'This procedure attempts to group (and do a check) of all 20 answer tiles.
Dim oSh As Shape
Dim i As Integer 'This is for the For statement
Dim iix As Integer 'This is to store the x position of the tiles.
Dim iiy As Integer 'This is to store the y position of the tiles.
For i = 1 To 20
If i = 1 Or i = 3 Or i = 5 Or i = 7 Or i = 9 Then
iix = 9
ElseIf i = 2 Or i = 4 Or i = 6 Or i = 8 Or i = 10 Then
iix = 198
ElseIf i = 11 Or i = 13 Or i = 15 Or i = 17 Or i = 19 Then
iix = 587
Else
iix = 774
End If
If i = 1 Or i = 2 Or i = 11 Or i = 12 Then
iiy = 9
ElseIf i = 3 Or i = 4 Or i = 13 Or i = 14 Then
iiy = 113
ElseIf i = 5 Or i = 6 Or i = 15 Or i = 16 Then
iiy = 218
ElseIf i = 7 Or i = 8 Or i = 17 Or i = 18 Then
iiy = 323
Else
iiy = 428
End If
ActiveWindow.Selection.Unselect 'This ensures that nothing has already been selected on the slide (which could then get grouped with the first rectangle!)
For Each oSh In ActivePresentation.Slides("DataInput").Shapes
If IsWithinRange(oSh, iix - 1, iiy - 1, iix + 179, iiy + 97) Then
'MsgBox oSh.Name & " " & oSh.Left
oSh.Select (msoFalse)
End If
Next
If ActiveWindow.Selection.ShapeRange.Count > 1 Then
With ActiveWindow.Selection.ShapeRange.Group
.Name = "GroupAnswer" & i
.Select
End With
ElseIf ActiveWindow.Selection.ShapeRange.Type = msoGroup Then
ActiveWindow.Selection.ShapeRange.Name = "GroupAnswer" & i & "a"
ElseIf ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox "Sorry, but there is a set up issues of your answer boxes. Either (1) one of your answer boxes does not contain a separate textbox or image or (2) there is a missing yellow rectangle! I note for point (1) the text must be placed in a separate text box to the yellow rectangle!"
End
End If
Next i
UpdateTitle 'This is a separate function that updates the title on the front slide.
CheckFor20Groups 'This is a function that checks that there are 20 groups for the rest of the program to use!
End Sub
Shape.Select method does not work in slide view - see remarks here: Shape.Select method (PowerPoint) - so you will have to use another method for working with your shapes - try using a variable to refer to the ShapeRange you are working with rather than ActiveWindow.Selection.ShapeRange - that way you can work with them without needing to select them.

Excel VBA DoEvents on multiple computers with different processing power

It's quite common that a file I have worked on will be used on multiple computers. The computers will not have the same processing power, but I would hope to keep the "experience" consistent.The code below will trigger when someone has made a selection from a listbox. The textbox will flash green and then return back to the original color. On PC1 this occurs at a very pleasing speed, however on PC2, it occurs at twice the speed I intended. Is there a way to somehow slowdown/speed up the events (Most likely the Sleep call) when they are happening too fast/slow? It's clear I don't have the best grasp on DoEvents, but I would appreciate any comments. Thanks
PC1: i5-2520M 2.50Ghz / 8GM RAM
PC2: i7-6700K 4.0Ghz / 16 GB RAM
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub flashSelection
Dim i As Integer
'Set Color First
Me.TextBox1.BackColor = RGB(220, 220, 220)
For i = 1 To 22
Me.TextBox1.BackColor = RGB(220 - (i * 10), 220 - (i * 2), 220 - (i * 10))
DoEvents
Call Sleep(0.55)
Next i
For i = 1 To 22
Me.TextBox1.BackColor = RGB(0 + (i * 10), 176 + (i * 2), 0 + (i * 10))
DoEvents
Call Sleep(0.55)
Next i
'Reset Color
Me.TextBox1.BackColor = RGB(220, 220, 220)
End If

VB.NET - Button Resizing

I'm writing a full screen 'kiosk-esque' application and I want the buttons to fit accordingly.
Currently when the form opens, I have the buttons anchored and they stretch vertically, but I want them to resize horizontally as well?
Is there an easy way to do this?
For WinForms, use a TableLayoutPanel with 3 columns, with widths set to 33.33% for your example. Put a button in each panel, set their Dock properties to Fill, and use Anchors to stretch the entire TableLayoutPanel.
For WPF you would use a Grid control.
Used code to do it.Just add this code to your form.
Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
Button1.Width = (Me.Width - 100) / 3 - 10 'That "10" in the last comes from 15*2/3 .So if the space2 is 15 this number must be 10.
Button2.Width = (Me.Width - 100) / 3 - 10 'That "Me.Width - 100" comes from 2*50 .If you want space1 50,this number must be 100.
Button3.Width = (Me.Width - 100) / 3 - 10 'Resize the last.
Me.Button1.Location = New Point(50, Button1.Location.Y) 'Start from 50 in X Coordinate.
Me.Button2.Location = New Point(Button1.Width + 65, Button2.Location.Y) 'That 65 means "50 + 15".(50 is space1,15 is space2.)
Me.Button3.Location = New Point(Button1.Width + Button2.Width + 80, Button3.Location.Y) 'As you expected "50 + 15 + 15 = 80"
'This works for only 3 buttons(horizontally).Get the logic and improve your code for your button count.
End Sub
You can see the space1 and space2 that I used in my code here.That 3 buttons resize horizontaly if your form SizeChanged.

Jython Slot machine: making the game loop

I am writing a slot machine game for my intro to programming class. I can make the game procure 5 random images from a file containing 6, arrange them on a blank canvas and compare the pictures to see if there are 3-in-a-row. It will tell you if you win or not and ask you to play again. I need to loop the game so that it runs again after the user selects "y/n". here is my code so far.
from random import *
def main():
pictureList = setMediaPath("F:\Class Stuff\INF 120\Project X\gamepics")
s = 1 # requestInteger("Slot machine image numbering begins at:")
e = 6 # requestInteger("Slot maching image numbering ends at:")
ext = "jpg" #requestString("Enter the extension ofthe slot machine image files (without a dot):")
mypic = []
for num in range(s, e+1):
mypic = mypic + [(makePicture("smImage" + str(num) + "." + ext))]
#set up the "game board" in a blank window
w = getWidth(mypic[0])
h = getHeight(mypic[0])
ePic = makeEmptyPicture(w*5, h)
show(ePic)
# start the actual game
win = False
inRow = 1
last = -1
#loop through all five slots and set pic for each one a new, random picture. Form list of pictures.
#make a loop to run through the game until win = true.
for i in range(0,5):
imgIndex = randrange(0,len(mypic))
copyInto(mypic[imgIndex], ePic, i*w, 0)
repaint(ePic)
if imgIndex == last:
inRow = inRow + 1
else:
inRow = 1
last = imgIndex
if inRow >= 3:
win = true
if win == true:
showInformation("YOU WIN!!")
rePlay = requestString("Would you like to play again? (y/n)")
else:
showInformation("You Lose...")
requestString("Play again? (y/n)")
the media path is set to the directory on my machine with the images. here is a link to my google drive with the images. https://drive.google.com/folderview?id=0B_ZDD1CZGQYlYjFQWEpjR0NzMGs&usp=sharing .If you are going to run this, you need to change the media path in my code to correspond with where you have the pictures.
I appreciate any and all help with this. Thanks!
I dont know any jython but the pseudo code should be
var continue = true
while(continue) {
[[play game, set continue based on user input]]
}