Discussion:
Change or Set the Classname of a wxWindow, possible?
(too old to reply)
Joerg Toellner
2009-05-07 10:09:09 UTC
Permalink
wxMSW 2.9.0, MSVC 2005, WinXP SP3

Hi wxGroup,

I have the following problem which i can't solve myself after testing for
hours now, and even can't find a matching answer in the internet.

What i want to do:

I want to use a third party DLL in my own wxApp. That dll sends some windows
messages when certain events occur (WM_USER+x). I have got a sample project
for a gui from the original Author that uses that dll, but the dll itself is
closed source and i only have a compiled binary. So i have to use the dll AS
IS, right out of the box.

Crossplatform is irrelevant for me in my wx project! It's win-only!

I know how to load and use a dll in my wxApp and I also know how to receive
windows messages in wx when they are sent to my wxWindow (frame).

But i want to replace the original gui and use my own wx gui instead,
because i need to add some more whistles and bells.

The Problem is:

The exported functions of the dll have no "notifywindowhandle" parameter or
something else, where i can specify my frame handle to act as the receiver
for the dll sent messages.

I inspected the dll a bit and found out, that the dll sends the messages
with the following functionality (Pseudocode):

hdl = FindWindow(<classname of the original window>)
SendMessage(hdl, ...blah)

