flat assembler
Message board for the users of flat assembler.

Index > Windows > Resource macros X external resource editor


How do you include resources in your windows app's?
I use an external resource editor and resource compiler and then add the .res to the asm source code.
44%
 44%  [ 8 ]
I code the resource section manually in the source using FASM macros.
55%
 55%  [ 10 ]
Total Votes : 18

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 07 Feb 2006, 02:21
Please vote and explain why.

Is there any tutorial on FASM Resources Macros?

Also, is someone planning on building a resource editor that can output resources macros to include in the asm code?
I mean, not output the windows standard resource language, but FASM macros for resources...

Thanks!

Sorry for my bad english...
Post 07 Feb 2006, 02:21
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 07 Feb 2006, 04:01
i used to just add the .res as i got used to it for nasm, C and etc, but now i try my hardest to not use a resource section and do it all manually but when i 'have' to i just use the fasm-specific stuff now

_________________
redghost.ca
Post 07 Feb 2006, 04:01
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 07 Feb 2006, 10:24
OzzY wrote:
Is there any tutorial on FASM Resources Macros?

http://flatassembler.net/docs.php?article=win32#1.6
Post 07 Feb 2006, 10:24
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 08 Feb 2006, 18:19
If FASM used the same parameter order it would be very easy to include resources in asm code. Sad

Anyway, I'm liking to use FASM resource macros.
SAMPLE CODE:
Code:
include '%fasminc%\win32ax.inc'
;equates
MAINDLG = 1
IDOK = 2
IDEDIT = 3

.data
;resources
data resource
directory RT_DIALOG, dialogs

resource dialogs,\
MAINDLG,LANG_NEUTRAL,maindlg

dialog maindlg,"My Dialog",6, 18, 258, 34,WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_VISIBLE+DS_CENTER
  dialogitem "Button","OK", IDOK, 196, 12, 45, 12,WS_TABSTOP+WS_VISIBLE
  dialogitem "Edit","", IDEDIT, 8, 12, 188, 12, ES_AUTOHSCROLL+WS_BORDER+WS_VISIBLE
enddialog
end data
;end resources

;data
buff rb 80

.code
;begin code
;Not using invoke just to remember the old days Laughing
main:
push 0
call [GetModuleHandle]

push 0
push DlgProc
push 0
push MAINDLG
push eax
call [DialogBoxParam]

ret

proc DlgProc hwnd,msg,wparam,lparam
mov eax,[msg]
cmp eax,WM_CLOSE
jz jclose
cmp eax,WM_COMMAND
jz jcommand

done:
xor eax,eax
ret

processed:
mov eax,1
ret

jclose:
push 1
push [hwnd]
call [EndDialog]
jmp processed

jcommand:
mov eax,[wparam]
cmp ax,IDOK
jnz  processed
shl eax,16
cmp ax,BN_CLICKED
jnz processed

push 80
push buff
push IDEDIT
push [hwnd]
call [GetDlgItemText]

push 0
push 0
push buff
push 0
call [MessageBox]

jmp processed
endp
.end main
;end code
;eof
    


FASM RESOURCE MACROS VERSION:
Code:
directory RT_DIALOG, dialogs

resource dialogs,\
MAINDLG,LANG_NEUTRAL,maindlg

dialog maindlg,"My Dialog",6, 18, 258, 34,WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_VISIBLE+DS_CENTER
  dialogitem "Button","OK", IDOK, 196, 12, 45, 12,WS_TABSTOP+WS_VISIBLE
  dialogitem "Edit","", IDEDIT, 8, 12, 188, 12, ES_AUTOHSCROLL+WS_BORDER+WS_VISIBLE
enddialog
    


Resource editor generated version:
Code:
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

#define MAINDLG 1
#define IDOK 2
#define IDEDIT 3
MAINDLG DIALOGEX DISCARDABLE 6, 18, 258, 34
STYLE 
WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_VISIBLE+DS_CENTER
CAPTION "My Dialog"
BEGIN
  CONTROL "OK", IDOK, "Button", WS_TABSTOP|WS_VISIBLE, 196, 12, 45, 12
  CONTROL "", IDEDIT, "Edit", ES_AUTOHSCROLL+WS_BORDER+WS_VISIBLE, 8, 12, 188, 12
END
    


It wasn't hard to convert rc->fasm macros, but it could automated, especially for big projects.
But I think I use this method by now. I design my dialogs in resource editor to get styles, size of controls and position, and then convert by hand to FASM macros. Then I just include in asm source and there's no need for external resource compiler. Very Happy
What I really like about FASM is: there's no need for a linker, resource compiler, HLL front-end, etc... because FASM macro language is powerful enough for building from low level optimized code to scripting languages. Very Happy


OFFTOPIC:
When I say that I code everything in asm, my teacher at university say "It's impossible. You must use some HLL, because is too hard.", and I say "No! It's not hard! It can be as high level as you want with the help of macros, but you can still keep optimized code. All these, because I use a very good assembler.".
Well, I think most teachers are still in the days of TASM, that could code only for DOS and macros were very simple, or worst, they even don't know what macros are. LOL! Laughing
He thinks I'm a n00b at programming, and I have to participate at pascal classes. I'm becoming really mad about it. I'm l33t coder! Twisted Evil
So, I'm thinking about creating a web page to host my programs made in FASM and C, so I can show it to my teacher and also share with other people who want to learn asm.
Could you tell me some good webhost provider that's: free, enough for host programs and simple HTML? Please do not say "here is a big list of them: <link>". I just want one, simple, and good.

Thank you very much!
Post 08 Feb 2006, 18:19
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.