flat assembler
Message board for the users of flat assembler.

Index > IDE Development > SysTray template bug?

Author
Thread Post new topic Reply to topic
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
It says undefined symbol << mov dword[nid.szTip],"Tray" >> mainform window.... Anyone got any idea?


Code:
PM_SHELLNOTIFY = WM_USER + 1

IDI_TRAY     = 0
IDM_EXIT     = 100
IDM_SHOWHIDE = 101


iglobal
  szShowHide db "&Show/Hide", 0
  szExit     db "&Exit", 0
endg

uglobal
  nid          NOTIFYICONDATA
  uVisibleFlag dd ?
  hTrayMenu    dd ?
endg


winproc MainWindowProc

ondefault
        stc
        ret

onmessage FM_AFTERCREATE

        mov     [nid.cbSize],sizeof.NOTIFYICONDATA              ; prepare tray icon
        push    [hwnd]
        pop     [nid.hWnd]
        mov     [nid.uID],IDI_TRAY
        mov     [nid.uFlags],NIF_ICON+NIF_MESSAGE+NIF_TIP
        mov     [nid.uCallbackMessage],PM_SHELLNOTIFY
        invoke  LoadIcon, NULL,IDI_WINLOGO
        mov     [nid.hIcon],eax
        mov     dword[nid.szTip],"Tray"
        mov     dword[nid.szTip+4], "Demo"
        invoke  Shell_NotifyIcon, NIM_ADD,nid

        invoke  CreatePopupMenu                 ; create tray popup menu - here you
        mov     [hTrayMenu],eax                 ; can add your own menu items
        invoke  AppendMenu, eax,MF_STRING,IDM_SHOWHIDE,szShowHide
        invoke  AppendMenu, [hTrayMenu],MF_STRING,IDM_EXIT,szExit
        clc
        ret

onmessage WM_DESTROY
        invoke  Shell_NotifyIcon, NIM_DELETE,nid
        invoke  DestroyMenu, [hTrayMenu]
        invoke  PostQuitMessage, 0
        clc
        ret

onmessage WM_COMMAND
        cmp     [.lparam],0
        jne     .ondefault

        mov     eax,[.wparam]           ; handle tray popup menu actions
        cmp     eax,IDM_SHOWHIDE        ;
        je      .showhide
        cmp     eax,IDM_EXIT
        je      .idm_exit
        stc
        ret

  .idm_exit:
        invoke  DestroyWindow, [.hwnd]
        clc
        ret


onmessage WM_CLOSE
        jmp     .hide

onmessage PM_SHELLNOTIFY                ; handle tray icons actions:
locals                                  ;  left mouse button - show/hide window
  .pt POINT                             ;  right mouse button - show tray popup menu
endl
        cmp     [.lparam],WM_LBUTTONDOWN
        je      .showhide
        cmp     [.lparam],WM_RBUTTONDOWN
        je      .show_tray_popup
        jmp     .finish
  .showhide:
        cmp     [uVisibleFlag],0
        je      .show
      .hide:
        invoke  ShowWindow, [.hwnd],SW_HIDE
        mov     [uVisibleFlag], 0
        jmp     .finish
      .show:
        invoke  ShowWindow, [.hwnd],SW_SHOW
        mov     [uVisibleFlag], 1
        invoke  SetActiveWindow, [.hwnd]
        jmp     .finish
  .show_tray_popup:
        lea     eax,[.pt]
        invoke  GetCursorPos, eax
        invoke  SetForegroundWindow, [.hwnd]
        invoke  TrackPopupMenu, [hTrayMenu],TPM_RIGHTALIGN,[.pt.x],[.pt.y],\
                                NULL,[.hwnd],NULL
        invoke  PostMessage, [.hwnd],WM_NULL,0,0
  .finish:
        clc
        ret
endwp    
Post 26 Dec 2005, 01:14
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
are you writing this with the Fresh IDE? You need to include the windows headers.
Post 26 Dec 2005, 01:25
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
That was the frm code... This is the.asm code


Code:
format PE GUI 4.0
entry Start

include '%finc%\win32\win32a.inc'
include '%finc%\libs\msgutils.inc'
include '%finc%\libs\strlib.inc'
include '%finc%\libs\templates.inc'
include '%finc%\libs\TForm.inc'
include '%finc%\libs\parents.inc'


section '.code' code readable executable
..ShowSizes = 1
..ShowSkipped = 0

include '%finc%\libs\msgutils.asm'
include '%finc%\libs\strlib.asm'
include '%finc%\libs\templates.asm'
include '%finc%\libs\TForm.asm'
include '%finc%\libs\parents.asm'

include 'mainwindow.frm'

uglobal
  hMainForm dd ?
  hInstance dd ?
endg

Start:
        invoke  GetModuleHandle, 0
        mov     [hInstance], eax
        InitializeAll

        stdcall CreateForm, frmMainWindow, NULL
        mov     [hMainForm],ebx

        include '%finc%\libs\mainloop.asm'
        push    eax
        FinalizeAll
        invoke  ExitProcess


section '.idata' data import readable writeable
ImportTable:
include '%finc%\win32\allimports.asm'
DispSize 'ImportTable', $ - ImportTable

section '.data' data readable writeable
IncludeAllGlobals    
Post 26 Dec 2005, 02:44
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
Code:
        mov     dword[nid.szTip],"Tray"
        mov     dword[nid.szTip+4], "Demo"
    

