delphi - Chromium embedded minimal client WM_paint stops working after minimizing and restoring -
apparently, basic delphi chromium embedded minimal or cefclient demo unable focus window while minimized , restored. unable click on anything, however, if resize window, it's going normal, being able click , use browser usual.
later edit : i'm using dcef3 , latest version https://github.com/svn2github/dcef3 , cef3 3.1364.1094 more specific.
does have idea how repaint browser after minimizing , restoring in delphi xe3 ?
actual code:
program cefclient; uses windows, messages, ceflib; type tcustomclient = class(tcefclientown) private flifespan: iceflifespanhandler; protected function getlifespanhandler: iceflifespanhandler; override; public constructor create; override; end; tcustomlifespan = class(tceflifespanhandlerown) protected procedure onaftercreated(const browser: icefbrowser); override; procedure onbeforeclose(const browser: icefbrowser); override; end; type twindowproc = pointer; wndproc = pointer; var window: hwnd; handl: icefclient = nil; brows: icefbrowser = nil; browserid: integer = 0; navigateto: ustring = 'http://google.com'; function cefwndproc(wnd: hwnd; message: uint; wparam: integer; lparam: integer): integer; stdcall; var ps: paintstruct; info: tcefwindowinfo; rect: trect; hdwp: thandle; setting: tcefbrowsersettings; begin case message of wm_paint: begin beginpaint(wnd, ps); endpaint(wnd, ps); result := 0; end; wm_create: begin handl := tcustomclient.create; getclientrect(wnd, rect); fillchar(info, sizeof(info), 0); info.style := ws_child or ws_visible or ws_clipchildren or ws_clipsiblings or ws_tabstop; info.parent_window := wnd; info.x := rect.left; info.y := rect.top; info.width := rect.right - rect.left; info.height := rect.bottom - rect.top; fillchar(setting, sizeof(setting), 0); setting.size := sizeof(setting); cefbrowserhostcreatesync(@info, handl, navigateto, @setting); settimer(wnd, 1, 100, nil); result := 0; end; wm_destroy: begin brows := nil; postquitmessage(0); result := defwindowproc(wnd, message, wparam, lparam); end; wm_setfocus: begin if brows <> nil postmessage(brows.host.windowhandle, wm_setfocus, wparam, 0); result := 0; end; wm_size: begin if(brows <> nil) begin // resize browser window , address bar match new frame // window size getclientrect(wnd, rect); hdwp := begindeferwindowpos(1); hdwp := deferwindowpos(hdwp, brows.host.windowhandle, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, swp_nozorder); enddeferwindowpos(hdwp); end; result := defwindowproc(wnd, message, wparam, lparam); end; wm_close: begin if brows <> nil brows.host.parentwindowwillclose; result := defwindowproc(wnd, message, wparam, lparam); end else result := defwindowproc(wnd, message, wparam, lparam); end; end; { tcustomclient } constructor tcustomclient.create; begin inherited; flifespan := tcustomlifespan.create; end; function tcustomclient.getlifespanhandler: iceflifespanhandler; begin result := flifespan; end; { tcustomlifespan } procedure tcustomlifespan.onaftercreated(const browser: icefbrowser); begin if not browser.ispopup begin // first browser brows := browser; browserid := brows.identifier; end; end; procedure tcustomlifespan.onbeforeclose(const browser: icefbrowser); begin if browser.identifier = browserid brows := nil; end; var wndclass : twndclass; begin // multi process cefsingleprocess := false; if not cefloadlibdefault exit; try wndclass.style := cs_hredraw or cs_vredraw; wndclass.lpfnwndproc := @cefwndproc; wndclass.cbclsextra := 0; wndclass.cbwndextra := 0; wndclass.hinstance := hinstance; wndclass.hicon := loadicon(0, idi_application); wndclass.hcursor := loadcursor(0, idc_arrow); wndclass.hbrbackground := 0; wndclass.lpszmenuname := nil; wndclass.lpszclassname := 'cefapp'; registerclass(wndclass); window := createwindow( 'cefapp', 'chromium', ws_overlappedwindow or ws_clipchildren, integer(cw_usedefault), integer(cw_usedefault), integer(cw_usedefault), integer(cw_usedefault), 0, 0, hinstance, nil); showwindow(window, sw_show); updatewindow(window); cefrunmessageloop; handl := nil; end; end.
Comments
Post a Comment