wxWindow from HWND?

C. Iacob wrote:
> Hi,
>
> does it exist the reverse of wxWindow::GetHandle()? Something like
> wxWindow* wxWindow::FromHandle(void*)
> ?

[Robin Dunn ]There is wxWindow_FromHWND(hWnd) but as I mentioned a couple weeks ago I'm not totally convinced that I've implemented it correctly. Let me
know how it goes.

It seems to work if the hwnd belongs to a wxWindow. But it doesn't work when the hwnd belongs to a window which was not created using wxPython.

Example: I debug a C++ app which works under AutoCAD. This way I can see which is the handle (e.g. 1277448) of the main frame of AutoCAD. Having the same AutoCAD session open, I hardcode a simple wxPython test:

                 w = wxWindow_FromHWND(1277448)

The result is a message box: "window.cpp(1023): invalid HWND".

Hm... do I try to mix completely different things which shouldn't be mixed? However I wish I could to pass the AutoCAD's main frame as a parent to a wxPython dlg...

Thanks,

Cristina.

···

-------------------------------------------------------
Xnet scaneaza automat toate mesajele impotriva virusilor folosind RAV AntiVirus.
Xnet automatically scans all messages for viruses using RAV AntiVirus.

Nota: RAV AntiVirus poate sa nu detecteze toti virusii noi sau toate variantele lor.
Va rugam sa luati in considerare ca exista un risc de fiecare data cand deschideti
fisiere atasate si ca MobiFon nu este responsabila pentru nici un prejudiciu cauzat
de virusi.

Disclaimer: RAV AntiVirus may not be able to detect all new viruses and variants.
Please be aware that there is a risk involved whenever opening e-mail attachments
to your computer and that MobiFon is not responsible for any damages caused by
viruses.

C. Iacob wrote:

C. Iacob wrote:
> Hi,
>
> does it exist the reverse of wxWindow::GetHandle()? Something like
> wxWindow* wxWindow::FromHandle(void*)
> ?

[Robin Dunn ]There is wxWindow_FromHWND(hWnd) but as I mentioned a couple weeks ago I'm not totally convinced that I've implemented it correctly. Let me
know how it goes.

It seems to work if the hwnd belongs to a wxWindow. But it doesn't work when the hwnd belongs to a window which was not created using wxPython.

Example: I debug a C++ app which works under AutoCAD. This way I can see which is the handle (e.g. 1277448) of the main frame of AutoCAD. Having the same AutoCAD session open, I hardcode a simple wxPython test:

                w = wxWindow_FromHWND(1277448)

The result is a message box: "window.cpp(1023): invalid HWND".

I'm not sure I fully understand what you are doing here. Is the python code above executed in the same process that owns the window handle you specify? If not then that is probably the problem in this case.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!