You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am trying to write an app with a NotifyIcon (system tray icon) with WinFBE/FreeBASIC.
So far, I was able to create a NotifyIcon and show it in the system tray.
But now I am trying to react on events, create a popup menu etc., but the MessagePumpHook function of the frmForm doesn't receive any events from the NotifyIcon.
The MessagePumpHook is, if I did understand it right, some kind of "replacement" for the WinProc callback function you would normaly use when you create your window/form by code with CreateWindow(), while you get the hWnd from CreateWindow(), right? So I activated the event in the WinFBE Designer, and took some code in its function body.
Then I did set the NOTIFYICONDATAs hWnd variable to frmForm.hWindow, which the manual says is the hWnd of the frmForm, while I created the NotifyIcon in the frmForm_Load() function, to "connect" both, the frmForm and the NotifyIcon, and successfully created it with Shell_NotifyIcon( NIM_ADD, @SystrayIcon )
I have put a PRINT statement in my MessagePumpHook to log all messages cuming in, and while I use the normal frmForm with my mouse, I can see a lot of messages going through. But when I hover the NotifyIcon with the mouse, nothing happens. When I click on the Icon with the left or right mouse button, nothing happens.
It seems like the NotifyIcon and the frmForm are not "connected" correctly. The MessagePumpHook receives messages from the main app frmForm, but the created NotifyIcon is not able to send its messages to the given hWindow message queue of the frmForm. Maybe the hWnd/hWindow of the frmForm is wrong at all? Is there any other handle I have to use?
I have tried different WinFBE versions (2+3) and different FreeBASIC compiler versions (1.07.2 and 1.10.x), always with the same result.
Here are some snippets from my code.
Did I oversee or misunderstood something? Depending MessagePumpHook and WinProc?
Am I doing something wrong here? Or is it a bug in WinFBE?
Hope that somebody can help or point me to the right direction... :-)
My OS is Windows 10 Pro 64bit, and I am using WinFBE 2.2.0 with FreeBASIC 1.07.2 (using the 64bit compiler)
Dim Shared SystrayIcon As NOTIFYICONDATA
'...
Function frmForm_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
Dim hIcon As hIcon
hIcon = LoadIcon (getmodulehandle(0), MAKEINTRESOURCE(IDI_MYICON) )
With SystrayIcon
.cbSize = Len(SystrayIcon)
.hWnd = frmForm.hWindow
.uId = IDI_MYICON
.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
.uCallbackMessage = WM_MYTRAYICON
.hIcon = hIcon
.szTip = "NotifyIcon Test" +Chr(0)
End With
Shell_NotifyIcon( NIM_ADD, @SystrayIcon )
Function = 0
End Function
'...
Function frmForm_MessagePumpHook( byval lpMSG as MSG ptr ) as boolean
Dim lpClickPoint As POINT
Print lpMSG->message 'for console log!
Select Case lpMSG->message
Case WM_MYTRAYICON
Print "WM_MYTRAYICON"
Select Case lpMSG->lParam
Case WM_RBUTTONDOWN
'GetCursorPos(@lpClickPoint)
Print "WM_RBUTTONDOWN"
End Select
Case WM_DESTROY
PostQuitMessage(0)
End Select
Function = 0
End Function
The text was updated successfully, but these errors were encountered:
Hi, instead of using MessagePumpHook, try using AllEvents handler instead. I created a sample project based on the code that you posted and using AllEvents, I was able to get the WM_MYTRAYICON message notifications.
Function frmForm_AllEvents( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
Select Case e.Message
Case WM_MYTRAYICON
Print "WM_MYTRAYICON"
Select Case e.lParam
Case WM_RBUTTONDOWN
'GetCursorPos(@lpClickPoint)
Print "WM_RBUTTONDOWN"
End Select
End Select
Function = 0
End Function
Oh wow! Thank you for that quick reply...
I have just tested your suggestion, moved my code into the AllEvents() function, and now everything is working as expected! Great! :-D
What is the intended difference between AllEvents() and MessagePumpHook() then?
Or, why is MessagePumpHook() "limited"? Is there a reason?
Hello,
I am trying to write an app with a NotifyIcon (system tray icon) with WinFBE/FreeBASIC.
So far, I was able to create a NotifyIcon and show it in the system tray.
But now I am trying to react on events, create a popup menu etc., but the MessagePumpHook function of the frmForm doesn't receive any events from the NotifyIcon.
The MessagePumpHook is, if I did understand it right, some kind of "replacement" for the WinProc callback function you would normaly use when you create your window/form by code with CreateWindow(), while you get the hWnd from CreateWindow(), right? So I activated the event in the WinFBE Designer, and took some code in its function body.
Then I did set the NOTIFYICONDATAs hWnd variable to frmForm.hWindow, which the manual says is the hWnd of the frmForm, while I created the NotifyIcon in the frmForm_Load() function, to "connect" both, the frmForm and the NotifyIcon, and successfully created it with
Shell_NotifyIcon( NIM_ADD, @SystrayIcon )
I have put a PRINT statement in my MessagePumpHook to log all messages cuming in, and while I use the normal frmForm with my mouse, I can see a lot of messages going through. But when I hover the NotifyIcon with the mouse, nothing happens. When I click on the Icon with the left or right mouse button, nothing happens.
It seems like the NotifyIcon and the frmForm are not "connected" correctly. The MessagePumpHook receives messages from the main app frmForm, but the created NotifyIcon is not able to send its messages to the given hWindow message queue of the frmForm. Maybe the hWnd/hWindow of the frmForm is wrong at all? Is there any other handle I have to use?
I have tried different WinFBE versions (2+3) and different FreeBASIC compiler versions (1.07.2 and 1.10.x), always with the same result.
Here are some snippets from my code.
Did I oversee or misunderstood something? Depending MessagePumpHook and WinProc?
Am I doing something wrong here? Or is it a bug in WinFBE?
Hope that somebody can help or point me to the right direction... :-)
My OS is Windows 10 Pro 64bit, and I am using WinFBE 2.2.0 with FreeBASIC 1.07.2 (using the 64bit compiler)
Greetings!
** resource.rc **
** main.bas **
** frmForm.inc **
The text was updated successfully, but these errors were encountered: