Using MouseMove() with Status Bar - vb6

I have been searching for an answer on Stack Overflow and on Google but found nothing. I am doing this as a school project and can not get my head around it. i need the status bar to show "Ready" when the mouse is not over the text boxes. This is the code for one of the text boxes:
Private Sub Text3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
StatusBar1.SimpleText = "Last Name of Student"
End Sub
How can I make it that when the mouse is somewhere else it says "Ready".
Thanks to anyone that could help.

I just created a mousemove for every object on the screen and coded it to show the information on the status bar.

Related

How to open and close a position in the same bar in pinescript v5

I am trying just that. Open one position at the open of bar and close it at the end of the bar, not in the next bar. Can be done? I can't find a way.
Probably I need to activate the "process_orders_on_close" to force the exit in that bar, okay, but how can I force the position open in that bar and not at the end of the one bar before?
I have been playing with commands like time_close and time_tradingday comparing one or both with a session input. But the problem is the same, the script is executed at the end of the bar by default and any change will be done in the next bar. So if I use the "process_orders_on_close" the entry signal appears in the bar before.
I also tried request.security_lower_tf() but It doesn't work, maybe because the lower timeframes data no longer exits, only does in a higher temp.
So my question is that, can it be done? Can I open an order at the end of a bar and close that order at the end of the same bar? I am talking in historical chart alwais, of course.
I think it doesn't matter the timeframe but I am working on D chart.

Editing text from outside shoes app overlaps text

I am working on a ruby app that needs to update text on the GUI at unknown times. The process I am using overlaps the text with text from the previous edit.
class_text is the element I need to edit. I have about 8 different places in the program that could potentially change the text. Sometimes when the text is changed the previous text does not get removed and instead the text overlaps itself.
$class_text.text = "Nothing scheduled to take attendance at this time."
This project was started by people before me and this is my first experience with Ruby. Thank you for any info you can send my way!
without more specific information I've just tested a bare minimum for a scenario similar to yours (using Red Shoes though) and this works:
Shoes.app do
#test_stack = stack do
#edit_box = edit_box
#edit_box.text = "first text"
#edit_text = para "second text"
end
button "change" do
#edit_box.text = "first replacement"
#edit_text.text = "second replacement"
end
end
You could also try clearing the element first.
hth
seba

How could I use VBA to change a button's picture to one of the embedded default images?

I'm trying to get a button to change from the "Arrow Left" to "Arrow Right" picture when I click it, but I'm not sure how to assign the images through VBA. I tried Me!btnCollapseUnscheduled.Picture = "Arrow Left", but I get an error message this way.
In Access 2010 or later, you can store images in the MSysResources system table. Then choose Shared for your command button's Picture Type property, and select one of those shared images.
Afterward, it's easy to toggle between the shared images from the command buttons's click event. I named my command button "cmdArrow" and the shared images "Arrow Left" and "Arrow Right" ...
Option Compare Database
Option Explicit
Private Sub cmdArrow_Click()
Dim strDirection As String
If Me!cmdArrow.Picture Like "*Left" Then
strDirection = "Right"
Else
strDirection = "Left"
End If
Me!cmdArrow.Picture = "Arrow " & strDirection
Me!txtImage.Value = Me!cmdArrow.Picture
End Sub
Private Sub Form_Load()
Me!txtImage.Value = Me!cmdArrow.Picture
End Sub
Screenshots:
The biggest challenge was loading the images into MSysResources. I created a throwaway form and added a command button. Next I chose Embedded as the button's Picture Type property and selected Arrow Left from the available choices. Then I changed Picture Type from Embedded to Shared, which added a row to MSysResources with the image data in an attachment field and my command button's name in the Name field. So I opened the table, changed Name to "Arrow Left" and closed the table. Note MSysResources will not be visible in the Navigation pane unless you enable "Show System Objects" in the Navigation Options.
I repeated those steps for "Arrow Right". It may sound fiddly, but it's not really a huge hurdle.
The trick is to use the full file path of your icon.
MS-Access might be using some icon map for its native icons, so you might not have much luck getting a path to one of those.
If you definitely can't find the path to the native MS-Access icons, you could always just do a google image search for arrow icons (specify exact size of 16 x 16 pixels).
You can then just save these icons to a folder of your choosing and then use those paths in the following illustrations.
If you just want the button to change its image on the first click and stay that way thereafter:
Make sure the button does not have a picture attached in Design View.
Assign the default image using its full path to your command button using the form's Open event:
Private Sub Form_Open(Cancel As Integer)
Me.cmdButton.Picture = "C:\myFolder\myDefaultIcon.png"
End Sub
Then in the button's click event, assign the .picture property to the icon path you want to change it to:
Private Sub cmdButton_Click()
Me.cmdButton.Picture = "C:\myFolder\myChangedIcon.png"
End Sub
If you just want the button to toggle between 2 images on each click:
Use a toggle button control instead of a command button control
Make sure the button does not have a picture attached in Design View.
Write a sub that will handle the different on/off states of your toggle button:
Public Sub togImg()
If _
Me.togButton = -1 _
Then
Me.togButton.Picture = "C:\myFolder\myChangedIcon.png"
Else
Me.togButton.Picture = "C:\myFolder\myDefaultIcon.png"
End If
End Sub
Call your sub from both the form's Open event and the toggle button's Click event:
Private Sub Form_Open(Cancel As Integer)
togImg
End Sub
Private Sub togButton_Click()
togImg
End Sub
You could create two buttons where only one is visible at a time, both calling the same code.
When one is clicked, unhide the other, set focus to this, then hide the first button. And vice-versa.

