Working on implemention

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Working on implemention

Postby pabloko » Wed Dec 23, 2009 6:51 am

Hi all, i discovered CEF yesterday, and i'm falling in love, I don't like to be the tipical idiot in forums that need work done, I only need some guidelines to start work out with CEF sucefully.

First, i will implement CEF on lua scripts, this is easy because this is C++ but it contais an API to work with lua, i suppouse you know hehe, well, I have a lua plugin that can call to dll functions and use memory storage to pass buffers, this scrips, in addition, have a class pointer reference to create a callback with any object, i think is here my opportunity! but i can done with mfc dll wrapped in a specific api, anybody has CEF on MFC and like to share?

My principal skill is to create an interpreter, for example, urls beguinning, Lua://myfolder/myfile.html i like to compile cef with implemention that get streams of file of one folder, pharse it and execute with lua c api, lua_dostring(L,...parts inside <%LUA ... %> Tags) and show generated HTML, i have a touch idea to how do this, but uld you send me some guidelines to work with it?

T'hanks for all, i don't very strong with c++, but i think this is fuc**ing amazing
pabloko
Techie
 
Posts: 15
Joined: Wed Dec 23, 2009 6:38 am

Re: Working on implemention

Postby magreenblatt » Wed Dec 23, 2009 4:23 pm

If you are seeking to implement a scheme handler as indicated by your lua:// example then you will want to use the CefRegisterScheme() function and the CefSchemeHandler classes. This will allow you to handle lua:// requests using whatever method you prefer.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Working on implemention

Postby pabloko » Wed Dec 23, 2009 8:28 pm

Yes, i see, now i'm triying on HandleBeforeResourceLoad because it's very easy make fast testing here, for example, i do read a file in the source folder as is:

Code: Select all
else if(wcsstr(url.c_str(), L"lua:pabloko") != NULL) {   
    inFile=L"test.txt";   
        resourceStream = CefStreamReader::CreateForFile(inFile);
   mimeType = L"text/html";
    }


when I have more experience and know more i will create the scheme, i see in the examples that this is done easily, but 'I have a problem because I don'r know how to use CefStreamReader::CreateForData, i see a null pointer, i figure that i need use the Read funcion or create my string in a buffer and store in the pointer, but, I told, I' don't very well on C++, i'm sure that it is an idiot question.,.

have a meeri xmas, from spain

update

...very idiot question

resourceStream = CefStreamReader::CreateForData(L"Hola",sizeof(L"Hola"));
pabloko
Techie
 
Posts: 15
Joined: Wed Dec 23, 2009 6:38 am

Re: Working on implemention

Postby pabloko » Sat Dec 26, 2009 6:56 pm

It's possible turn transparent the background of cef and render a webpage over the desktop? do you think that this is possible?

and other thing, i'm having memory errors when i try to use a code that works fine in other app, the code is for read a textfile and display the contents but it appear an several error of memory, the code is;

Code: Select all
wint_t  retval;
FILE    *fp;
wchar_t *pwcs;
    if ((fp = fopen("test.txt", "r")) == NULL) {
      pwcs=L"error";
    } else {
        while ((retval = fgetwc(fp)) != WEOF){
            *pwcs++ = (wchar_t)retval;
        }
    }
    fflush(fp);
    fclose(fp);

I tested other methods to read files with the same result, i know that i can do with create for file, but i need use a lua api to evaluate the string and get an variable with the result... but memory errors are killing me
pabloko
Techie
 
Posts: 15
Joined: Wed Dec 23, 2009 6:38 am

Re: Working on implemention

Postby magreenblatt » Sun Dec 27, 2009 11:41 am

I don'r know how to use CefStreamReader::CreateForData, i see a null pointer

The |data| argument must be a valid pointer and |size| must be the size of the data pointed to by |data|. The data will be copied by CEF so it doesn't need to persist after being passed to CreateForData().

It's possible turn transparent the background of cef and render a webpage over the desktop?

The easiest approach would be to capture the desktop as a bitmap and then use that bitmap as the background image for a full screen CEF window.

One problem with your code snippet is that the |pwcs| variable is never assigned an address, so calling |*pwcs++ = ...| will overwrite a random location in memory.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Working on implemention

Postby pabloko » Fri Jan 01, 2010 11:47 pm

yes, i see, i used a fuction readContentFromFile thta i founded on http://www.google.es/codesearch/p?hl=es ... p&q=fgetws with this code:

Code: Select all
wchar_t* test=readContentFromFile(L"test.txt");
 resourceStream = CefStreamReader::CreateForData(test,wcslen(test)*2);
mimeType = L"text/html";


this works good, but the code is passed decoded (&lt;html&gt;&lt;h1&gt;Hola&lt;/h1&gt;&lt;br&gt;) and don't recognize html... any method to get the correct characters?

thanks for all
pabloko
Techie
 
Posts: 15
Joined: Wed Dec 23, 2009 6:38 am

Re: Working on implemention

Postby pabloko » Mon Jan 11, 2010 9:54 am

Hi, i uploaded a sample project with slider object

http://www.megaupload.com/?d=8885ZWIY

I want to use this project as skelton to use CEF, but it uses afx classes, and the callback used is AFX_MESSAGE_MAP and I don't know how use CEF with his callback system

This CSliderApp class manage the object and implements some functions on lua engine and manage a configuration dialog... I can create this, but I can't create the callback system. This generates a dll that i can use with my software, autoplay media studio

Anybody can help me to do this?
pabloko
Techie
 
Posts: 15
Joined: Wed Dec 23, 2009 6:38 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 41 guests