HGE in a child window

简介:

Running HGE in a child window hosted by a Windows application may be useful to create authoring tools and ActiveX controls or to integrate HGE into a third party IDE. Here follow the guidelines how to do that.

Creating HGE window as a child

To run HGE in a child window mode you should just specify the parent window handle. To do this set HGE_HWNDPARENT system state before calling to System_Initiate:

hge->System_SetState(HGE_HWNDPARENT, hwnd);

Mouse cursor

You may prefer HGE to use standard Windows cursor while in child window mode. This can be done by setting HGE_HIDEMOUSE system state to false:

hge->System_SetState(HGE_HIDEMOUSE, false);

Dispatching application's messages and running Frame Function

To provide additional flexibility System_Start behaves a bit differently in child window mode. First, it returns after just one call to user's frame function regardless of the value returned by it. Second, it doesn't dispatch window messages. So you should set up your own message processing loop. Here's the simpliest loop enough to run HGE properly:

for(;;)
{
  if(hge->System_GetState(HGE_HWND))
    hge->System_Start();

  if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  { 
    if(msg.message == WM_QUIT) break;
    DispatchMessage(&msg);
  }
}

Moving and resizing HGE window

You can move and resize HGE window with WinAPI functions like MoveWindow. When it's window resized, HGE will reinitiate DirectX to meet new window dimensions:

MoveWindow(hge->System_GetState(HGE_HWND),
           x, y, width, height, true);

Destroying HGE window

HGE has lots of resources associated with it's window. So you should use System_Shutdown call to free them, don't rely on just destroying the window. The good place to do this is WM_DESTROY handler of the parent window:

case WM_DESTROY:
    FreeLoadedHGEResources();
    hge->System_Shutdown();
    PostQuitMessage(0);
    return FALSE;

Child window mode limitations

1. To accept keyboard events in child window mode HGE window must have input focus. It gains focus automatically when you click somewhere inside. Use the following call to set the focus explicitly:

SetFocus(hge->System_GetState(HGE_HWND));

2. Switching into fullscreen is unavailable when running in child window mode. Regardless of HGE_WINDOWED system state HGE will run in a window.

目录
相关文章
|
4天前
|
JavaScript
原生js中offsetTop, offsetLeft与offsetParent的详细讲解
原生js中offsetTop, offsetLeft与offsetParent的详细讲解
|
6月前
|
内存技术
Egret的TimerEvent.TIMER和Event.ENTER_FRAME的区别
Egret的TimerEvent.TIMER和Event.ENTER_FRAME的区别
35 0
|
JavaScript 前端开发
18、DOM对象(window、screen、location、history、navigation)
18、DOM对象(window、screen、location、history、navigation)
102 0
为什么会有window.window这种设计
为啥要搞这个这个看起来貌似很奇葩的设计。 要解答这个问题,还得请出this,我们经常说浏览器中的全局对象是window, 这句话对了,也还没完全对。 全局对象的真实身份应该是全局作用域的this。 window只是为了便于访问this,弄出来的一个属性。
274 0
为什么会有window.window这种设计
|
前端开发 JavaScript 数据安全/隐私保护
58、window 对象
浏览器里面,window对象(注意,w为小写)指当前的浏览器窗口。它也是当前页面的顶层对象,即最高一层的对象,所有其他对象都是它的下属。一个变量如果未声明,那么默认就是顶层对象的属性。
200 0
Dialog显示引起的问题 Activity has leaked window DecorView@5704632[] that was originally added here
Dialog显示引起的问题 Activity has leaked window DecorView@5704632[] that was originally added here
|
编解码
window.innerHeight window.outerHeight 与screen.height
本文目录 1. window 2. innerHeight与outerHeight 3. screen.height 4. 实例
347 0
window.innerHeight window.outerHeight 与screen.height
mint-ui在tab-container使用Infinite scroll 不能触发loadmore
直接上代码,基本上就是官网的Infinite scroll外面套上一层tab-container:
3235 0
解决popup不随着window一起移动的问题
原文:解决popup不随着window一起移动的问题 当我们设置Popup的StayOpen="True"时,会发现移动窗体或者改变窗体的Size的时候,Popup并不会跟随着一起移动位置。为了解决这个问题,可以给Popup定义一个附加属性,代码如下所示: /// /// Popup帮助类...
1049 0