I see you have nid defined, but how does FASM know what is this szTip?
I'm sorry if I'm misleading you because I haven't coded with Fresh, but this part feels suspicious.
Post 26 Dec 2005, 10:36
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
because it's in the shell32 equates..For some reason it just doesn't want to except it... I think it's a bug. Can anyone please help me with this sigh...
Post 26 Dec 2005, 17:52
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
The variables are not getting defined. I looked in the fresh includes, and noticed a macro called 'IncludeAllGlobals'. I think this macro defines all the data in there proper place. Somewhere in your code put a single line of code:

Code:
 IncludeAllGlobals     


I don't use fresh, but I've read the information in some of the threads and think this will fix the problem.
Post 26 Dec 2005, 22:26
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
still didn't fix it
Post 26 Dec 2005, 23:54
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Sorry, it was my fault. I didn't update win32a.inc file properly, and SysTray template wasn't updated to new macros too. Here's valid win32a.inc for Fresh:

Code:
; Win32 programming headers (ASCII)

;========================================================================
; Macro library options
;========================================================================

..ShowSizes = 1        ; if 1 - displays the messages passed through
                       ; DispSize macro.

..ShowUserMessages = 1 ; if 1 - displays list with user defined Windows
                       ; messages - names and values, created by "message"
                       ; macro.

include '../macro/struct.inc'
include '../macro/exceptions.inc'
include '../macro/proc32.inc'
include '../macro/proc32ex.inc'
include '../macro/import32.inc'
include '../macro/export.inc'
include '../macro/display.inc'
include '../macro/globals.inc'

struc CHAR val { match any, val \{ . db val \}
                 match , val \{ . db ? \} }

include 'equates/kernel32.inc'
include 'equates/user32.inc'
include 'equates/gdi32.inc'
include 'equates/comctl32.inc'
include 'equates/comdlg32.inc'
include 'equates/shell32.inc'
include 'equates/wsock32.inc'    


and mainwindow.fpr (just paste and replace all):

Code:
PM_SHELLNOTIFY = WM_USER + 1

IDI_TRAY     = 0
IDM_EXIT     = 100
IDM_SHOWHIDE = 101


iglobal
  szShowHide db "&Show/Hide", 0
  szExit     db "&Exit", 0
endg

uglobal
  nid          NOTIFYICONDATA
  uVisibleFlag dd ?
  hTrayMenu    dd ?
endg


winproc MainWindowProc

ondefault
        stc
        ret

onmessage FM_AFTERCREATE

        mov     [nid.cbSize],sizeof.NOTIFYICONDATA              ; prepare tray icon
        push    [hwnd]
        pop     [nid.hWnd]
        mov     [nid.uID],IDI_TRAY
        mov     [nid.uFlags],NIF_ICON+NIF_MESSAGE+NIF_TIP
        mov     [nid.uCallbackMessage],PM_SHELLNOTIFY
        invoke  LoadIcon, NULL,IDI_WINLOGO
        mov     [nid.hIcon],eax
        mov     dword[nid.szTip],"Tray"
        mov     dword[nid.szTip+4], "Demo"
        invoke  Shell_NotifyIcon, NIM_ADD,nid

        invoke  CreatePopupMenu                 ; create tray popup menu - here you
        mov     [hTrayMenu],eax                 ; can add your own menu items
        invoke  AppendMenu, eax,MF_STRING,IDM_SHOWHIDE,szShowHide
        invoke  AppendMenu, [hTrayMenu],MF_STRING,IDM_EXIT,szExit
        clc
        ret

onmessage WM_DESTROY
        invoke  Shell_NotifyIcon, NIM_DELETE,nid
        invoke  DestroyMenu, [hTrayMenu]
        invoke  PostQuitMessage, 0
        clc
        ret

onmessage WM_COMMAND
        cmp     [lparam],0
        jne     .ondefault

        mov     eax,[wparam]           ; handle tray popup menu actions
        cmp     eax,IDM_SHOWHIDE        ;
        je      .showhide
        cmp     eax,IDM_EXIT
        je      .idm_exit
        stc
        ret

  .idm_exit:
        invoke  DestroyWindow, [hwnd]
        clc
        ret


onmessage WM_CLOSE
        jmp     .hide

onmessage PM_SHELLNOTIFY                ; handle tray icons actions:
locals                                  ;  left mouse button - show/hide window
  .pt POINT                             ;  right mouse button - show tray popup menu
endl
        cmp     [lparam],WM_LBUTTONDOWN
        je      .showhide
        cmp     [lparam],WM_RBUTTONDOWN
        je      .show_tray_popup
        jmp     .finish
  .showhide:
        cmp     [uVisibleFlag],0
        je      .show
      .hide:
        invoke  ShowWindow, [hwnd],SW_HIDE
        mov     [uVisibleFlag], 0
        jmp     .finish
      .show:
        invoke  ShowWindow, [hwnd],SW_SHOW
        mov     [uVisibleFlag], 1
        invoke  SetActiveWindow, [hwnd]
        jmp     .finish
  .show_tray_popup:
        lea     eax,[.pt]
        invoke  GetCursorPos, eax
        invoke  SetForegroundWindow, [hwnd]
        invoke  TrackPopupMenu, [hTrayMenu],TPM_RIGHTALIGN,[.pt.x],[.pt.y],\
                                NULL,[hwnd],NULL
        invoke  PostMessage, [hwnd],WM_NULL,0,0
  .finish:
        clc
        ret
endwp
    


Now it compiles OK.
Post 27 Dec 2005, 08:22
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.