Livecode command keystrokes [closed] - development-environment

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there a way to drag a stack window while developing on the MAC OS other than at the bar at the top of the window? If I can't see the top bar and try to drag somewhere in the middle of the stack window, it activates that group, object, etc. The only success I have is using the 'Size and position' on the stack properties window.
Thanks in advance...

If you are working in the IDE, you can type command-M to display the message box and type the following code in the message box:
set the loc of this stack to the screenLoc
This will usually move the top of the window to a visible part of the screen. You could also use
set the top of this stack to 100
which will move the title bar down to 100 pixels below the top of the screen.
If you want to move a stack window without title bar, you could use this script:
on grabWindow
if the platform is "MacOS" and (the decorations of the defaultStack contains "title" or the decorations of the defaultStack is "default") then
put 22 into myMenuCorrection
else
put 0 into myMenuCorrection
end if
put "10,10,310,310" into myRect
add myMenuCorrection to item 2 of myRect
lock messages
put (trunc(the width of this window/2) - the mouseH) into difH
put (trunc(the height of this window/2) - the mouseV) into difV
repeat until the mouse is up
put the loc of this window into loc1
put the screenMouseLoc into loc2
add difH to item 1 of loc2
add (difV + myMenuCorrection) to item 2 of loc2
if loc1 is not loc2 then set the loc of this window to loc2
end repeat
unlock messages
end grabWindow
on mouseDown
grabWindow
end mouseDown
I copies this script from a project of mine. Actually, you may not need the entire script and you might think it is a little verbose, but sometimes it could be useful to do a correction for the menubar.

Related

