From wormhole fly
After risisi reader enables XP, the interface is still harmonious.
In Windows XP and later versions ,. net Framework 1.0 and 1.1. net winform enables XP style, simply calling application. enablevisualstyles (); there are many problems, especially the problem that the toolbar icon cannot be correctly drawn.
There are three methods to solve the bug of this framework:
- After application. enablevisualstyles () is executed, run application. enablevisualstyles () directly, for example:
/// <Summary>
/// Main entry point of the application.
/// </Summary>
[Stathread]
Static void main ()
{
Application. enablevisualstyles ();
Application. doevents ();
Application. Run (New Form ());
}
- Enable a thread to run the program:
/// <Summary>
/// Main entry point of the application.
/// </Summary>
[Stathread]
Static void main ()
{
Application. enablevisualstyles ();
New thread (New threadstart (runner). Start ();
}
Static void runner ()
{
Application. Run (New Form ());
}
- Enable. Manifest: Enable the. manifest file in the application directory.
Risisi reader is the first type, but during the running process, a system exception is thrown from time to time, and then a program is launched directly. At first, I didn't realize that it was a problem caused by enabling the XP effect. After I followed it and couldn't tell the result, I simply checked the exception details, as shown below:
System. runtime. interopservices. sehexception: An exception occurs for the external component.
At system. Windows. Forms. unsafenativemethods. dispatchmessagew (MSG & MSG)
At system. Windows. Forms. componentmanager. system. Windows. Forms. unsafenativemethods + imsocomponentmanager. fpushmessageloop (int32 dwcomponentid, int32 reason, int32 pvloopdata)
At system. Windows. Forms. threadcontext. runmessageloopinner (int32 reason, applicationcontext context)
At system. Windows. Forms. threadcontext. runmessageloop (int32 reason, applicationcontext context)
......
Google system. runtime. interopservices. sehexception. The conclusion is that the XP performance is improperly enabled. Immediately change to the third type. Add risisi.reader.exe. manifest in the application directory:
<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
<Assembly
Xmlns = "urn: Schemas-Microsoft-com: ASM. V1"
Manifestversion = "1.0">
<Assemblyidentity
Version = "1.0.0.0"
Processorarchitecture = "x86"
Name = "risisi. Reader"
Type = "Win32"/>
<Description> risisi. Reader </description>
<Dependency>
<Dependentassembly>
<Assemblyidentity
Type = "Win32"
Name = "Microsoft. Windows. Common-Controls"
Version = "6.0.0.0"
Processorarchitecture = "x86"
Publickeytoken = "6595b64144ccf1df"
Language = "*"/>
</Dependentassembly>
</Dependency>
</Assembly>
Solve the problem immediately.
. NET Framework 2.0 does not have a specific test, but in 2.0, the winform interface is automatically processed as office 11, and this bug should not be found. About.
Trackback: http://tb.donews.net/TrackBack.aspx? Postid = 571328