Class Variables - Preserve The Last Window Position
Jun 4, 2011
I have two forms that are called by the main form. One is named frmEdit, and is invoked by the ShowDialog (modal) method. The other is named frmSearch and is invoked by the Show (non modal) method. In both cases I want to preserve the last window position so each form (class) begins with Public Class frmEdit (or frmSearch):
Dim lastx as Integer = -1
Dim lasty as Integer = -1
in the Shown event handler for each form I have the code
If lastx >= 0 Then
Me.Left = lastx
Me.Top = lasty
End If
and in the FormClosing handler I do
lastx = Me.Left
lasty = Me.Top
What I don't understand is why the frmEdit (modal) form remembers its previous position but the frmSearch (non-modal) does not. frmSearch always invokes with lastx and lasty equal to -1.
View 5 Replies
ADVERTISEMENT
Aug 24, 2009
I have looking for a tutorial or class that demonstrates more than a trivial example of saving a windows position on closing. The ones I have found don't seem to work on all systems because of:
1. Multiple monitors. (and resolution between those monitors)
2. Toolbar size and position (toolbar is only on the primary monitor, well sometimes)
3. Sometimes the programs dont open on the right monitor they were closed on.
Is there an extensive class or tutorial on all the stuff a programmer needs to get right to have a window size and position persisted between executions?
View 1 Replies
Mar 30, 2010
I have been learning about OOP and classes from a book and one of the question is the book has asked to create a simple Saving/Checking accounts Program. The question says that most of the functionality must be done through an Accounts Class, and this Acoounts class must inherit certain private fileds from an base class 'Transaction.
The question also says that data from the Saving/Checking accounts Program must be read to and from a text file, and these functions must be done within the Acounts class.
i have done everything the question asks to the best of my knowlegde and understanding but when it comes to storing and retieving data from the textfile i cannot utilise the array i created to store the textfile data onto it.
Bank Account.Write a program to maintain a person's Savings and Checking accounts. The program should keep track of and display the balances in both accounts, and maintain a list of transactions (deposits, withdrawals, fund transfers, and check clearings) separately for each account. The two lists of transactions should be stored in sequential files so that they will persist between program sessions.
Consider the form in Figure 11.12. The two dropdown combo boxes should each contain the items Checking and Savings. Each of the four group boxes corresponds to a type of transaction. (When Savings is selected in the Account combo box, the Check group box should disappear.) The user makes a transaction by typing data into the text boxes of a group box and pressing the button. The items appearing in the Transactions list box should correspond to the type of account that has been selected. The caption of the second label in the Transfer group box should toggle between "to Checking" and "to Savings" depending on the item selected in the "Transfer from" combo box. If a transaction cannot be carried out, a message (such as "Insufficient funds") should be displayed.
The program should use two classes, Transaction and Account. The class Transaction should have properties for transaction name, amount, date, and whether it is a credit (deposit) or debit (withdrawal/check). The class Account, which will have both a checking account and a savings account as instances, should use an array of Transaction objects. In addition, it should have properties for name (Checking or Savings) and balance. It should have methods to carry out a transaction (if possible), to display the list of transactions, and to load and retrieve the set of transactions into or from a sequential file. The events InsufficientFunds and TransactionCommitted should be triggered at appropriate times.
Hint: In order for an Account object to display a list of transactions, a list box should be passed to a method as an argument. The method might be declared with Sub EnumerateTransactions(ByVal lb As ListBox).
Here is my code. I am sorry this code is basic and unedited.
Public Class Form3
'load contents of Text file into the listbox when first loaded
'store data in file into array of accounts, record no. counts
[code]....
View 3 Replies
Mar 23, 2012
I define some global variables of a class as follows:
Private Class MyClass
Private var1 as Decimal
Private list1 as List(Of string)[code].....
But I found that after this form is closed, all above variables, var1, list1, list2 still exist in memory. I thought they should be collected by gc since the form is already disposed as I confirmed.
Add: I have monitored half an hour after the form is closed. But these variables are not collected by gc. I have an automatic update procedure on the form which uses above variables.Since the above variables still hold values, the automatic update procedure is always called which causes exception. (One quick fix is to check if form.isDisposed in update procedure. But I do not think this is elegeant. Besides, these variables occupy memory.)
View 2 Replies
Jun 9, 2012
I'm new in .NET programming.I have a class Form1 that includes Button1_Click event.Button1_Click creates a multiple Text Boxies at run time)Here is the class:
Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer
[code].....
View 3 Replies
Nov 1, 2011
Simple thing, well, I think it is.I need to Add a class to an element within an asp:repeater under certain conditions, using VB.
So, I can do
ITEMID.Attributes.Add("class", "classToAdd")
But this removes the existing classes and therefore screws up my CSS.
[code].....
View 2 Replies
Aug 3, 2011
In vb6, we have a windows (kind of layout of the screen), that allows us to manually position a form, by simply moving it with the mouse to the desired position.Don't we have same feature in .net ? am not finding where I can show this Window in visual studio 2008
View 6 Replies
Mar 9, 2009
I accidentally moved the Toolbox out of its original position. How can I place it back to the vertical tab position? The photo below shows how it is now. I cannot find the way to place it back to its original position as a vertical t
View 3 Replies
Aug 17, 2010
im using this code to get window's Postions
Imports System.Runtime.InteropServices
Public Class Form1
<StructLayout(LayoutKind.Sequential)> _
[Code].....
it works perfect on anything i have tried but now im trying to get a system window more specific the properties window i tried Winspect to get the window ID i tried everything listed in it and nothing worked anyone got some idea's why ? or any other way i can get the window postion
View 5 Replies
Dec 3, 2009
I am working on an application in Visual Basic 2008 Express.Dependeing on aa user choice,the window can be one of three sizes. I want each to be centered.On startup the property for "StartPosition" is "CenterScreen", the form loads with the window at the top center of the screen.
The user selects a differentsize for the form, using the following code:
Me.Size = New System.Drawing.Size(1020, 475)
Me.StartPosition = FormStartPosition.CenterScreen
[code]......
View 1 Replies
Aug 5, 2010
how can I make start my external application "DXSETUP.exe" at center screen position using this code?
Private Sub Panel3_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel3.MouseClick
Try
Me.Hide()
Threading.Thread.Sleep(2000)
[code]....
View 3 Replies
Nov 4, 2010
I'm having a difficult time getting cursor's position within the window I tried using : Cursor.Position.X and Cursor.Position.Y but it returns the position of the cursor on the screen and not in the window...
View 10 Replies
Jan 18, 2011
i just want to know how to maintain the position of an object w.r.t the window in vb when i resize the window during run-time.i tried anchoring it from all sides and the object resizes along with it.
View 6 Replies
Sep 27, 2011
How do I know the other window trackbar position lever
View 2 Replies
Jan 30, 2012
I tried this for my forms, but because I am setting the position with a re-size function and anchors as well, it does not seem to work quite right.
I end up with grey lines (edge of a control I think), and some of my text boxes loose their position. What do you recommend? [URL]
View 1 Replies
Oct 30, 2008
like when i close a program, i want it to save its location (i guess to the registry, idk) and then when it loads, i want it to load back where it was.this is what i have so far. it saves to the registry ok, but it doesnt load where it should. also, my button1 click is what saves the location for now, but this code is just a test app for this.
Code:
Imports System.IO
Imports Microsoft.Win32
[code].....
View 11 Replies
Jul 10, 2009
My OCR program uses coordinates to capture text from other program. It works great when program that it takes image from is positioned at coordinates (0, 0). Is here way to find window coordinates, so it can work no matter where program window is positioned?
Something like this:
$winpos = WinGetPos("[Class:Notepad]")
MouseClick("left", $winpos[0]+10, $winpos[1]+10)
(example from Autoit)
View 3 Replies
Jan 15, 2011
I want to find the size and position of a window from another application. I already have the window handle, how can i do this?
View 2 Replies
May 30, 2012
i'm playing around with fore & background colors, putting text in different places so i thought i'd try to size and position the console window but Console.SetWindowSize(640, 480) gives me an error saying that it has to be less than 170? [Code]. Positioning the window to the center of my screen isn't working either?
View 2 Replies
Apr 17, 2011
I have a project in WPF 4 and vb.net 2010.
I have a canvas inside a window. The window is full screen, but the canvas is set to a solid 640x480 in the center of the window. I need to get the mouse position inside of the canvas, but NOT inside of the window. How do I do this?
View 1 Replies
Jan 17, 2009
I have a VB.NET MDI WinForms app. My users have been complaining about form creep (as they call it), this is where each time you open a specific form within the main MDI window it opens slightly below and to the right of the location it loaded previously - i.e. it starts in the top left of the window and works its way down to the bottom right.I have to agree with them that this is extremely irritating, is there any way to prevent this?
The code to load the forms is:
frmPurchaseInvoiceSelect.Show()
frmPurchaseInvoiceSelect.MdiParent = Me
I can address this somewhat by setting the forms start-up positions to 'Manual' but then they just open directly on top of each other in the top left of the screen.
View 5 Replies
May 5, 2009
I need to program an application which acts like a passwordfiller.
Describtion: When i open up internet explorer a popup comes up requesting my username and password and i need a way to set my application near the popup and fill it in.
Here is what i need:
- Get Window hwnd (using find window api) *Ok
- Get Window state *Ok
- Get window Position *Help
- Get Window Length and Width *Help
- Focus on the window *Help
- Sendkeys *Ok
View 6 Replies
Jun 19, 2010
I have a small application that displays a listbox under the cursor position when the user uses a shortcut key.
When the user double clicks a selection from the listbox I want to insert that selected text at the curser position of that opened window.
Example: user has microsoft word open. He/she uses a shortcut key that displays a listbox just under the cursor position. The listbox has a collection of text. When the user double clicks a selection that selected text is inserted at the cursor position.
I tried the following:
Private Sub ListBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Text.Insert(Cursor.Position, ListBox1.SelectedItem)
End Sub
View 1 Replies
Nov 6, 2010
What i need to do is, I need to send the value of "e.enrollNo " to any active windows cursor point(to the Insertion Pointer).
Sub
BioBridgeSDK_OnAttTransactionEx(ByVal
sender As[code].....
View 3 Replies
Jul 7, 2009
If TextBox1.Text has atleast one number 0 or 1 or 2 or 0 (it may have text too, with numbers) then End If Also what command is it to get window position coordinates and what winpos[x] and winpos[y] are. All I found was setwindowpos
View 2 Replies
Jun 24, 2009
as title says.... ive been searching it for a long time and i couldnt find it
View 1 Replies
Sep 6, 2009
How to find window handle by its position?
View 13 Replies
Dec 12, 2011
No matter what I've done, I can't make my application window the size and position saved in the registry. Below is the code at the end of my Form1_Load: [code]
View 1 Replies
Nov 23, 2010
I am writting a program that aims at filling up bookmarks of a template with data retrieved from a sql server db. The form opens a Word document but I can't control the position and dimensions of the word document. It seems that I can't manage to overwrite MS Word default settings for position and dimensions. I want to be able to display the word document close to the form.Here is the code that I have tried and doesn't work:
Dim
wawidth
As
Integer
[code]....
View 1 Replies
May 21, 2012
I am working on an Examination system for a secondary school. The system captures the marks of students of the subjects they take and stores them in the database. from there, it has to compute the grades of marks for each subject that a student takes and get the position of that student in the stream and in the class.
For the gradeing part of it, I have already made it, my problem is to get the positions of students and show them on the rdlc report.
The word class and stream here, I mean;
The school has six classes, senior one/form one TO senior 6/form 6 as classes and each class(form) for example senior one has 4 streams. By streams, I mean; Students are grouped into different streams but under one class(level/form).
for example; form1 A TO Form 1 D that is one class/form secondary level. form 2 also has four streams ( form 2A, 2B, 2C, 2D) and so on. So a student can be number one in his stream but if the marks are compared to other streams of thesame level, he is number 3. it is indicated on the report as Position in Stream 1...........Class 3
View 8 Replies