This is a simplified version of CanaryBay, without bells and whistles.
The purpose of this code is to help you understand what is going on...
The CanaryBay project is a compound application mixing the core
WV2B binary EXE (written in C++) within a host application that could be written with any programming language.
Compound application is using interprocess to communicate together via a specific registered message:
gP.WM_BROWSER = RegisterWindowMessage("WM_BROWSER") '// Send/Get messages to/from the Browser
The inital parameters are shared using a config file (szConfig) to setup the WV2B behavior when firing the browser.
type SETBIN
dwExStyle as dword
dwStyle as dword
hParent as dword
x as long
y as long
w as long
h as long
onTABclose as WSTRING * %MAX_PATH
defaultURL as WSTRING * %MAX_PATH
end type
The names of the
SETBIN structure are self explanatory, and are used to setup the CreateWindowEx of the main Browser window.
Use of region
SetBrowserRegioncreates a hole region within the host window to display WV2B runing like a child process.
The host application can listen WV2B messages from the
ProcessBrowserMessage subroutine.
For now
WM_NCDESTROY is sent when the last Browser TAB is closing.
Firing the browser is done with buttons using the
WM_COMMAND message from the standard
Wndproc case %WM_COMMAND:
local wP as long
wP = LOINT(wParam)
select case long wP
case %IDC_BTN1
StartBrowser("https://forum.powerbasic.com/")
function = 0: exit function
case %IDC_BTN2
StartBrowser("http://www.objreader.com/download/video/TobVerF6zgr_576.mp4")
function = 0: exit function
case %IDC_EXIT
if gP.hBrowser then SendMessage(gP.hBrowser, %WM_CLOSE, 0, 0)
DestroyWindow(hWnd)
function = 0: exit function
end select
StartBrowser being the master API to fire WV2B.
The "
PowerBASIC" button is firing a standard website.
The "
D3D video" button is firing a video, just to show you that WV2B itself being a "Direct 3D" application, is using the latest web technology.
The "
Exit" button is meant to shut down the whole compound application.
The main window of the host application is a bare one, using only
%WS_POPUP or %WS_CLIPCHILDREN or %WS_CLIPSIBLINGS.
This means no caption, no border, nothing related to the NonClient_AREA, thus freeing us of the Windows default interactions.
However the standard behavior of a caption bar is emulated to move the window around, and changing the caption color to figure the gain or lost of focus.
About the coding style:It is using the core SDK syntax API, that is the only way to write portable code, because the core API is the common denominator understood by all Windows languages.
Contribution:If you appreciate this code, please consider to make a
donation to support my work.
Screenshot:(BTW, this is a custom 3D model running in my
ObjReader 3D engine, and available in the "car" collection for free)
If you have questions about this code, feel free to post them here.