|
This really is an application-specific problem. Explorer's ListView (the common control 6 ListVew32) uses a system image list and many, many other things to query files type handlers for a certain interface (IThumbnailCapture ) which returns an image that it stores in a cache (in this case, a hidden system file named thumbs.db).
For your application, you could do something similar, although using the default controls leave much to be desired (not everything from Windows' common controls is wrapped in the .NET equivalents).
Get thumbnails for your ListViewItem s, add them to the ListView 's LargeImageList property, and then set the appropriate ListViewItem s' ImageIndex property to the index in which the thumbnail was inserted. In effect, these become the icons for the ListViewItem s.
Unfortunately, if you want the thumbnail view that Explorer boasts, it won't be an easy task. First, you must make sure your application is bound to common controls 6 (in .NET 1.1, call Application.EnableVisualStyles before calling Application.Run in your program's entry point, Main ), or use a manifest file (see my article list for an article that describes it). Then you'll have to P/Invoke lots of Win32 native functions and override a lot of functonality. Not fun.
I hope at least I gave you some idea of what Explorer does for the functionality you want. Again, though, it's really up to you about how to do it since you control the code in your app.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have an application that connects to a database where the user has to log in to access the app. The login screen is the first screen the user encounters and requires the user to enter username/psswd info along with database info (i.e. database name, server name, etc...). I want to set it up so that when the app is run it will pull up the info entered by the user from the last time. What is the best way to approach this? I thought of XML serialization, but as I understand it, this is not a secure method and therefore passwd info should not be stored in passwd file. I already make a database connection in this form, so if I could I would like to store this data in the database, but I cannot make the connection string until the user enters that info. I suppose I could do the mix of the two, but how will that affect performance? Any one have thoughts.
Thanks in advance.
|
|
|
|
|
Why don't you just write it to the registry using an Encryption algorithm?
|
|
|
|
|
Using the registry is not recommended for .NET applications. Instead (to the original poster) you can still encrypt the password and save it to the .config file (named yourappname.exe.config) either in the <appSettings> or to your own section that you can create using an implementation of IConfigurationSectionHandler . Using .config files is far more robust for .NET apps because it centralizes application settings.
The idea would still be the same, though, and there's many ways to accomplish the task.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Storing (and ESPECIALLY retrieving) a password is never secure. Why would you want to retrieve the password from a file? You should never have to retrieve a password, it should always be given to you by the user.
|
|
|
|
|
I'm not a security expert, but there's one thing I've picked up...
In general, you should never store a password. I think it's a bad idea to even store an encrypted one. If you store an encrypted one and your keys are compromised, decrypting it is trivial.
Store the hash of a password and "salt" that hash. It's preferable to have your salt have something in it that varies per user. Assuming the user-list and password hash is compromised, salting prevents a hacker from gaining easy entry. Having your salt have something unique per user in it prevents comparing a known account with a known password and finding another account with that same password.
Then hash what they input and check it against the stored hash.
Do a search for hash's and salt for some more info.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I try to retrieve the bitmap displayed in a static control with a call to appropriate windows API.
I get a non zero bitmap handle, but the following code generate the exception reported.
imageHandle= SendMessage (handle,STM_GETIMAGE,IMAGE_BITMAP,0);
Bitmap bitmap = Bitmap.FromHbitmap(imageHandle);
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
What's the problem?
thanks.
|
|
|
|
|
Why is your managed app getting a handle to an image using SendMessage ? I assume the image is in a native control? Is it in another application apart from yours? If so, handles are not valid across application boundaries.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Yes, im trying to get the icon of a label control (Static) belonging to
a dialog popped up by another app.
Window handle remains valid across application context, i'm able to
enumerate all the components contained in dialogs owned by other applications
and get all their properties, but every thing fails when i try to access images.
There's a way to have managed code to access other application contexts?
thanks.
|
|
|
|
|
|
Roger J wrote:
since it is free i hope i wont get too flamed for this ..
As long as the code is free, its ok, you are under obligation to submit an article within the next 90 days.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Just an FYI:
You should take a look at that page with the Mozilla 1.5 browser. It gets really screwed up.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
What is an easy way to change a return key to act like the tab key in a c# windows application for all controls on a windows form?
|
|
|
|
|
You could handle the Control.KeyDown event and use SendKeys.Send to send a tab:
this.myForm.KeyPreview = true;
this.myForm.KeyDown += new KeyEventHandler(this.myForm_KeyDown);
private void myForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.Handled = true;
SendKeys.Send("{TAB}");
}
} There's other ways through P/Invoking PostMessage , but doing it this way should work and keeps all your code managed.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you for your reply.
I had tried this, but I tried it again (using the designer and adding the code to check: if(e.KeyCode == Keys.Enter) and what I found again was that this only seems to work if you place the _KeyDown check for each control rather than at the form level. Is there a way to trap the key stroke globally since setting the: [this.myForm.KeyPreview = true;this.myForm.KeyDown += new KeyEventHandler(this.myForm_KeyDown);] does not seem to do it?
|
|
|
|
|
That's why I included myForm.KeyPreview = true in my example code.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you again for your response.
I tried as you suggested (the code you suggested is generated by the .NET studio by changing KeyPreview in the form properties to the "True" value) and the same result occured ... the return key was not trapped and the cursor did not advance to the next tab field. The following code was generated:
this.KeyPreview = true;
where "this" is the form.
When I changed the event handler for each field to access the function "GlAcctMaster_KeyDown", it worked fine. It generated the following code:
this.Text_Description.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GlAcctMaster_KeyDown);
I much appreciate your responses.
|
|
|
|
|
Im looking for a way to unblock a Socket when then Accept() i called.... I´ve been looking at setSocketOption() but can´t get it to work.
Hope that someone can help me..
Thanks in advance
Søren Christensen
|
|
|
|
|
First use the SetSocketOption to have a timeout as such.
YOURSOCKET.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 10000);
(The third paramater is the timeout in Milliseconds)
Then put the Accept in a Try/Catch block because if it does time out it will cause a SocketException.
|
|
|
|
|
I´ve tried that, but it still doesn´t work, the exception is newer thrown...
<br />
listeningSocket.SetSocketOption( SocketOptionLevel.Socket, <br />
SocketOptionName.ReceiveTimeout, 10000 );<br />
<br />
try<br />
{<br />
connection = listeningSocket.Accept();<br />
}<br />
catch( SocketException )<br />
{<br />
}<br />
<br />
can you see any error?
Søren
|
|
|
|
|
I'm trying to make a call on a singleton remoting object
that is running using tcp channel.
I get the Transparent Proxy using Activator.GetObject
with no problems when I make the first call on the
remoting object.
This is part of the exception i get.
_remoteStackTraceString
=======================
_remoteStackTraceString "\nServer stack trace:
\n at
System.Runtime.Serialization.Formatters.Binary.BinaryAssem
blyInfo.GetAssembly()\r\n at
System.Runtime.Serialization.Formatters.Binary.ObjectReade
r.GetType(BinaryAssemblyInfo assemblyInfo, String name)
\r\n at
System.Runtime.Serialization.Formatters.Binary.ObjectMap..
ctor(String objectName, String[] memberNames,
BinaryTypeEnum[] binaryTypeEnumA, Object[]
typeInformationA, Int32[] memberAssemIds, ObjectReader
objectReader, Int32 objectId, BinaryAssemblyInfo
assemblyInfo, SizedArray assemIdToAssemblyTable)\r\n at
System.Runtime.Serialization.Formatters.Binary.ObjectMap.C
reate(String name, String[] memberNames, BinaryTypeEnum[]
binaryTypeEnumA, Object[] typeInformationA, Int32[]
memberAssemIds, ObjectReader objectReader, Int32
objectId, BinaryAssemblyInfo assemblyInfo, SizedArray
assemIdToAssemblyTable)\r\n at
System.Runtime.Serialization.Formatters.Binary.__BinaryPar
ser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped
record)\r\n at
System.Runtime.Serialization.Formatters.Binary.__BinaryPar
ser.ReadObjectWithMapTyped(BinaryHeaderEnum
binaryHeaderEnum)\r\n at
System.Runtime.Serialization.Formatters.Binary.__BinaryPar
ser.Run()\r\n at
System.Runtime.Serialization.Formatters.Binary.ObjectReade
r.Deserialize(HeaderHandler handler, __BinaryParser
serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)\r\n at
System.Runtime.Serialization.Formatters.Binary.BinaryForma
tter.Deserialize(Stream serializationStream,
HeaderHandler handler, Boolean fCheck, IMethodCallMessage
methodCallMessage)\r\n at
System.Runtime.Remoting.Channels.CoreChannel.DeserializeBi
naryRequestMessage(String objectUri, Stream inputStream,
Boolean bStrictBinding, TypeFilterLevel securityLevel)
\r\n at
System.Runtime.Remoting.Channels.BinaryServerFormatterSink
..ProcessMessage(IServerChannelSinkStack sinkStack,
IMessage requestMsg, ITransportHeaders requestHeaders,
Stream requestStream, IMessage& responseMsg,
ITransportHeaders& responseHeaders, Stream&
responseStream)\n\nException rethrown at [0]: \n"
string
stackTraceString
================
_stackTraceString " at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMess
age(IMessage reqMsg, IMessage retMsg)\r\n at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke
(MessageData& msgData, Int32 type)\r\n at
TAM.Data.Common.IPortal.Fetch(Object businessObject,
Object criteria)\r\n at TAM.Framework.Portal.Fetch
(Object businessObject, Object criteria) in
c:\\sourcecode\\tam\\tam.framework\\portal.cs:line 86"
string
_message
========
_message "Cannot find the assembly
TAM.BusinessObjects, Version=1.0.1424.15601,
Culture=neutral, PublicKeyToken=d3e3ed99c018e29a."
string
It keeps wanting to find the assembly that has the
BusinessObjects in even though I'm sending the object as
object type.
Is this a problem with my objects Deserialization or why
does the remoting need my assembly when it can get the
type from the object?
Any comments or help appreciated.
MickD
Mick D
|
|
|
|
|
When you use remoting you have to pass in the EXACT same copy of the class.
|
|
|
|
|
thanks.
ok, I have tried that (using the exact object) and it made no difference, from the exception that I still get. There is stack information against the property "_remoteStackTraceString" which presumably means that the object got to the remote object?? and cannot be unpacked (Deserialized). I cannot remember the sequence that remoting\channels performs when recieving information from another App domain.
Any comments or help appreciated
Mick D
|
|
|
|
|
Are you sure you are recieving the entire class before you try to Deserialize it because the TCP protocol has no bounds checking.
|
|
|
|
|
Hi,
can anybody tell me if what im doing here is correct?
Having 2 DataGrid Controls, one showing data from "ParentTable", the other showing data from "ChildTable", I am trying to synchronize them in a way that when I select a Row in the Child- DataGrid, the Parent- DataGrid should be updated too (dv2 is the DataView of the Parent-DataTable):
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)<br />
{<br />
CurrencyManager cm = (CurrencyManager)<br />
dataGrid1.BindingContext[dataGrid1.DataSource ,dataGrid1.DataMember];<br />
<br />
DataRowView drv = (DataRowView)cm.Current; <br />
// Set the RowFilter of the ParentTable-View to reflect changes in Child
<br />
dv2.RowFilter = "VERNR = '"+drv["VERNR"]+"'"; <br />
<br />
}
|
|
|
|