News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Getting my head around resource file compilation

Started by Anaryl, February 25, 2016, 11:53:18 PM

Previous topic - Next topic

jj2007

Quote from: Anaryl on March 07, 2016, 10:19:34 PMSupposedly there's a way to compile them in visual studio

So you are using VS? That explains your difficulties.
Open \Masm32\qeditor.exe and look at the Project menu.

TWell

In Visual Studio remember to add your .rc files into project Recource Files

TouEnMasm

compile with vs
http://masm32.com/board/index.php?topic=4489.msg47997#msg47997
With a batch (Dos,a black screen):
http://stackoverflow.com/questions/9760663/compile-and-run-assembly-file-using-masm-and-context
More questions ?,post a zip file with your working directory.



Fa is a musical note to play with CL

Anaryl

I was using masm/qeditor but that throws an error

http://imgur.com/F0LrhA1

Then I read it has to be compiled form an rc to a res first?

i'll check those links presently.

Anaryl

it wouldnt let me attach the zip to the last post so i'm trying it here.

TWell


GoneFishing

just rename your resource file to what RC wants

jj2007

Quote from: Anaryl on March 08, 2016, 02:42:34 AM
I was using masm/qeditor but that throws an error

http://imgur.com/F0LrhA1

Then I read it has to be compiled form an rc to a res first?

It doesn't hurt to read the error messages: "could not open rsrc.rc" is a very valuable hint IMHO 8)

Anaryl

Quote from: jj2007 on March 08, 2016, 04:11:28 AM
Quote from: Anaryl on March 08, 2016, 02:42:34 AM
I was using masm/qeditor but that throws an error

http://imgur.com/F0LrhA1

Then I read it has to be compiled form an rc to a res first?

It doesn't hurt to read the error messages: "could not open rsrc.rc" is a very valuable hint IMHO 8)

I tried that - same error.

http://imgur.com/prt5svl

jj2007

So what is your theory why rc.exe can't open rsrc.rc?

I have three:
- you forgot to create rsrc.rc
- it's not in the main source's path
- it's open in another application (Visual Crap?), so access denied.
8)

Anaryl

My theory is that it needs to specifically compiled by the rc.exe and that for some reason qeditor can't path rc.exe to the masm32\workspace directory.

I've checked the other ones. I failed at compiling the .rc file before I reinstalled VS so it's not that (but obviously double checked) and it's not failed to create rsrc.rc because when the error came up that seemed like an obvious first step to try (but again I just double checked this).

