Re: No smooth transition to the next form
From: Hari (Hari_at_discussions.microsoft.com)
Date: 11/25/04
- Next message: Hari: "Re: User can change date format in ppc?"
- Previous message: Eric: "How to pinvoke RTC API in .NET CF C# code?"
- In reply to: Dan Bass: "Re: No smooth transition to the next form"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Nov 2004 20:25:02 -0800
Dear Dan,
Thank you for your valuable suggestions & code. I'll try it out and if
there is any problem, I will let you know about it.
sample contents of a text file
==================
CODE APPLE
CODE ORANGE
CODE GRAPES
I am reading the textfile line by line. Then I'll extract the word APPLE
and concatenate with 60 blank spaces and then concatenate the CODE in the
same string after the blank spaces. Then I will add the entire string as an
item in the combo.
My intention is to hide the CODE from the user, so i am adding 60 blanks.
Only the word APPLE gets displayed in the combo. If an option get selected
in the combo, then i will read the combo.text() and using the substring()
method, i will extract the CODE after the blank spaces and write it to a file.
Out of the 7 textfiles, 5 have the above format.
So using your idea in a different way, I can achieve it.
If there is any better way, please inform me.
Thank you so much,
Hari
"Dan Bass" wrote:
> Hari,
>
> If all the text file contents are going to be < 50kb, then I'd firstly have
> some static buffer in the Form...
>
> static string textBuffer1 = null;
> static string textBuffer2 = null;
> ...
> static string textBuffer7 = null;
>
> then in your Form_Load event do this:
>
> LoadControlFromFile ( out textBuffer1, textFilename1, comboBox1 );
> LoadControlFromFile ( out textBuffer2, textFilename2, comboBox2 );
> ...
> LoadControlFromFile ( out textBuffer7, textFilename7, comboBox7 );
>
> where we define this method LoadControlFromFile as:
>
> void LoadControlFromFile ( string out fileBuffer, string filename,
> ComboBox combo )
> {
> if ( fileBuffer == null )
> {
> if ( File.Exists (filename) )
> {
> StreamReader reader = File.OpenText ( filename );
> fileBuffer = reader.ReadToEnd();
> reader.Close();
> }
> else
> {
> combo.Items.Add ( "file not found" );
> return;
> }
> }
>
> //
> // now use fileBuffer to populate combo
> //
> }
>
>
> I'm not sure how you're populating your combo boxes but you get the idea.
> Now I'd ensure the user closes the form with the OK button in the top right,
> and then when the onload loads a second/third/forth/.... time nothing will
> be loaded from any files, and you'll find the combo boxes will be
> repopulated far faster so that the transistion should be smooth.
>
> You could even move this to a public static method on the form so that when
> your application loads, the main thread calls this and creates the buffers
> before the user creates the form.
>
> Does that make sense? Let me know if you need more help.
>
> Dan.
>
>
>
>
>
> "Hari" <Hari@discussions.microsoft.com> wrote in message
> news:F4CC937B-40C1-405A-804F-18F80C6C22FC@microsoft.com...
> > Dear Dan,
> >
> > I will make it very clear. In a form, there are 7 combo boxes and one
> > save
> > button. The comboboxes are populated using 7 different text files, and
> > the
> > size of the biggest text file is 2kb. All other files have sizes around
> > 1+
> > kb.
> >
> > If the user clicks the Save button, some small text files are read and
> > saves
> > the data to a textfile, based on the contents of the combo boxes. And it
> > is
> > taking only a fraction of a second and the transition to the next form
> > happens smoothly.
> >
> > But the real problem happens when the user tries to close the form. The
> > above action(save operation) must be performed, even though the user is
> > closing the form. So I am calling the same function for Saving in the
> > Form_Closing Event.
> >
> > Till now, no problems. All saving operation happens within a fraction of
> > a
> > second in the Form_Closing Event.
> >
> > But after the Form_Closed event, the combo boxes loses their contents
> > permanently and the form object is disposed or not there. So whenever I
> > am
> > calling this form again, an exception is generated with the message that
> > no
> > object with that reference.
> >
> > Instead of avoiding the exception, I am creating a new instance of the
> > form
> > in the Form_Closed event itself and start populating the combos by reading
> > text files. After that, the next form is displayed.
> >
> > So anyway I have to create a new instance and populate the controls either
> > in the Form_Closed event or in the Form_Load event. In any case, it will
> > take time. But please remember, this situation happens only when the user
> > tries to close the form by clicking the OK button(Min. & Max. property set
> > to
> > false, so Ok button). If he is clicking the SAVE button provided by me,
> > then
> > save operation will be performed and transition happens as usual. (since
> > there is no need to create another instance).
> >
> > If the user tries to close the form, some flickering are happening and
> > some
> > part of the next form to be displayed gets displayed with around half of
> > its
> > size and the remaining half with the previous form. After 1+ second, the
> > second form will be displayed normally.
> >
> > So how to retain the reference of the form, even after it is closed and
> > when
> > it is called the next time, it should have all the items in the combo
> > boxes
> > without any additional operations.
> >
> > I can do it easily, by setting the minimize property of the Form to True.
> > So all the save operations will be performed and form hides/minimizes
> > after
> > the clicking the close button.
> >
> > But I wish to know whether it is a Standard Way to provide the Close
> > button
> > in the form and on clicking, actually saving is happening? Instead of
> > avoiding this, I am providing the Ok button.
> >
> > Regards,
> > Hari
> >
> >
> >
> > "Dan Bass" wrote:
> >
> >> Hari,
> >>
> >> From what I'm reading, I'm not sure where the problem lies...
> >>
> >> The transistion between forms is delayed because you're loading text
> >> files
> >> to populate your combo boxes.
> >> You can either:
> >> - creating a progress dialog that displays while your loading takes
> >> place
> >> so that you're providing feedback as to what is happening in your
> >> transistions
> >> - working loading all the necessary textfiles into static buffers
> >> (provided there isn't too much data in your files) when the application
> >> loads up (allowing you to display a splash screen while this is
> >> happening).
> >> This way when the user loads up a new form, all the data is at hand and
> >> doesn't need to be loaded, allowing populating the combo boxes to be far
> >> faster.
> >> - a slight deviation of the previous point, you could load your data
> >> into
> >> buffers in a seperate worker thread.
> >>
> >> Finally, I'm not sure you should be loading anything in your close event.
> >> If
> >> a form needs data for itself, it should be loaded in the load event
> >> handler... If you need to save out a lot of data from your form on close,
> >> then do this in the close event. Again if there is lots of data to save
> >> out
> >> a simple progress screen should suffice.
> >>
> >> Thanks.
> >>
> >> Dan.
> >>
> >> "Hari" <Hari@discussions.microsoft.com> wrote in message
> >> news:2ED87505-AC86-40C2-8B7B-F2D8CFBAD76A@microsoft.com...
> >> > Hi,
> >> > In one of the forms in my pocket pc application, i have set the max.
> >> > &
> >> > min. buttons to false, so that OK button will be displayed in the right
> >> > hand
> >> > top corner of the form and while clicking on that, it closes the form.
> >> >
> >> > Actually I am keeping a global reference of the form. On close, again
> >> > I
> >> > have to create a new instance of the form and assign it to the global
> >> > variable.
> >> >
> >> > In the form, there are 7 combo boxes, whose values are populated by
> >> > reading a text file. So when I am closing the form, the current
> >> > instance
> >> > is
> >> > lost and in the new instance, the contents of the combo box are
> >> > missing.
> >> >
> >> > So in the form.closed event, again i am reading 7 different text files
> >> > to
> >> > add contents to the combo boxes. Because of this, there is not a
> >> > smooth
> >> > transition to the next form.
> >> >
> >> > How can I solve this problem? If I am setting the minimize property
> >> > to
> >> > true, then the close button is displayed, and on clicking that, it
> >> > minimizes
> >> > the form and the instance is not lost and that way i can easily solve
> >> > the
> >> > problem.
> >> >
> >> > But I have verified most of the Windows default screens provided in
> >> > the
> >> > pocket pc and found that Microsoft is using OK button in the right hand
> >> > top
> >> > corner of most of the forms. So I followed the standard way. Also I
> >> > have
> >> > to
> >> > save some information before closing the form. If I am displaying the
> >> > close
> >> > button, the user gets an impression that the form is closed without
> >> > saving
> >> > the information.
> >> >
> >> > Awaing your valuable suggestions.
> >> > Thanks in advance,
> >> >
> >> > Regards,
> >> > Hari
> >> >
> >>
> >>
> >>
>
>
>
- Next message: Hari: "Re: User can change date format in ppc?"
- Previous message: Eric: "How to pinvoke RTC API in .NET CF C# code?"
- In reply to: Dan Bass: "Re: No smooth transition to the next form"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|