Καλώς ορίσατε στο dotNETZone.gr - Σύνδεση | Εγγραφή | Βοήθεια
σε

 

Αρχική σελίδα Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες

Morfopoiisi programmatos!

Îåêßíçóå áðü ôï ìÝëïò Thanasis. Τελευταία δημοσίευση από το μέλος Χρήστος Γεωργακόπουλος στις 30-12-2005, 12:10. Υπάρχουν 2 απαντήσεις.
Ταξινόμηση Δημοσιεύσεων: Προηγούμενο Επόμενο
  •  30-12-2005, 09:41 8238

    Morfopoiisi programmatos!

    Kalimera & Xronia Polla se olous,

    Tha ithela na sas rotiso pos einai dunato se ena programma se VB.NET 2003, to opoio tha trexei se periballon MS Windows XP ta controls na exoun tin morfi ton control ton windows. Diladi na einai pio strogulemena stis akres kai ta buttons (kai oxi mono auta) na moiazoun me ta buttons ton Windows XP. Na einai XP like kata kapoio tropo. Pros to paron stro programma pou exo ftiaksei moiazoun me to periballon to Windows 98.

    Euxaristo & Kales Giortes se olous!
  •  30-12-2005, 11:50 8250 σε απάντηση της 8238

    Απ: Morfopoiisi programmatos!

    Για να ενεργοποιήσεις τα XP Themes (αυτό ζητάς) αρκεί να καλέσεις το Application.EnableVisualStyles() όταν ξεκινάει η εφαρμογή σου,  όπως παρακάτω:

    <System.STAThread()> _
            Public Shared Sub Main()

                System.Windows.Forms.Application.EnableVisualStyles()
                System.Windows.Forms.Application.Run(New Form1)
            End Sub 'Main

    Επιπλέον, θα πρέπει σε όσα control έχουν την ιδιότητα FlatStyle να βάλεις  FlatStyle.System.


    Επίσης, καλό είναι να γράφεις στα ελληνικά. Τα greeklish είναι πολύ πιο δύσκολα στο διάβασμα, ειδικά αν σκεφτείς ότι τα περισσότερα μέλη εργάζονται και κοιτάνε το email τους που και που στα γρήγορα για να δουν τί νέα posts υπάρχουν. Ένα ευανάγνωστο post θα απαντηθεί μέσα σε λίγα λεπτά, ένα δυσανάγνωστο θα περιμένει μέχρι το βράδυ για να το διαβάσει κάποιος με την ησυχία του ...


    Παναγιώτης Καναβός, Freelancer
    Twitter: http://www.twitter.com/pkanavos
  •  30-12-2005, 12:10 8251 σε απάντηση της 8238

    Απ: Morfopoiisi programmatos!

    Το Application.EnableVisualStyles() πρέπει να ακολουθείται κατ' ευθείαν από ένα Application.DoEvents(), αλλιώς μπορούν να παρουσιαστούν πολλά προβλήματα. Περισσότερα μπορείς να βρείς και στο blog του Raghavendra Prabhu:

    Q I sometimes have weird problems with Application.EnableVisualStyles. Some controls don't seem to pick up theming; images that are assigned to TreeView nodes or ListView items sometimes don't render at all. However, when I use a manifest, I don't see these problems.

    Yes, this is a known issue with the implementation of Application.EnableVisualStyles. The reason for this is as follows. As I mentioned before, the activation context is setup around the application's message loop. So any comctl32 handles created after the message loop is setup will be correctly redirected to v6.0. However, when you have the following code in Main:

    Application.EnableVisualStyles();
    Application.Run(new Form1());

    Form1 is constructed before the message loop is setup. Therefore, any handle created in Form1's constructor code will result in that control being bound to v5.8 instead of v6.0, since the activation context has not yet been setup. This isn't as bad as it may sound, since in most cases, we delay handle creation as much as possible, so control handles aren't typically created in InitializeComponent. One rather common exception is the Imagelist - it turns out that in many cases, the Imagelist's handle is created in InitializeComponent, so you get a v5.8 imagelist that doesn't interop well with v6.0 controls on XP (on Windows Server 2003, the v5.8 imagelist does interop well with v6.0 controls, so you won't see this problem on that platform), the result being that the images don't show up. There are also some cases where some other control handles may get created early, in which case, those controls too will get bound to v5.8 and will not appear themed. We are obviously planning to fix this in the future, but for now, there are several workarounds that customers have used successfully. I list some of them here for reference:

    • Include a call to Application.DoEvents() before Application.Run().
    • Move the erring code (that causes handle creation to happen) from InitializeComponent to the Form's Load method.
    • Use a manifest!

    Note that the above discussion applies only to the app's "Main Form", i.e., the Form that is passed to the Application.Run. Forms that are instantiated after the message loop is setup will be constructed after the context is activated, so code in their constructors shouldn't face this problem.


    Χρήστος Γεωργακόπουλος
Προβολή Τροφοδοσίας RSS με μορφή XML
Με χρήση του Community Server (Commercial Edition), από την Telligent Systems