As you see, the classname of the original gui is fix coded in the dll. :-(
Patching the dll strings i found, that are used in the FindWindow API call,
to represent my wxApp classname looks not as an option for me.

So the only way i see is, to let my frame (or another, maybe hidden, window
that forwards the messages to my frame) mimic the windowclass of the
original gui, so that my wxFrame will be found by FindWindow in the dll.

For that i need to specify the classname of the original gui app when
creating my frame (or another window). But i can't get this to work. :-(

I saw, that the last parameter in the constructor of e.g. wxFrame is
described as "name with that the window could be referenced later", as the
documentation says. BUT, whatever i pass in this parameter i everytime get a
window of class "***@0BCDEFNR" (or something like that) when the window
appears on the screen and i inspect the properties of this window with
Spy++. :-(

Question:
Is it possible, and if so how, to create a wxWindow with a specific
classname that registers in the windows OS with that classname, so that a
WinAPI-call to FindWindow with the classname as the given parameter will
find and return the handle to it?

It would help me much, if someone could point me in the right direction.
Thank you in advance for your effort and a reply. Any hint or enlightenment
is appreciated.

Greetings
Joerg
Vadim Zeitlin
2009-05-07 11:10:40 UTC
Permalink
On Thu, 7 May 2009 12:09:09 +0200 Joerg Toellner <***@oss-gmbh.de> wrote:

JT> I inspected the dll a bit and found out, that the dll sends the messages
JT> with the following functionality (Pseudocode):
JT>
JT> hdl = FindWindow(<classname of the original window>)
JT> SendMessage(hdl, ...blah)

If the DLL hard codes the class name of the window it probably has good
reasons to do it. I.e. it might expect it to behave in some particular way
in which wxWindow will not behave. IOW I think that you won't succeed in
making it to work by just changing the class name.

JT> So the only way i see is, to let my frame (or another, maybe hidden, window
JT> that forwards the messages to my frame) mimic the windowclass of the
JT> original gui, so that my wxFrame will be found by FindWindow in the dll.

The hidden window approach would probably be best. Like this you can keep
all the DLL-related hacks completely separate.

JT> I saw, that the last parameter in the constructor of e.g. wxFrame is
JT> described as "name with that the window could be referenced later", as the
JT> documentation says. BUT, whatever i pass in this parameter i everytime get a
JT> window of class "***@0BCDEFNR" (or something like that) when the window
JT> appears on the screen and i inspect the properties of this window with
JT> Spy++. :-(

This name is completely different from the Windows window class name.
There is no provision for specifying the names of the class name in wxMSW
and I don't think this is a generally useful feature so you can only patch
your version of wx to do it. But, again, using a separate window is a
better idea.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Joerg Toellner
2009-05-07 11:55:53 UTC
Permalink
Dear Vadim,

Thank you for your early reply.

No, the dll has no good reason. It's just a problem of "programmer thinked
too short" :-) It only sends a "Work finished" message, when it has done
it's job. There are more messages from the dll, but i am only interested in
this single one.

But as it's not possible within wx to set classname, i have either to go the
hard WinAPI-Windows-Way (EEEK! :-) ) or i just came across another idea. As
i only need to know when the dll finished its work and there is a window
open (and/or a seperate process running), i can scan the window- or
process-list of the OS to see when the window/process vanish. Need a wxTimer
and polling, but maybe a more clear and clean way. And so i don't need any
messages from the dll anymore.

But thanks for clarifying this "name" misunderstanding anyway.

Greetings
Joerg

-----Ursprüngliche Nachricht-----
Von: wx-users-bounces+toellner=oss-***@lists.wxwidgets.org
[mailto:wx-users-bounces+toellner=oss-***@lists.wxwidgets.org] Im
Auftrag von Vadim Zeitlin
Gesendet: Donnerstag, 7. Mai 2009 13:11
An: wx-***@lists.wxwidgets.org
Betreff: Re: Change or Set the Classname of a wxWindow, possible?

On Thu, 7 May 2009 12:09:09 +0200 Joerg Toellner <***@oss-gmbh.de>
wrote:

JT> I inspected the dll a bit and found out, that the dll sends the
JT> messages with the following functionality (Pseudocode):
JT>
JT> hdl = FindWindow(<classname of the original window>)
JT> SendMessage(hdl, ...blah)

If the DLL hard codes the class name of the window it probably has good
reasons to do it. I.e. it might expect it to behave in some particular way
in which wxWindow will not behave. IOW I think that you won't succeed in
making it to work by just changing the class name.

JT> So the only way i see is, to let my frame (or another, maybe hidden,
JT> window that forwards the messages to my frame) mimic the windowclass
JT> of the original gui, so that my wxFrame will be found by FindWindow in
the dll.

The hidden window approach would probably be best. Like this you can keep
all the DLL-related hacks completely separate.

JT> I saw, that the last parameter in the constructor of e.g. wxFrame is
JT> described as "name with that the window could be referenced later",
JT> as the documentation says. BUT, whatever i pass in this parameter i
JT> everytime get a window of class "***@0BCDEFNR" (or something
JT> like that) when the window appears on the screen and i inspect the
JT> properties of this window with
JT> Spy++. :-(

This name is completely different from the Windows window class name.
There is no provision for specifying the names of the class name in wxMSW
and I don't think this is a generally useful feature so you can only patch
your version of wx to do it. But, again, using a separate window is a better
idea.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Steve Cookson
2009-05-07 13:14:52 UTC
Permalink
Hi,

I am developing a medical application for use in a semi-darkened room and I
want to change the default control colours away from the platform defaults
(eg on windows, I don't want an inappropriately bright XP-blue title bar).
Is there some way I can alter the defaults for my application only for:

- Title bars (I am happy to suppress the title bar, if that is available),
- Status bars,
- Button surrounds,
- Notebook tabs,

Etc etc etc,

I have tried using the background and foreground colours both at window and
control level, but this doesn't appear to alter these properties.

Thanks

Steve
Julian Smart
2009-05-07 16:44:28 UTC
Permalink
Hi Steve,
Post by Steve Cookson
I am developing a medical application for use in a semi-darkened room and I
want to change the default control colours away from the platform defaults
(eg on windows, I don't want an inappropriately bright XP-blue title bar).
- Title bars (I am happy to suppress the title bar, if that is available),
Unfortunately these can't be changed as they're under OS control. But
you can suppress it and if necessary, use a window to fake a title bar
(handling window moving yourself).
Post by Steve Cookson
- Status bars,
Changable I think...
Post by Steve Cookson
- Button surrounds,
I think the button border will remain a light colour, but the background
and (active) text colour is settable with SetBackgroundColour and
SetForegroundColour.
Post by Steve Cookson
- Notebook tabs,
I don't seem to be having any success changing the colours for
wxNotebook, unfortunately, even when passing wxNB_NOPAGETHEME to the
notebook. You might have more success with wxAuiNotebook, or at least
you'll be able to hack the code since it's generic.

Regards,

Julian

Loading...