Hi list,

I made some progress but I'm still a bit lost here.

I managed to get Pharo to be headless in Win32, by hiding the window via NB
as Igor suggested, plus suspending the UI process (UIManager default
uiProcess suspend), which was the cause for the window to show up again
after a fraction of a second, because of the refresh interval.

However, now I can only close Pharo by killing the process manually, which
is not very nice for the end user. So I figured I'd try to add an icon to
the system tray with a single context menu entry for closing Pharo.

This is what I'm doing, taken from
MSDN<http://msdn.microsoft.com/en-us/library/windows/desktop/bb762159(v=vs.85).aspx>
:

NBWin32Shell >> shellNotifyIcon: lpdata dwMessage: dwMessage

<primitive: #primitiveNativeCall module: #NativeBoostPlugin>

^ self nbCall: #(bool Shell_NotifyIcon(

  DWORD dwMessage,

  PNOTIFYICONDATA lpdata

)) module: #shell32

dwMessage is just a 0 (flag to create a tray icon), but lpdata needs to be a
pointer to a struct of this
form<http://msdn.microsoft.com/en-us/library/windows/desktop/bb773352(v=vs.85).aspx>
:

typedef struct _NOTIFYICONDATA {
  DWORD cbSize;
  HWND  hWnd;
  UINT  uID;
  UINT  uFlags;
  UINT  uCallbackMessage;
  HICON hIcon;
  TCHAR szTip[64];
  DWORD dwState;
  DWORD dwStateMask;
  TCHAR szInfo[256];
  union {
    UINT uTimeout;
    UINT uVersion;
  };
  TCHAR szInfoTitle[64];
  DWORD dwInfoFlags;
  GUID  guidItem;
  HICON hBalloonIcon;
} NOTIFYICONDATA, *PNOTIFYICONDATA;


So, my question is: how do I translate this into NB code? How does one
define a struct and then pass its pointer to a function in NativeBoost?

Thanks a lot for your help, I'm getting closer :)

Bernat.

p.s. Could the Windows API be any more convoluted and dev-unfriendly in any
possible sense?



2013/11/4 Bernat Romagosa <tibabenfortlapala...@gmail.com>

> Hi!
>
> Thanks Igor, that kinda worked! Pharo hides, but comes back after half a
> second or so. I'll keep digging, thanks! :)
>
>
> 2013/11/1 p...@highoctane.be <p...@highoctane.be>
>
> Well, this should rather be:
>>
>> handle :=NativeBoostWin32 squeakWindowHandle.
>> window := NBWin32Window new value: handle; yourself.
>> window hide.
>>
>> or
>>
>> window setWindowText: 'im a main window blablabla'.
>>
>> Phil
>>
>>
>> On Thu, Oct 31, 2013 at 10:03 PM, Igor Stasenko <siguc...@gmail.com>wrote:
>>
>>> You can try something like this:
>>>
>>> | handle window |
>>>
>>> handle := NativeBoost forCurrentPlatform squeakWindowHandle.
>>> window := NBWin32Window new value: handle; yourself.
>>> window hide.
>>>
>>> or
>>>
>>> window setWindowText: 'im a main window blablabla'.
>>>
>>> :)
>>>
>>> i didn't tested it since its been implemented, but i think it should
>>> work.
>>>
>>>
>>>
>>> On 30 October 2013 11:20, Bernat Romagosa <
>>> tibabenfortlapala...@gmail.com> wrote:
>>>
>>>> In this direction, I'm trying to call a function in the shell32.dll lib
>>>> that apparently should let you minimize an app to the system tray, but I'm
>>>> not having much luck... I guess I don't really understand what am I exactly
>>>> doing.
>>>>
>>>> This is what I found in the 
>>>> MSDN<http://msdn.microsoft.com/en-us/library/bb762159%28VS.85%29.aspx>
>>>> :
>>>>
>>>>  BOOL Shell_NotifyIcon(
>>>>   _In_  DWORD dwMessage,
>>>>   _In_  PNOTIFYICONDATA lpdata
>>>> );
>>>>
>>>>
>>>> So, I tried to translate this into Pharo as:
>>>>
>>>> MyClass >> minimizeToTray: dwMessage data: lpData
>>>>
>>>>   <apicall: bool 'Shell_NotifyIcon' (dword PNOTIFYICONDATA) module:
>>>> 'shell32.dll'>
>>>>
>>>>
>>>> But it won't let me save the method, reporting it's expecting an
>>>> argument before PNOTIFYICONDATA.
>>>>
>>>> I realize PNOTIFYICONDATA is not a primitive type, but I just don't
>>>> know how to handle it... :(
>>>>
>>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko.
>>>
>>
>>
>
>
> --
> Bernat Romagosa.
>



-- 
Bernat Romagosa.

Reply via email to