473,785 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Window recreation on theme change

The short version is that when the theme is changed my application barfs.

The problem is a control I've created to host the WebBrowser control and
implement all the com callbacks for browser customisation. The problem only
occurs when it's present.

I'll fix it, but first I need detailed info on exactly what happens to a
winform when the theme changes. It seems to me that the native window would
have to be recreated to pick up the new window style, and there are
undoubtedly various messages flying around that my control ought to respond
to.

Obviously I want to handle this in my control rather than on the form. Other
controls get re-themed, so obviously they get notified somehow and I ought
to be handling this notification... I don't suppose there's an OnThemeChange
or OnRecreateNativ eWindow event...?

And having detected the change, what are the responsibilitie s of a control
at this point?
Nov 16 '05 #1
5 2861
There is a notfication WM_THEMECHANGED and the form seems to be handling it.

When the exception occurs the call stack is very short, it looks like the
DNF is invoking System.Windows. Forms.MessageBo x.ShowCore() and passing it a
null reference.

Naturally the ShowCore() method is about as well documented as my bum.
Nov 16 '05 #2
It only barfs if my wrapper is installed:

(IE.GetOcx() as IOleObject).Set ClientSite(this as IOleClientSite) ;

Setting

(IE.GetOcx() as IOleObject).Set ClientSite(null );

Makes the problem go away - but of course you lose all the benefits of the
wrapper.
Nov 16 '05 #3
I tried hooking WM_THEMECHANGED in WndProc and disconnecting from the
browser. To reconnect I send myself a message using BeginInvoke() to call
the method that installs my control as the client site of the browser
object.

It no longer dies but the browser has a tantrum when I try to use it.

I tried creating a new browser and setting that up. It hooks up and does
callbacks (I can tell because it changes its border in accordance with the
host settings) but it has a tantrum when I try to call Navigate();
Nov 16 '05 #4
Built myself a test harness: I send the WM_THEMECHANGED message to the form
myself using a button click event handler.

It works in the test harnes - I detach and send a message to reattach and it
all happens and Bob's your uncle. Except that it doesn't work when the
message is the real McCoy. I still get my NullReferenceEx ception.

What's REALLY puzzling is that I've discovered that the hWnd is constant
which implies that the window ISN'T being destroyed, so I'm blowed if I know
what's giving it indigestion.

Someone say something useful, I'm starting to freak out!

Next thing I'll try is putting the thread to sleep for say two seconds while
themes gets its act together.
Nov 16 '05 #5
Sleeping the thread doesn't work.
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5983
by: JeffP | last post by:
I want to add a short-cut to a windows app similar to launching from a windows run line a New window, to prevent changing an existing browser window from moving off a current logged in session to another web application. And, I'd like it to be a chromeless window, sans toobars and sized similar to a popup. TIA
1
5094
by: redneon | last post by:
I'm trying to add another button to a window's title bar to use as a "keep this window on top" button. I've managed to draw the button using the code below (C#) but I'm having a couple of other problems... .... private bool buttonChecked = false; private int buttonSize = 16; private int buttonX = 226; private int buttonY = 6;
0
3050
by: Chenghui Li | last post by:
We have a problem with the Windows XP theme: We have a IDE which allows other developers to develop visual programs for their customers. Our IDE allow them to set font for window captions easyly (through a dialog). It works fine fo W98, 2000, NT, and XP is the theme is Classic. But on XP if the theme is "Windows XP", the we have a problem: if the developer set the caption font to be say, "Script" (and all non-default font), then the...
9
1517
by: Just Me | last post by:
I need an image that agrees with the one shown at the right end of the title bar. That is, the image for the button that closes the window. I believe it changes with changes in the theme so I can't simply dup one. Any one know how I can, at run time, obtain the image currently being used?
7
4309
by: Terry Olsen | last post by:
I paste the following code into each project to get XP theme support. 'Add this at the beginning of any program to enable Windows XP Visual Styles <System.STAThread()> Public Shared Sub Main() If OSFeature.Feature.IsPresent(OSFeature.Themes) Then System.Windows.Forms.Application.EnableVisualStyles() End If Application.DoEvents() 'This must be here, otherwise buttons won't stylize System.Windows.Forms.Application.Run(New Form1) End Sub...
1
2242
by: kfc1976 | last post by:
Hi All, First of all, following are the facts 1) I've been trying to solve the following issue for the past 8 hours (Not Kidding) 2) If I can't find the answer, It will drive me completely crazy Platform: XP Pro, .net 2.0 FrameWork, Visual Studio 2005 Problem Regarding:
0
2227
by: vikramp | last post by:
Hi, I am storing theme in web.config using <pages theme="mytheme"/>. I am then using the following code to read it from my webpage: Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); PagesSection section = (PagesSection)config.GetSection("system.web/pages"); string currenttheme = section.Theme;
4
23279
by: jodleren | last post by:
Hi all I have a file I open in a smaller window, like this: <a href="#" onclick="window.open.... but it also causes the main window to jump to the top. What have people done to avoid that? BR
12
1521
by: Teresa Church | last post by:
Is there such a thing as defining a constant (or a variable) for a theme? For example, storing a color code and then using it in 4 or 5 places, so to change the color I only have to edit one line? TIA
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.