Using MSDN C++ functions in Xojo

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).

Not sure about the type of lpMsg but try with

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

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

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

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

Do you mean “wouldn’t”?

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.