# Using MSDN C++ functions in Xojo

**URL:** <https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590>\
**Category:** Windows\
**Created:** [January 13, 2014, 2:26pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590 "2014-01-13T14:26:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Woods](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/d9b06d/32.png) [@Joshua\_Woods](https://forum.xojo.com/u/Joshua_Woods)\
**Post date:** [January 13, 2014, 2:26pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590/1 "2014-01-13T14:26:57Z")

</div>

Hello everyone,

I’ve had some limited success fumbling my way with this and gotten simple functions like ShowWindow to work but I can’t get GetMessage from user32.lib to work. Probably the datatypes or parameters are wrong.

Can anyone help me here?

[code] declare function GetMessage lib “User32” alias “GetMessage” (lpMsg as integer, hWnd as integer, wMsgFilterMin as UInt32, wMsgFilterMax as Uint32) as integer

```
  // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644936(v=vs.85).aspx
  if GetMessage(0, 0, &h0200, &h020A) <> 0 and MouseOutside then
    self.close
  end if[/code]

```

Essentially all I want to be able to detect is a mouseclick anywhere in the application that happens outside a control (MouseUp event is useless for this unfortunately).

---

<div class="post-metadata">

**Author:** ![Massimo\_Valle](https://forum.xojo.com/user_avatar/forum.xojo.com/massimo_valle/32/23049_2.png) [@Massimo\_Valle](https://forum.xojo.com/u/Massimo_Valle)\
**Post date:** [January 13, 2014, 2:37pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590/2 "2014-01-13T14:37:15Z")

</div>

Not sure about the type of lpMsg but try with

```auto
declare function GetMessage lib "User32" alias "GetMessageW" (lpMsg as integer, hWnd as integer, wMsgFilterMin as UInt32, wMsgFilterMax as Uint32) as boolean
      
      // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644936(v=vs.85).aspx
      if GetMessage(0, 0, &h0200, &h020A) and MouseOutside then
        self.close
      end if
```

---

<div class="post-metadata">

**Author:** ![Joshua\_Woods](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/d9b06d/32.png) [@Joshua\_Woods](https://forum.xojo.com/u/Joshua_Woods)\
**Post date:** [January 13, 2014, 2:47pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590/3 "2014-01-13T14:47:51Z")

</div>

Thanks Massimo.

It’s finding the function now but it still crashes. lpMsg seems to be a structure: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644958(v=vs.85).aspx](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644958(v=vs.85).aspx)

Maybe that’s the problem. What do you think?

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [January 13, 2014, 2:48pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590/4 "2014-01-13T14:48:50Z")

</div>

I would recommend messing up the message loop of a windows app…

---

<div class="post-metadata">

**Author:** ![Joshua\_Woods](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/d9b06d/32.png) [@Joshua\_Woods](https://forum.xojo.com/u/Joshua_Woods)\
**Post date:** [January 13, 2014, 2:52pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590/5 "2014-01-13T14:52:10Z")

</div>

> [@58766:@Christian Schmitz](#):
>
> I would recommend messing up the message loop of a windows app…

Do you mean “wouldn’t”?

---

<div class="post-metadata">

**Author:** ![Joshua\_Woods](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/d9b06d/32.png) [@Joshua\_Woods](https://forum.xojo.com/u/Joshua_Woods)\
**Post date:** [January 13, 2014, 3:01pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590/6 "2014-01-13T15:01:56Z")

</div>

Ah well, you’re probably right Christian.

I’ve found that simply using the deactivate event suits my needs well enough. Since Massimo’s answer fulfilled the purpose of the thread I’ll mark this one as answered.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:01pm UTC](https://forum.xojo.com/t/using-msdn-c-functions-in-xojo/13590/7 "2020-10-29T17:01:30Z")

</div>