The thing iwth the pathing though is that the .asm and run program all run fine from qeditor/masm32 - and it works fine with example code (it's basically a rewrite/rubberduck of exeample01\generic\generic.asm - and that code works and compiles perfectly.

So my theory is that rc.exe is either not pathing correctly or I am a noob and have mssed something obvious.

jj2007

Quote from: Anaryl on March 08, 2016, 05:53:53 AM
My theory is that it needs to specifically compiled by the rc.exe and that for some reason qeditor can't path rc.exe to the masm32\workspace directory.

Which app produces error RC 1234?

Seriously: check my three theories above. Obviously, qEditor finds rc.exe, otherwise no RC nnnn errors. It does not find rsrc.rc, though. More precisely, it cannot open rsrc.rc. Does this file exist, and if yes, in which folder? The same as mysource.asm? If the file exists and is in the right folder, it might be open in Visual Crap, so be sure you close that one completely.

If nothing helps, install MasmBasic, open your source in \Masm32\MasmBasic\RichMasm.exe and hit F6. If you have errors, copy the output window's content and post it here.

Anaryl

I gotta admit I was starting to get a bit frustrated here (probably not helped by an impending tobacco scarcity), But your tool actually helped me out here!

** Start A:\Masm32\MasmBasic\Res\bldallRM.bat
***** user-defined OPT_xx variables: ***

*** anawin2.rc not found, will try rsrc.rc ***
OPT_Arg1:
OPT_Arg2:
OPT_Out:  "anawin2.exe"
OPT_Res:  rsrc


*** Assemble, link and run anawin2 ***



rsrc.rc (1): error RC2135 : file not found: MAINICON.ICO
*** Resource "rsrc.rc" could not be created ***

So what seemed to be the problem was the call for Mainicon.ico (a relic from copying and pasting the .rc from the generic dir).


After removing the .ico file

** Start A:\Masm32\MasmBasic\Res\bldallRM.bat
***** user-defined OPT_xx variables: ***
OPT_Arg1:
OPT_Arg2:
OPT_Out:  "anawin2.exe"
OPT_Res:  anawin2


*** Assemble, link and run anawin2 ***

*** Assemble using JWasm /c /coff  /Fl /Sn /Fo "anawin2" ***
JWasm v2.12pre, Feb 18 2014, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.


***********
ASCII build
***********

Tmp_File.asm: 284 lines, 2 passes, 153 ms, 0 warnings, 0 errors
*** Link using polink with sub WINDOWS    "anawin2.obj" rsrc.res /OUT:"anawin2.exe" ***

*** Assembling and linking took 281 milliseconds ***

03/08/2016  07:50 PM             3,072 anawin2.exe
03/08/2016  07:50 PM             2,203 anawin2.obj
03/08/2016  07:50 PM               218 anawin2.rc
03/06/2016  02:54 AM            10,567 anawin2.asm
« OK »** RichMasm warning: Exit code 'still active' **


Output returned when trying to link and run

***********
ASCII build
***********

Tmp_File.asm: 284 lines, 2 passes, 171 ms, 0 warnings, 0 errors
*** Link using polink with sub WINDOWS    "anawin2.obj" rsrc.res /OUT:"anawin2.exe" ***

POLINK: fatal error: Access is denied.
*** Link error ***


Hmmm okay? Check taskman - the application still seems to have been running there. Kill those processes from before.

Try again.

Okay so it seems now that the application doesn't create a window at all now ...

Hmm, alright well at least the .rc compiles ... so back to the drawing board.
[edit] was able to use the Masm editor you linked to get it to compile the code effectively and get it to run straight away.

So my take away here is - why doesn't qeditor automatically compile the rc files? It seems to have permissions issues over actually compiling them. I'm going to fiddle around again with it to see whats causing it. At least now I know the code works.

TWell

RegisterClassEx() still missing from that code?

TouEnMasm

Bad  WNDCLASSEX

   mov wc.cbSize,sizeof WNDCLASSEX
   mov wc.style,CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW
   m2m wc.lpfnWndProc,   WndProc            
   mov wc.cbClsExtra,     NULL      ;obsolete voir API SetProp
   mov wc.cbWndExtra,     NULL
   Push    hInstance
   pop wc.hInstance
   invoke LoadIcon,NULL,IDI_HAND   
   mov wc.hIcon,eax 
   invoke LoadCursor, NULL, IDC_ARROW     ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   mov wc.hCursor,eax    
   m2m wc.hbrBackground,  COLOR_BTNFACE+1         
   mov wc.lpszMenuName,NULL   
   mov wc.lpszClassName, offset szClassName
   mov wc.hIconSm,0
   invoke RegisterClassEx, ADDR wc

bad WM_CLOSE

.elseif uMsg == WM_CLOSE
;---------------------------------------------
; this is the place where various requirements are performed before the app exits to the OS
; such as deleting resources and testing if files have been saved. You have the option of returning
; ZERO if you dont wish the application to close which exits the WndProce procedure without passi
; this messages to the defgault window processing done by the OS
;---------------------------------------------

szText TheText, "Please Confirm Exit"
invoke MessageBox, hWin, ADDR TheText, ADDR szDisplayName,MB_YESNO
    .if eax == IDNO
    return 0
    .endif
   invoke PostMessage,hWin,WM_DESTROY,0,0
.elseif uMsg == WM_DESTROY
Fa is a musical note to play with CL