WinXP themes without manifest!

Discussion in 'C#' started by shabbir, Dec 5, 2006.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83

    Introduction



    Whenever you generate a new C# Windows Application using the .NET IDE you have the following lines in the main of your program in program.cs file. Did you ever try to note what are these and what do they do. If not I will explain to you the meaning of each line.

    Code:
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault( false );
    Application.Run(new Form1());

    EnableVisualStyles



    EnableVisualStyles(); enables you with the XP Look and feel to your application. Just to test try adding some common controls like button, progress bar to the form using the designer and compile and run the program. You will see that they are having XP look by default but you dont have any manifest files as was the case for the legacy languages like MFC. Now try commenting the above line and you will see that your application is to the normal non - XP look application. You will see the difference only in XP but probably not in 2k as it does not have any custom theme but I have not tested this would look for some of your input.

    SetCompatibleTextRenderingDefault



    SetCompatibleTextRenderingDefault(false); enables you with the correct rendering of text in various RTL languages. To see what it does follow the following steps.

    1. Add label to the form that is generated.
    2. Set the Text of the label as 4 x 4.
    3. Set the RightToLeft property to Yes.

    Run the application.

    Now comment SetCompatibleTextRenderingDefault(false); and Run the application.

    You will see the text as x 4 4. The problem is when SetCompatibleTextRenderingDefault(false); is commented and RightToLeft is true C# application cannot render correctly the mixed character set like arabic numbers as well as english characters. x is english and 4 is number.

    Run



    Run(new Form1()); creates an object of your main form and runs it. I would not go into the details of the form events and component initialization here.
     
  2. yogesh shrikhande

    yogesh shrikhande New Member

    Joined:
    Apr 14, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    plz tell me with out use of .net tell me how in vc++6
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    This is .net way of doing but for VC you have the manifest file. Check [thread=754]Windows XP Style controls in your MFC/WIN32 Applications[/thread].
     
  4. yogesh shrikhande

    yogesh shrikhande New Member

    Joined:
    Apr 14, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    i dont want to use manifest file in vc++ any other method
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Not sure but any specific reason why you dont want to be using that. You dont need to have the file with the executable when running the app though. Its just at dev time.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice