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
Related
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.
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.
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 4 years ago.
Improve this question
I have a textbox, i want the user to be able to type like a color code or something in the textbox and the form back color to change to the specific color the user typed.
Help?
If you mean that the user will be typing in something like black or blue then you need the .GetColorFromName function. The code below takes the text from TextBox1 and checks to make sure that the color is recognized. If so, the Form.BackColor is set to that colour. This way if the user mis-types a color, you wont get an error. Also, it doesn't seem to matter if you type black or Black
Dim c As Color = System.Drawing.Color.FromName(TextBox1.Text)
If c.IsKnownColor Then
Me.BackColor = c
End If
If you want to add a keyword "color" to the begining of the textbox, try this instead ..
Dim commandString As String = TextBox1.Text
If commandString.ToLower.StartsWith("color") Then
'remove the 5 letters making "color" and a space
commandString = commandString.Remove(0, 6)
Dim c As Color = System.Drawing.Color.FromName(commandString)
If c.IsKnownColor Then
Me.BackColor = c
End If
End If
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.
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 6 years ago.
Improve this question
How can i grab this url and paste it in a textbox?
Logout (Kassy Daniels) ยท Help
from this in webbrowser1
i want it to grab the /logout.php? url cause each user is different
and just paste it in a textbox1 when you hit a button
Assuming your webbrowser is WebBrowser1,
Using WebBrowser1.Document.Links will get you a HTMLElementCollection of all of the links on the page.
You can iterate through those, and check the OuterHtml element of each of those links (which will give you a string that contains the raw link, the IDs, etc.) for the text your are looking for (in this case logout?).
Using the substring command, extract that URL, and eliminate the surrounding text, and you can plug that right into the textbox.
Update: Using Firebug or your favorite DOM tool, you can find that the logout link is in the root div of the document
Dim rootDiv As HtmlElement = WebBrowser1.Document.GetElementById("root")
Dim links As HtmlElementCollection = rootDiv.GetElementsByTagName("a")
Dim index As Integer
For i As Integer = 0 To links.Count - 1
If links(i).InnerHtml.Contains("Logout") Then
index = i
Exit For
End If
Next i
Dim stringofLink As String = links(index).OuterHtml
If the page changes in structure, this should be somewhat resilient to it, but you may need to generalize it further. Process stringofLink however you want to break it up (find the ampersand that you need and then copy from the question mark to that point).