aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/service/svcs/svc_accroleserver.cpp
blob: 84bbaabf41afea54c63a28f8d6c85d2b922f96e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <precomp.h>

#include "svc_accroleserver.h"
#include <api/script/objects/guiobject.h>
#include <api/wnd/api_window.h>

#define CBCLASS svc_accRoleServerI
START_DISPATCH;
  CB(RS_HANDLEROLE,      handleRole);
  CB(RS_CREATEOBJECT,    createObject);
  VCB(RS_DESTROYOBJECT,  destroyObject);
END_DISPATCH;
#undef CBCLASS


#define CBCLASS roleServerObjectI
START_DISPATCH;
  CB(RSO_WNDPROC,        wndProc);
  CB(RSO_GETHWND,        gethWnd);
  CB(RSO_FLATTENCONTENT, flattenContent);
END_DISPATCH;
#undef CBCLASS


roleServerObjectI::roleServerObjectI(HWND par, api_window *w) {
  wnd = w;
  hwnd = NULL;
  parent = par;
  triedyet = 0;
}

roleServerObjectI::~roleServerObjectI() {
  if (hwnd != NULL)
    DestroyWindow(hwnd);
}

api_window *roleServerObjectI::getWnd() {
  return wnd;
}

HWND roleServerObjectI::gethWnd() {
  if (!triedyet) {
    triedyet = 1;
    hwnd = createWindow(parent);
    if (hwnd !=NULL)
      oldproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC);
    else
      oldproc = NULL;
  }
  return hwnd;
}

ScriptObject *roleServerObjectI::getScriptObject() {
  if (wnd == NULL) return NULL;
  GuiObject *go = wnd->getGuiObject();
  if (go == NULL) return NULL;
  return go->guiobject_getScriptObject();
}

WNDPROC roleServerObjectI::getOldProc() {
  return oldproc;
}

int roleServerObjectI::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  return CallWindowProc(oldproc, hWnd, uMsg, wParam, lParam);
}

int roleServerObjectI::flattenContent(HWND *w) {
  return FLATTENFLAG_ASKPARENT;
}