Excel: conflict between validation, protection, and worksheet_beforeDoubleClick

I'm trying to build a protected worksheet where one of the cells has the following qualities:
Double-clicking the cell populates it with "hello".
The cell can only be blank or contain the word "hello".
So I decided to put validation on the cell, and write a worksheet_beforeDoubleClick() event.
Let's say it's cell A1. Starting with a blank worksheet, in B1 I enter "hello", and I set A1's validation as a list with range B1:B2.
My double-click event code is as follows:
Private Sub worksheet_beforedoubleclick(ByVal Target As Range, Cancel As Boolean)
If Target.Row = 1 And Target.Column = 1 Then
Target.Value = "hello"
End If
End Sub
This code and validation works fine while the sheet is unprotected; the cell populates with "hello" when double-clicked.
However, once the sheet is protected, double-clicking on cell A1 turns the mouse pointer into an hourglass until I press Esc or click on another cell; the cell does not populate with the word "hello".
Any idea what's going on?
When you protect the sheet, check the "Edit Objects" checkbox and it will work. Don't know quite why, but it will.
Thanks Doug for a lead in the right direction. For future reference, a good VBA snippet for this is:
ActiveSheet.Protect UserInterfaceOnly:=True, DrawingObjects:=False
This will protect the sheet, but allow macros to edit the sheet, as well as clear up the conflict described here.
While the answers above with unprotecting the drawing objects works, the end solution with respect to the user being able to right click and edit drawing object shapes is not always acceptable.
My work around was to use a checkbox to the left of the cell and add a macro that did what my double click action originally was doing.

VBA Excel Event Compile Error with MouseMove event on a command button

I am trying to use the MouseMove event with a command button, but cannot figure out how to prevent the following error:
Compile error:
Procedure declaration does not match description of event or procedure having the same name.
The code is very simple. I used "dummy" code here because I can never enter the event handler to get to something useful.
Private Sub Button_Name_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim X as Integer
x = x+1
End Sub
I have taken the parameter list directly from the object browser. I get similar results with other events, including DblClick(), but not Click(). I think that I must be making some fundamental error, but have not been able to identify it. Help!
I don't quite understand why you have taken the parameter list directly from the object browser. If you have the code of your user form open in the VBA window, you can select the command button in the left drop down list just above the code and the MouseMove event in the right drop down list. Then the required code is inserted automatically. It will slightly differ from your code:
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
End Sub
The next error you will run into is a duplicate declaration of X. It's already a parameter of the subroutine. So you cannot reuse it within the subroutine.
With these two things fixed, the mouse move event will fire, even on a command button.
The error occurs because you have changed the default argument specification (you removed the ByVal). The proper argument specifications appears automatically if you select MouseMove from the top-right drop-down menu in the VBA editor (after having selected your command button in the top-left drop-down). The argument specification should not be changed, else it won't work. VBA expects this specific list of arguments and if it finds something different, it won't compile. (The only thing you can change is the name of the argument variables -- but nothing else.)
This works:
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
X = X + 1 ' or whatever you need to do with X and Y
MsgBox "MouseMove! " & X & " " & Y
End Sub
I have to admit, I find that using a MouseMove event on a command button is a rather peculiar thing to do -- but maybe you have your reasons? I'd sure like to hear them.
Also, as pointed out by #Codo, you shouldn't re-declare X inside the Sub. It's already been declared as an argument of the Sub, and you can use it straight away (e.g. X = X + 1 or whatever). You don't have to redeclare it using Dim -- in fact, doing so will give a compile-time error.

Resources