flat assembler
Message board for the users of flat assembler.

Index > Windows > Animated cursor resources

Author
Thread Post new topic Reply to topic
inskipp



Joined: 23 Jun 2003
Posts: 25
Location: Poland
inskipp 19 Aug 2003, 13:52
I was trying to use load animeted cursor from resource. How to correct define such resource? I was using this code:
Code:
invoke  LoadCursor,image_base,IDR_CURSOR  ;this funcion returns 0

...

section '.rsrc' resource data readable

directory   RT_ICON,icons,\
    RT_VERSION,versions,\
      RT_GROUP_ICON,group_icons,\
        RT_ACCELERATOR,accelerators,\
      RT_MENU,menus,\
    RT_ANICURSOR,cursor


IDR_CURSOR=102h

...

resource       cursor,\
   IDR_CURSOR,LANG_NEUTRAL,my_cursor

fileres        moj_cursor,'res\cursor.ani'    


I can load this cursor using LoadCursorFromFile, but i want to load it from resource. Thanks for any help.
Post 19 Aug 2003, 13:52
View user's profile Send private message ICQ Number Reply with quote
Barf



Joined: 17 Sep 2004
Posts: 34
Location: Poland
Barf 17 Sep 2004, 19:00
You should use LoadCursor. In first param you write hInstance of your prog, and in second number of resource.
Post 17 Sep 2004, 19:00
View user's profile Send private message Reply with quote
barmentalisk



Joined: 06 Sep 2005
Posts: 36
barmentalisk 20 Feb 2009, 10:58
I still dont know how to put animated cursor into resource section.
"fileres" is illegal instruction, ...

Could somebody place here working example of adding ani-cursor to resource section?
Post 20 Feb 2009, 10:58
View user's profile Send private message Reply with quote
barmentalisk



Joined: 06 Sep 2005
Posts: 36
barmentalisk 20 Feb 2009, 11:53
Oh, wah, I did it!
If somebody still need - take it:

Code:

; Template for program using standard Win32 headers

format PE GUI 4.0
entry start

include 'win32w.inc'

section '.data' data readable writeable

  _class TCHAR 'FASMWIN32',0
  _title TCHAR 'Win32 program template',0
  _error TCHAR 'Startup failed.',0

  wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class

  msg MSG

section '.code' code readable executable

  start:

        invoke  GetModuleHandle,0
        mov     [wc.hInstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc.hIcon],eax
        invoke  LoadCursor,[wc.hInstance],12345
        mov     [wc.hCursor],eax
        invoke  RegisterClass,wc
        test    eax,eax
        jz      error

        invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,256,192,NULL,NULL,[wc.hInstance],NULL
        test    eax,eax
        jz      error

  msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        cmp     eax,1
        jb      end_loop
        jne     msg_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  error:
        invoke  MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK

  end_loop:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc hwnd,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     .finish
  .wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  .finish:
        pop     edi esi ebx
        ret
endp

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL'

  include 'api\kernel32.inc'
  include 'api\user32.inc'

section '.rsrc' resource data readable

  directory RT_ANICURSOR,anicurs

  resource anicurs,12345,LANG_NEUTRAL,anicur

  resdata anicur
    file 'cursor.ani'
  endres
    
Post 20 Feb 2009, 11:53
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.