get_os_window_handleT_get_os_window_handleGetOsWindowHandleGetOsWindowHandleget_os_window_handle (Operator)

Name

get_os_window_handleT_get_os_window_handleGetOsWindowHandleGetOsWindowHandleget_os_window_handle — Get the operating system window handle.

Warning

This operator does not work in an HDevelop graphics window opened with dev_open_window.

Signature

get_os_window_handle( : : WindowHandle : OSWindowHandle, OSDisplayHandle)

Herror T_get_os_window_handle(const Htuple WindowHandle, Htuple* OSWindowHandle, Htuple* OSDisplayHandle)

void GetOsWindowHandle(const HTuple& WindowHandle, HTuple* OSWindowHandle, HTuple* OSDisplayHandle)

void* HWindow::GetOsWindowHandle(void** OSDisplayHandle) const

static void HOperatorSet.GetOsWindowHandle(HTuple windowHandle, out HTuple OSWindowHandle, out HTuple OSDisplayHandle)

IntPtr HWindow.GetOsWindowHandle(out IntPtr OSDisplayHandle)

def get_os_window_handle(window_handle: HHandle) -> Tuple[int, int]

Description

get_os_window_handleget_os_window_handleGetOsWindowHandleGetOsWindowHandleGetOsWindowHandleget_os_window_handle returns the operating system window handle of the HALCON window WindowHandleWindowHandleWindowHandleWindowHandlewindowHandlewindow_handle in OSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleoswindow_handle. Under Unix-like systems, additionally the operating system display handle is returned in OSDisplayHandleOSDisplayHandleOSDisplayHandleOSDisplayHandleOSDisplayHandleosdisplay_handle. The operating system window handle can be used to access the window using functions from the operating system, e.g., to draw in a user-defined manner into the window. Under Windows, OSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleoswindow_handle can be cast to a variable of type HWND. Under Unix-like systems, OSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleoswindow_handle can be cast into a variable of type Window, while OSDisplayHandleOSDisplayHandleOSDisplayHandleOSDisplayHandleOSDisplayHandleosdisplay_handle can be cast into a variable of type Display.

Execution Information

Parameters

WindowHandleWindowHandleWindowHandleWindowHandlewindowHandlewindow_handle (input_control)  window HWindow, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Window handle.

OSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleOSWindowHandleoswindow_handle (output_control)  pointer HTupleintHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Operating system window handle.

OSDisplayHandleOSDisplayHandleOSDisplayHandleOSDisplayHandleOSDisplayHandleosdisplay_handle (output_control)  pointer HTupleintHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Operating system display handle (under Unix-like systems only).

Example (C)

/* Draw a line into a HALCON window under Unix-like systems using X11 calls. */
#include "HalconC.h"
#include <X11/X.h>
#include <X11/Xlib.h>

int main(int argc, char **argv)
{
  Hlong hwin, win, disp;
  Display *display;
  Window window;
  GC gc;
  XGCValues values;
  static char dashes[] = { 20, 20 };

  open_window(0, 0, 500, 500, 0, "visible", "", &hwin);
  get_os_window_handle(hwin, &win, &disp);
  display = (Display *)disp;
  window = (Window)win;
  gc = XCreateGC(display, window, 0, &values);
  XSetFunction(display, gc, GXset);
  XSetLineAttributes(display, gc, 10, LineOnOffDash, CapRound, JoinRound);
  XSetDashes(display, gc, 0, dashes, 2);
  XSetForeground(display, gc, WhitePixel(display, DefaultScreen(display)));
  XSetBackground(display, gc, BlackPixel(display, DefaultScreen(display)));
  XDrawLine(display, win, gc, 20, 20, 480, 480);
  XFlush(display);
  XFreeGC(display, gc);
  wait_seconds(5);
  return 0;
}

/* Draw a line into a HALCON window under Windows using GDI calls. */
#include "HalconC.h"
#include "windows.h"

int main(int argc, char **argv)
{
  Hlong hwin, win, disp;
  HDC hdc;
  HPEN hpen;
  HPEN *hpen_old;
  LOGBRUSH logbrush;
  POINT point;
  static DWORD dashes[] = { 20, 20 };

  open_window(0, 0, 500, 500, 0, "visible", "", &hwin);
  get_os_window_handle(hwin, &win, &disp);
  logbrush.lbColor = RGB(255,255,255);
  logbrush.lbStyle = BS_SOLID;
  hpen =  ExtCreatePen(PS_USERSTYLE|PS_GEOMETRIC, 10, &logbrush, 2, dashes);
  hdc = GetDC((HWND)win);
  hpen_old = (HPEN *)SelectObject(hdc, hpen);
  MoveToEx(hdc, 20, 20, &point);
  LineTo(hdc, 480, 480);
  DeleteObject(SelectObject(hdc, hpen_old));
  ReleaseDC((HWND)win, hdc);
  wait_seconds(5);
  return 0;
}

Result

If the window is valid get_os_window_handleget_os_window_handleGetOsWindowHandleGetOsWindowHandleGetOsWindowHandleget_os_window_handle returns 2 ( H_MSG_TRUE) . Otherwise, an exception is raised.

Possible Predecessors

open_windowopen_windowOpenWindowOpenWindowOpenWindowopen_window

Module

Foundation