Registry Repository


Author
Message
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Hi friends, can u explain how to use that control?

Thanks...   BigGrin

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, Ricardo,

Start by dropping an instance onto a form.  It should appear down at the bottom in the "components" region of the form. 

Then, simply set the RegistryKey property on it.  This needs to be the full path to the registry key like this: "HKEY_LOCAL_MACHINE\Software\Ricardo"

Then, use the methods on the component to get/set the values within that registry key.  It essentially allows to create/read registry values with a single line of code rather than having to use the objects within the Microsoft.Win32 namespace.

Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Thanks Ben, I will try...
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Yo friends after work i get to this:

On the form I found a property called RegistryRepositoryKey

I put this value HKEY_LOCAL_MACHINE\SOFTWARE\teste

Then i went to the register and create that key "teste" (test for u texan people) Smile

I put that on the form_load method:

Me.Width = RegistryRepository1.ReadInt32((Me.RegistryRepositoryKey), "form1_width", 5)

Then, 5 new values appear: SF_FormHeight, SF_FormState, SF_FormWidth, SF_FormX, SF_FormY and the best is that it works, after running the solution and moves the form to a diferent place on a screen, it saves diferent values, and after running again, the form starts in the previous position.

So far, so good, all okidoki, but that makes me thought.. I need to create a key for every form. If the aplication is going to run on my machine only.. ok.. but.. it's not.. so after all that here comes the question:

Is that a way, maybe inside a "if ... then" code to check if the key already exists? if not:

let the form auto create the key, maybe with HKEY_LOCAL_MACHINE\SOFTWARE\teste\My Form Name or Text ?

if this is easy to write? Please post here, if not forget, i do not want to take your time...

Thanks.

 

 


Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
In fact i saw theres no need of this line on the form load...

Me.Width = RegistryRepository1.ReadInt32((Me.RegistryRepositoryKey), "form1_width", 5)

And setting the property on the form of the key, creates the values.. but the other question still persist... BigGrin

Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Yo, another thing i created more 2 forms and insert this code to open the form, on the load of the first form:

Form3.Show()

Form4.Show()

I created the keys in the register too.

But only the form1 saves the new values to the form. If i change the startup form on the AppMain to form3 then it saves the values to the register. What is wrong? w00t


Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
But only the form1 saves the new values to the form. If i change the startup form on the AppMain to form3 then it saves the values to the register. What is wrong?

Saves the form3 values not the other form's values, I forgot to write..

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Hey Ricardo...here is how it works:

When you set the RegistryRepositoryKey on a form it will update based on three other properties:

RememberFormLocation
RememberFormMaximizedState
RememberFormSize

If you have all of this set, then you will see a total of 5 registry values added to the registry key you provide.

Since this is automated, you will have to provide a unique registry key for each form whose position, size, etc. you want remembered.  If you want to automate the registry key, you could write a shared class method that dynamically sets this property.  For example:

Me.RegistryRepositoryKey = GenerateRegistryKeyValue(Me.Name)

or maybe something like this:

Me.RegistryRepositoryKey = "HKEY_LOCAL_MACHINE\SOFTWARE\teste\" & Me.Name

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Trent.

We created a class with a shared function and then we are calling it passing the form name ...

It works great. All the forms have a good memory now ... I wish we did too. Tongue

One thing, we noticed that if it is not an MDI application, and the main form calls some other not modal forms, if the main is closed, the others all get closed but the registry is not saved.

Thanks.

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
This is most likely because the called forms are not raising their Closing event (the code to save the values to the registry is in the OnFormClosing method).  I'll check into this, but if the event is not being raised, we might not be able to fin another place to attach the code.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search