is the task shown? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I want to find out is the task actual shown or not. (Possible it's not shown by filter, or the outline structure is collapsed)
I want to handle it in VBA.
To determine if a task is visible, all that is really needed is to use the Find method of the Application object which returns True if visible. However, the Find method moves the active cell to that task if found and selects the entire row. This is often undesirable for the end-user.
This function returns True/False depending on if the task is visible, and resets the active cell.
Function TaskIsVisible(uid As Long) As Boolean
Dim curTaskUID As Long
curTaskUID = ActiveCell.Task.UniqueID
Dim curField As String
curField = ActiveCell.FieldName
TaskIsVisible = Application.Find("Unique ID", "equals", uid)
Application.Find "Unique ID", "equals", curTaskUID
Application.SelectCellLeft
Do While ActiveCell.FieldName <> curField
SelectCellRight
Loop
End Function
Note: Any task field can be used with the Find method and the field does not have to be in the current view. Unique ID is best in this case since it's guaranteed to not match any other task.

Visual Basic - How to save an image that is in the first column of a listview control? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Have a listview object with some columns and some rows. The first one has an image for each line (different images). I want to save each image from each row. The filename doesn't matter (could be imgyyyyMMddHHmmss.jpg, for example). struggling to get the image. The following code does not work (the listview item cannot be converted to string).
Any clues?
Thanks
Dim tmpIndex1 As Integer
Dim tmpImage As Image
For tmpIndex = 0 To listView1.Items.Count
tmpImage = lsvAddOrderItems.Items(tmpIndex1)
tmpImage.Save()
Next
A ListView control cannot contain an Image object within one of its Items.
If you want to add images to a ListView you must associate an ImageList to the ListView control.
Then to your ImageListControl load the images with its Key
Once you have all your images inside your ImageListControl, you will fill your items with your ListViewControl with the imageKey of your ImageListControl.
Then you must change your code to:
For tmpIndex = 0 To listView1.Items.Count
tmpImage = ImageListControl.Images(lsvAddOrderItems.Items(tmpIndex1).ImageKey)
tmpImage.Save()
Next
This way the conversion will not fail.

Comparing a Location [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How do I check if a Location is, for example, x = 100, y = 100?
' Compile error
If Button1.Location = 0, 0 Then
Button1.Visible = False
End If
The Location property is of type Point so you have to compare it to a Point value.
If you want a Point value with coordinates (0,0) then you can use the Shared field Point.Empty.
If you want other coordinates then you'll have to create a Point value yourself.
If Button1.Location = New Point(100, 100) Then
Button1.Enabled = False
End If
Alternatively, you could compare the Top and Left properties, each of which are type Integer, separately.
It appears that what you actually want to know is not what I read and what I provided an answer for previously. I'm not sure whether that's your fault, someone else's fault roa combination of the two. Either way, I will now answer the question of how to centre a form if it is located in the top-left of its containing window.
Firstly, while creating a new Point from (0,0) is not exactly wrong, it's more correct to use Point.Empty.
As for the actual issue, it's useless to set the StartPosition after you've called Show because StartPosition represents the position in which the form starts. If it's already been shown then it's already started so any change to StartPosition will have no effect.
You need to position the form manually by setting its Location explicitly, based on the relation between its size and that of the window you're positioning it relative too. The fact that you're using CenterParent suggests that that's not the screen, so you'll need to qualify that if you want a specific example. You shouldn't need a specific example though, because it's simple arithmetic of the sort taught in primary school.
If Button1.Location.X = 0 And Button1.Location.Y = 0 Then
Button1.Visible = False
End If

How to know when a picture is being selected in Excel with VBA? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm new to VBA (1 month), and I can't find how to get my code to know when I select a picture in Excel.
I want to be able to autoselect the cell containing the picture if I select the picture instead of the cell.
The picture already has the same name as the cell with "INV" as start (ex: INV$A$1).
The code must also work for double clicks, as double clicking the cell triggers some subroutine.
Everything is already written, but if I click the picture rather than the cell, nothing happens.
Add a macro to your images when they're inserted. You can use the same macro for all images and check the value of Application.Caller to determine which image/shape was clicked.
Sub Pics_Clicks()
ActiveSheet.Shapes(Application.Caller).TopLeftCell.Select
End Sub
Try something like this:
Private Sub Image1_Click()
MsgBox "clicked via Click!"
End Sub
Private Sub Image1_GotFocus()
MsgBox "clicked via GotFocus!"
End Sub
Here, "Image1" is the automatically created name of a control of type Image.
Such a control is inserted to an Excel sheet in Design Mode. Double click on the control to get the event handler routine auto-edited in the VBA editor.

VB.net Game Using Picture Boxes Functions [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to develop a simple game using picture boxes
For example, if you have 3 different picture boxes each containing a unique picture
When a form loads, one box is visible while other two are invisible
The player has to click on the visible picture box before it becomes invisible (time is specified for the box to stay visible)
Example: box 1 stays visible for 5 seconds , if the box is not clicked during the 5 seconds box 1 become invisible , and another random box will become visible.
Of course , if the user click on the picture successfully his score is updated
Different levels can be made by making the time shorter
The code would probably be one single code placed at the form load
Any help? Thanks
I would probably use a stopwatch - a timer would be difficult because i dont know of a way to reset the count back to 0 when a user clicks sucessfully.
declare a stopwatch like so:
Private maxWaitTimer As New Stopwatch
then, perhaps a 'game loop' type of thing could be used in your form load event... maybe something like this:
maxWaitStopwatch.Start()
While(GameIsRunning)
If maxWaitStopwatch.ElapsedMilliseconds > 5000 Then
Losses = Losses + 1
selectNewPictureBox()
maxWaitStopwatch.Restart()
Else
Application.DoEvents() 'this gives the program a chance to execute the picture box click event, among other things (resize, drag, etc... since we are spinning in a loop)
End If
'System.Threading.Thread.Sleep(100) 'uncommenting this line will prevent it from maxing out your processor, although it will be slightly less responsive
End While
and your picture boxes could implement something like this:
Wins = Wins + 1
selectNewPictureBox()
maxWaitStopwatch.Restart()
basically, your program spins around in a loop, checking to see if the timer is elapsed, and if it is, it moves the picture.
the click event increments the score - it has a chance to be run during the 'application.doevents()' portion of the loop.
adding a sleep(100) will slow it down very slightly (and make it slightly more innaccurate, by about 100ms), but it will prevent it from using tons of CPU. you probably wont notice the difference in speed.
there may be better ways to do this, though...
EDIT - reflecting what steven said, it would be better if you used a timer instead of a loop:
use stop() when the user clicks the picture, and then call start() after.
(i didnt realize that would reset it, but apparently it does)
Use a timer with an interval of 5000 and then in the elapsed event handler
Timer.stop()
Losses = Losses + 1
selectNewPictureBox()
Time.start()
Then in the picture box handler
Timer.stop()
Wins = Wins + 1
selectNewPictureBox()
Timer.start()