- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
i am trying to make a tray icon for our program. It works really well, is well shown and the tip text also works.
Further we want, that this tray icon shows up a balloon tip, when something special happens...a mathematic procedure finished for example.
So i searched the msdn to look how this would be done...seems pretty easy.
I coded all necessary attributes and then BOOM...many many errors.
I took a look at the T_NOTIFYICONDATA type which is use in Shell_NotifyIcon function and there i realised that the type is generated in ifwinty module like this:
[fortran] TYPE T_NOTIFYICONDATA SEQUENCE integer(DWORD) cbSize ! knowns DWORD integer(HANDLE) hWnd ! handles HWND integer(UINT) uID ! knowns UINT integer(UINT) uFlags ! knowns UINT integer(UINT) uCallbackMessage ! knowns UINT integer(HANDLE) hIcon ! handles HICON !DEC$ IF DEFINED(__KEEP_OLD_CHARACTER_ARRAYS) character(SCHAR) szTip(64) ! knowns CHAR !DEC$ ELSE character(64) szTip !DEC$ ENDIF END TYPE [/fortran]
And there is the problem.
I need further more parameters to use the Balloon Tip. These areszInfo,szInfoTitle,dwInfoFlags, anduTimeout.The uFlags parameter also does need NIF_INFO for initialize the Tip as a BalloonTip...thats not the big deal...its#00000010 and can be added simple.
I thought "hey no problem...create my own type which is a copy of T_NOTIFYICONDATA and add the missing parameters"...well...wont work :)
Shell_NotifyIcon wants aT_NOTIFYICONDATA type.
So what could i do now?...Any ideas from the fortran super pros?
Best regards
Oliver
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could create your own variant of the interface block for Shell_NotifyIcon. Copy the current interface is in Shell32.f90, change the name of the function, change the name of the type (to your new type) but leave the rest the same. Something a bit like:
[fortran]MODULE ShellSuperDeluxe USE IFWINTY IMPLICIT NONE PRIVATE PUBLIC :: T_NOTIFYICONDATA_SuperDeluxe PUBLIC :: Shell_NotifyIcon_SuperDeluxe TYPE :: T_NOTIFYICONDATA_SuperDeluxe SEQUENCE TYPE(T_NOTIFYICONDATA) :: base INTEGER(DWORD) :: dwState INTEGER(DWORD) :: dwStateMask CHARACTER(256) :: szInfo INTEGER(UINT) :: uTimeout_or_uVersion CHARACTER(64) :: szInfoTitle INTEGER(DWORD) :: dwInfoFlags TYPE(T_GUID) :: guidItem INTEGER(HANDLE) :: hBalloonIcon END TYPE T_NOTIFYICONDATA_SuperDeluxe INTERFACE FUNCTION Shell_NotifyIcon_SuperDeluxe(dwMessage, lpData) use ifwinty IMPORT :: T_NOTIFYICONDATA_SuperDeluxe IMPLICIT NONE integer(BOOL) :: Shell_NotifyIcon_SuperDeluxe ! BOOL !DEC$ ATTRIBUTES DEFAULT :: Shell_NotifyIcon_SuperDeluxe !DEC$ ATTRIBUTES STDCALL, DECORATE :: Shell_NotifyIcon_SuperDeluxe !DEC$ ATTRIBUTES ALIAS:'Shell_NotifyIconA' :: Shell_NotifyIcon_SuperDeluxe integer(DWORD) dwMessage ! DWORD dwMessage !DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpData TYPE (T_NOTIFYICONDATA_SuperDeluxe) lpData ! PNOTIFYICONDATAA lpData END FUNCTION Shell_NotifyIcon_SuperDeluxe END INTERFACE END MODULE ShellSuperDeluxe [/fortran]Be mindful that when building your own types to use for interfacing to the Win32 API that alignment issues can cause trouble. If there are odd length components (I can't see any above) the compiler may not lay things out in memory as the operating system expects. You may need to tell the compiler with !DEC$ or a command line switch what the alignment is (byte packed on x86?).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many many thanks to you lanH.
Works like a charm...well...as far as the old version do :)
Ballon Tip wont pop up at this time, but i am sure that there is some error in my code as a reason for that.
Never thought that this will be gonna be so easy to "manipulate" the fortan modules for your own business.
You saved my life :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again.and set cbSize = NOTIFYICONDATAA_V3_SIZE.
Maybe one of you can help me once again.
I am able to create a BalloonTip now, but the problem is, that no text is visible. Was a horrible way of searchig through the internet to realize that the cbSize Attribute has NOT to be set as sizeof(notifyicon) because the BalloonTip wont pop up then. So i created 3 Parameters
[fortran]integer, parameter:: NOTIFYICONDATAA_V1_SIZE = 88 integer, parameter:: NOTIFYICONDATAA_V2_SIZE = 488 integer, parameter:: NOTIFYICONDATAA_V3_SIZE = 504[/fortran]
V2 working too, V1 not...guess that is for WinXP.
But i do have another problem now.
The only thing i see is a stupid + sign within the text area. Title have no text.
I think, that the text itself which i setted in szInfoTitle and szInfo is not correctly sent to the API.
My declaration of the Interface and the special NotifyIcon type is exactly as lanH wrote above.
I tried the following
[fortran]nisd%szInfo = "test"C nisd%szInfo = "test"//char(0) nisd%szInfo = trim(adjustl("test") write(nisd%szInfo,*) "test"C[/fortran]
None of them worked...any other suggestions?
Best Regards
Oliver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting ratzeputz
I am able to create a BalloonTip now, but the problem is, that no text is visible. Was a horrible way of searchig through the internet to realize that the cbSize Attribute has NOT to be set as sizeof(notifyicon) because the BalloonTip wont pop up then. So i created 3 Parametersand set cbSize = NOTIFYICONDATAA_V3_SIZE.
- integer,parameter::NOTIFYICONDATAA_V1_SIZE=88
- integer,parameter::NOTIFYICONDATAA_V2_SIZE=488
- integer,parameter::NOTIFYICONDATAA_V3_SIZE=504
[fortran]integer, parameter:: NOTIFYICONDATAA_V1_SIZE = 88 integer, parameter:: NOTIFYICONDATAA_V2_SIZE = 488 integer, parameter:: NOTIFYICONDATAA_V3_SIZE = 504[/fortran]
V2 working too, V1 not...guess that is for WinXP.
I had a look at the headers and the size of the szTip member has changed with Windows version. You can't use my shortcut of having the previous type as a component of the new type. Try this instead...
[fortran] TYPE :: T_NOTIFYICONDATA_SuperDeluxe SEQUENCE INTEGER(DWORD) :: cbSize INTEGER(HANDLE) :: hWnd INTEGER(UINT) :: uID INTEGER(UINT) :: uFlags INTEGER(UINT) :: uCallbackMessage INTEGER(HANDLE) :: hIcon CHARACTER(128) :: szTip INTEGER(DWORD) :: dwState INTEGER(DWORD) :: dwStateMask CHARACTER(256) :: szInfo INTEGER(UINT) :: uTimeout_or_uVersion CHARACTER(64) :: szInfoTitle INTEGER(DWORD) :: dwInfoFlags TYPE(T_GUID) :: guidItem INTEGER(HANDLE) :: hBalloonIcon END TYPE T_NOTIFYICONDATA_SuperDeluxe[/fortran]This gives a size of 508 bytes, which matches the size given by the C headers in version 7.0A of the Windows SDK (I think that's Server 2008 level, but maybe its Vista). Sorry about that.
By the way - the MSDN docs are worth a read if you haven't already. Lots of Windows version related stuff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi lanH and thanks again for your help.
I realized, that the size must be wrong, cause everytime i changed the size in cbSize, i saw that the BalloonTip does have another behavior. But how the hell did you find out, that the WinAPI needs a size of 508 bytes then?
I am always using the msdn docu (its one of the best docus ive ever seen by the way) but this thing i did not saw :)
Thanks again for your superdeluxe type :). Will give it a try and callback if it works...or not :)
edit for callback:
it works...many many thanks.
well it works under win7. hope that it will do under vista and xp too.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page