News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using VB as resource for assembly program

Started by white scorpion, May 26, 2006, 03:41:21 PM

Previous topic - Next topic

white scorpion

Hi guys,

A while ago i read a piece of text where was explained how to simply create GUI's for your assembly programs by creating the GUI in Visual Basic and then using it's resources to build an assembly program.
Unfortunately i don't know where it is or how to do this. I've tried resourcehacker to extract the resources out of the executable, but this left me with a very small part, not even the button locations are in there  :'(

My reason to do this:



I haven't got a clue on how to put that image into the program while is it SO easy to do it in VB.
I've checked the program with a disassembler the following is pushed on the stack

0012FE8C   00400000  |hInst = 00400000
0012FE90   00000001  |ResourceName = 1
0012FE94   00000001  |Type = IMAGE_ICON
0012FE98   00000010  |Width = 10 (16.)
0012FE9C   00000010  |Height = 10 (16.)
0012FEA0   00000000  \Options = LR_DEFAULTCOLOR

before calling

7343045D   FF15 4C164273    CALL DWORD PTR DS:[<&USER32.LoadImageA>] ; USER32.LoadImageA


Although this is all logical, i still don't know how to set it in the resource file other then

#define ImageName              1001
ImageName   IMAGE_ICON    "mypicture.jpg"


But how do i define the location of the image in the resource  file and how do i actually trigger it to load?

With LoadIcon i use

invoke SendMessage,hwnd,WM_SETICON,FALSE,eax

to actually use the icon.

I've searched msdn for a long time, but am still unable to find something that might help me.

Any ideas anyone?

hutch--

Scorpion,

Do yourself a favour, create the dialog in a resource editor, trying to convert VB to a useful format is too much work.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

P1

Quote from: White Scorpion on May 26, 2006, 03:41:21 PMA while ago i read a piece of text where was explained how to simply create GUI's for your assembly programs by creating the GUI in Visual Basic and then using it's resources to build an assembly program.
Post the reference.  I think you may have read it wrong.

Regards,  P1  :8)

white scorpion

QuotePost the reference.  I think you may have read it wrong.
That's the problem, i don't have it anymore.
I think eczelion wrote it though, but i'm not sure..

Hutch, which editor do you recommend? I never used a resourceeditor before, but it's never too late to learn  :toothy

Ossa

Grab a copy of RadASM - it has a built-in resource editor. (and has all its other great features... and it works with (nearly) whatever assembler you like (MASM, HLA, FASM, etc) - MASM for you I guess)

Ossa
Website (very old): ossa.the-wot.co.uk

white scorpion

I've heared about RadASM before, but i was under the impression it was an assembler, not a front-end.
Will take a look at it right away!

Vortex

i) Symantec Resource Studio V1.0

http://movsd.com/download/nre.exe

ii) Poide's ( Pelles IDE ) built-in resource editor

iii) Open Watcom's resource editor

tenkey

Quote from: White Scorpion on May 26, 2006, 03:41:21 PM
A while ago i read a piece of text where was explained how to simply create GUI's for your assembly programs by creating the GUI in Visual Basic and then using it's resources to build an assembly program.

It's more likely that the description was for using Visual Studio, not Basic. You could create makefile projects for VS up to version 6. Don't know about the later versions.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

white scorpion

#8
QuoteIt's more likely that the description was for using Visual Studio, not Basic. You could create makefile projects for VS up to version 6. Don't know about the later versions.
That's possible. I could have been mistaken...

I've started creating the project in RadASM after my last post, and i already created a large part of the program, including the image, BUT, the image won't show up when i assemble the program.

Here's what i've done:
-Click button Image
-Create a square where the image should come
-Select Type Bitmap
-Selected image file

It is now visible in the editor, but like i said, when i assemble the complete project it doesn't show up in my program :(
This is really driving me crazy!!! :dazzled:

Btw, i really like RadASM, too bad i didn't start using it before. It really saves a lot of time  :dance:
[EDIT]never mind, i finally got it to work:

.elseif uMsg==WM_PAINT
        invoke LoadBitmap,hInstance,501
        mov hBitmap,eax
        invoke BeginPaint,hWnd,ADDR ps
        mov hdc,eax
        invoke CreateCompatibleDC,hdc
        mov hmem,eax
        invoke SelectObject,hmem,hBitmap
        invoke GetClientRect,hWnd,ADDR rc
        invoke BitBlt,hdc,5,5,rc.right,rc.bottom,hmem,0,0,SRCCOPY
        invoke DeleteDC,hmem
        invoke EndPaint,hWnd,addr ps
        xor eax,eax     
        ret


That was the code i was missing.[/EDIT]


hutch--

scorpion,

Here is an example of what your dialog is like using a dialog created as an in memory template. This stuff is documented in the dialogs.hlp file in masm32.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

white scorpion


DlgBitmap 5,10,8,123



5 BITMAP MOVEABLE PURE LOADONCALL DISCARDABLE "SCORPION.BMP"

Unbelievable that this is everything you need...
This is so simple when you look at it like this  :clap:

I didn't even knew you could create a dialog this easily. Thanks a lot!

hutch--

BitBlting the image is a better technique within a CreateWindowEx() window as you have more control over it and can change the image and move its location but for a simple interface, a static control with the right style is simple and easy to use.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php