To answer your first question, frame returns a Frame (), which, under the hood is an Object - that's another way of saying that I think your code is at least correctly typed.
I think you would need to use wxDirect to integrate properly with wxHaskell. It's a bit tedious, but not especially hard. I'll probably write a blog posting about this soon, but the basics of what you need to do are as follows:
Create an Eiffel(!) file containing all of the constant definitions exported by wxWebConnect (or at least the ones you want...). The reason for the Eiffel is historical: wxHaskell was originally built on top of a (long-obsolete) binding of wxWidgets to Eiffel. This requires no real knowledge of Eiffel: it's simply a file containing lines such as:
wxMY_CONTROL_SOME_VALUE : INTEGER is 23
Create a C header file describing the API you want to wrap - this is somewhat stylized, using macros to describe inheritance.
Run wxDirect over the newly created files - this autogenerates C wrappers over the C++ classes/functions with appropriate Haskell to use them.
I realize that this is a bit 'handwaving', but a full description really requires quite a lot more than I can manage in a single e-mail.
As a little more help, if you download wxCore source code (cabal fetch wxcore), you can look at the following files for inspiration:
wxcore/src/include/wxc_glue.h and wxc.h - these show the 'wrapping' style needed.
wxcore/src/eiffel/stc.e - this shows how to define constants in the Eiffel format
WxDirect accepts the following options:
-d : create constant definitions from .e files
-c : create class definitions from .h files
-t : create class type definitions from .h files
-i : create class info definitions
-o : set the output directory
I suspect that you will have a bit of trouble with getting all of this to work, so if you can wait (it may be a couple of weeks), there may be a blog posting to help you.
Hello, wxHaskell community!
foreign import stdcall unsafe "_browserFrame"
c_browserFrame :: Ptr a -> IO(Ptr ())
main :: IO ()
= start gui
gui :: IO ()
gui = do
f <- frame [text := "Hello world!", size := (sz 600 600) ]
withObjectPtr f c_browserFrame
where browser frame looks like
void* __stdcall browserFrame (wxFrame* ptrWxWindow)
wxString xulrunner_path = FindXulRunner(wxT("xr"));
wxWebControl* ptrBrowser = new wxWebControl(ptrWxWindow, wxID_WEB, wxPoint(0,0), wxSize(600,600)); //Here error comes from
it is compiled as dll by MS Visual 2008 and linked to Haskell program.
Also it looks like CreateControl execution fails.
It should be mentioned that ptrWxWindow can be operated with no errors (I mean hiding, resizing etc) and no any other kind of control can be created (wxButton, wxLabel).
If first parameter to c_browserFrame (parent window) is objectNull then everything is ok with no changes to gui. I can't understand what is wrong with ptrWxWindow param when passed from Haskell.
typeid(ptrWxWindow).name() shows expected type of ptrWxWindow - wxFrame.
What am I doing wrong? Please help me. Or maybe can you help me using your wxdirect subsystem to add this control to wxHaskell?
with best regards,
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
wxhaskell-users mailing list