The MASM Forum

General => The Campus => Topic started by: jayanthd on March 15, 2013, 08:13:46 PM

Title: MASM example code needed
Post by: jayanthd on March 15, 2013, 08:13:46 PM
Please see this link http://www.winasm.net/forum/index.php?showtopic=4139


I am doing a project using WinASM and ml.exe assembler. I now this forum is for MASM32. Registration at MASM forum is disabled, so I am asking the question here. I need a MASM code for the application (GUI) shown in the above link. The code should take string input like "12345" from the first textbox and then convert it to integer like 12345 and then do two operations like number + 12 and number * 12 and convert the results to strings and display it in the other two textboxes. This should happen when Generate button is clicked. When Exit button is clicked the program should exit to windows. Also mention how to change the caption of a label through code.
Title: Re: MASM example code needed
Post by: sinsi on March 15, 2013, 09:54:55 PM
QuoteThe code should take string input like "12345" from the first textbox and then convert it to integer like 12345
Use something like atodw and store the value
Quoteand then do two operations like number + 12 and number * 12
value+12, store it, value*12, store it
Quoteand convert the results to strings and display it in the other two textboxes.
Use dwtoa on the two stored values, use SetWindowText to display them
QuoteThis should happen when Generate button is clicked.
Handle WM_COMMAND in your wndproc
QuoteWhen Exit button is clicked the program should exit to windows.
Handle WM_COMMAND and send WM_CLOSE
QuoteAlso mention how to change the caption of a label through code.
SetWindowText

Now knock some code together for us to critique  :biggrin: no homework handouts here.
Title: Re: MASM example code needed
Post by: dedndave on March 15, 2013, 10:50:03 PM
Quote from: jayanthd on March 15, 2013, 08:13:46 PM
Registration at MASM forum is disabled....

this is the "new" masm32 forum
the one that is disabled is the "old" masm32 forum, which is us   :biggrin:
it is left as is, so that the information there may be accessed using the forum search tool

it helps to break the project into seperate pieces
get each piece to work, and add the pieces together

as for the edit boxes, there are a number of examples in the masm32\examples folder
you can also find many in the (old and new) forum contents by using the search tool
by browsing the forum, you can see what problems others have had, and how they were overcome

you can create buttons and edit boxes by using statements in a resource file or by using CreateWindowEx
i prefer the latter but, for beginners, the resource file may be simpler

the math part (adding and multiplying) is pretty simple x86 code
you can also find examples of these using the search tool, especially multiply (add is easy)

so, what is left is the type conversion part - converting between binary and ASCII decimal formats
this is generally a two-part process - ASCII/binary conversion and base conversion
as Sinsi mentioned, there are pre-written routines and macros in the masm32 package
you can even look in masm32\macros\macros.asm and the masm32\m32lib folder to see how they work
and, again, the forum search tool will find you other examples of type conversion functions
Title: Re: MASM example code needed
Post by: jayanthd on March 15, 2013, 10:53:19 PM
Quote from: sinsi on March 15, 2013, 09:54:55 PM
QuoteThe code should take string input like "12345" from the first textbox and then convert it to integer like 12345
Use something like atodw and store the value
Quoteand then do two operations like number + 12 and number * 12
value+12, store it, value*12, store it
Quoteand convert the results to strings and display it in the other two textboxes.
Use dwtoa on the two stored values, use SetWindowText to display them
QuoteThis should happen when Generate button is clicked.
Handle WM_COMMAND in your wndproc
QuoteWhen Exit button is clicked the program should exit to windows.
Handle WM_COMMAND and send WM_CLOSE
QuoteAlso mention how to change the caption of a label through code.
SetWindowText

Now knock some code together for us to critique  :biggrin: no homework handouts here.


How to get Text from textbox? Should I use GetDlgItemText API? Can you show an example code of using GetDlgItemText(0 and SetWindowText()? I have win32API help file but GetWindowText, GetWindowsTextA is not mentioned in it.
Title: Re: MASM example code needed
Post by: dedndave on March 15, 2013, 11:05:14 PM
it's an "edit control" - often called an "edit box"

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775458%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb775458%28v=vs.85%29.aspx)

on the left of that page, you will see sub-sections
after you have read the description pages, the reference pages will help as a guide
you are interested in the functions and style constants, of course
but, also, much of the work is done with the messages and notifications
we often control the box by using SendMessage to send messages to the edit control
and we often get feedback by writing code to handle the notifications sent to the parent window
Title: Re: MASM example code needed
Post by: dedndave on March 15, 2013, 11:27:43 PM
here is a simple example to get you started.....

masm32\examples\dialogs_later\gettext

type some text into the edit control, then press enter
Title: Re: MASM example code needed
Post by: dedndave on March 15, 2013, 11:53:45 PM
buttons are another form of windows controls

http://msdn.microsoft.com/en-us/library/windows/desktop/bb773169%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb773169%28v=vs.85%29.aspx)

i have been working my way through the list, trying each control type
some are more complex than others,
but understanding the documentation gets a little easier with practice   :P

buttons are some of the simpler control types to learn
until you want to do something special - lol
Title: Re: MASM example code needed
Post by: hutch-- on March 16, 2013, 12:17:40 AM
What you need to do when you create a control like an edit control is get its handle, if it is created using CreateWindowEx() then you use its return value as the handle, if its created as a dialog you use the dialog control ID and GetDlgItem() to get its handle. A window handle which is what an edit control produces is a unique ID number within the system which you can then use as a target ID to both get and set text using either Windows messages or Windows API functions.

Now normally you use a GLOBAL value set in the uninitialised data section (.data?) which has global scope and when you get either the return value OR the dialog ID control handle, you copy it into the global variable.



.data?
    hEditControl dd ?
    ........................

.code
    ........................

    mov hEditControl, eax    ; from CreateWindowExd()

    or

    invoke GetDlgItem, hDlg, IDNUM    ; from dialog
    mov hEditControl, eax
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 12:48:26 AM
Quote from: dedndave on March 15, 2013, 11:05:14 PM
it's an "edit control" - often called an "edit box"

http://msdn.microsoft.com/en-us/library/windows/desktop/bb775458%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb775458%28v=vs.85%29.aspx)



Can you give an example code for Edit_GetText and Edit_SetText?


See image (http://www.pixhost.org/show/3144/16325455_edit.jpg)(http://www.pixhost.org/show/3144/16325455_edit.jpg)
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 01:05:27 AM
Quote from: hutch-- on March 16, 2013, 12:17:40 AM
What you need to do when you create a control like an edit control is get its handle, if it is created using CreateWindowEx() then you use its return value as the handle, if its created as a dialog you use the dialog control ID and GetDlgItem() to get its handle. A window handle which is what an edit control produces is a unique ID number within the system which you can then use as a target ID to both get and set text using either Windows messages or Windows API functions.

Now normally you use a GLOBAL value set in the uninitialised data section (.data?) which has global scope and when you get either the return value OR the dialog ID control handle, you copy it into the global variable.



.data?
    hEditControl dd ?
    ........................

.code
    ........................

    mov hEditControl, eax    ; from CreateWindowExd()

    or

    invoke GetDlgItem, hDlg, IDNUM    ; from dialog
    mov hEditControl, eax


@hutch

This is the code of SDI.asm of my SDI project.




.386


.MODEL FLAT,STDCALL


OPTION CASEMAP:NONE


WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD


Include SDI.inc


.CODE
Start:
   Invoke GetModuleHandle, NULL
   MOV hInstance,EAX
   Invoke GetCommandLine
   MOV CommandLine, EAX
   Invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
   Invoke ExitProcess,EAX
   
WinMain Proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
Local wc:WNDCLASSEX
Local msg:MSG
Local hwnd:HWND


   MOV wc.cbSize, SizeOf WNDCLASSEX
   MOV wc.style, CS_HREDRAW or CS_VREDRAW
   MOV wc.lpfnWndProc, Offset WndProc
   MOV wc.cbClsExtra,NULL
   MOV wc.cbWndExtra,NULL
   PUSH hInst
   POP wc.hInstance
   MOV wc.hbrBackground, COLOR_WINDOW+1
   MOV wc.lpszMenuName, NULL
   MOV wc.lpszClassName, Offset ClassName
   Invoke LoadIcon, NULL, IDI_APPLICATION
   MOV wc.hIcon,EAX
   MOV wc.hIconSm,0
   Invoke LoadCursor, NULL, IDC_ARROW
   MOV wc.hCursor,EAX
   Invoke RegisterClassEx, addr wc
   Invoke LoadMenu, hInst, Offset MenuName
   MOV hMenu,EAX
   Invoke CreateWindowEx, WS_EX_CLIENTEDGE, ADDR ClassName, ADDR szAppName,\
           WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,\
           CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenu,\
           hInst, NULL
   MOV hwnd,EAX
   Invoke ShowWindow, hwnd, SW_SHOWNORMAL
   Invoke UpdateWindow, hwnd
   .While TRUE
      Invoke GetMessage, ADDR msg, NULL, 0, 0
      .Break .If (!EAX)
      Invoke TranslateMessage, ADDR msg
      Invoke DispatchMessage, ADDR msg
   .EndW
   MOV EAX, msg.wParam
   RET
WinMain endp
WndProc Proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
   .If uMsg==WM_DESTROY
      Invoke PostQuitMessage, NULL
   .ElseIf uMsg==WM_COMMAND
      MOV EAX,wParam
      .If AX==IDM_FILE_NEW
         Invoke MessageBox, NULL, ADDR szFileNew, Offset szAppName, MB_OK
      .ElseIf AX==IDM_FILE_OPEN
         Invoke MessageBox, NULL, ADDR szFileOpen, Offset szAppName, MB_OK
      .ElseIf AX==IDM_HELP_ABOUT
         Invoke MessageBox, NULL,ADDR szHelpAbout, Offset szAppName, MB_OK
      .Else
         Invoke DestroyWindow, hWnd
      .EndIf
   .Else
      Invoke DefWindowProc, hWnd, uMsg, wParam, lParam
      RET
   .EndIf
   XOR EAX,EAX
   RET
WndProc EndP


End Start



This is the code of SDI.inc


Include windows.inc
Include user32.inc
Include kernel32.inc
;-------------------------------------------------------------------
;Needed For Debug Window Only
;Include masm32.inc
;Include debug.inc
;-------------------------------------------------------------------
IncludeLib user32.lib
IncludeLib kernel32.lib
;-------------------------------------------------------------------
;Needed For Debug Window Only
;IncludeLib masm32.lib
;IncludeLib debug.lib


.DATA
ClassName      DB "MainWinClass",0
szAppName      DB "SDI Application",0
MenuName      DB "FirstMenu",0
szFileNew      DB "You selected 'New'.",0
szFileOpen      DB "You selected 'Open'.",0
szHelpAbout      DB "You selected 'About'.",0


.DATA?
hInstance      HINSTANCE ?
CommandLine      LPSTR ?
hMenu         HMENU ?


.CONST
IDM_FILE_NEW   EQU 1
IDM_FILE_OPEN   EQU 2
IDM_HELP_ABOUT   EQU 3
IDM_FILE_EXIT   EQU 4





I have included SDI.inc in main.asm file.



Title: Re: MASM example code needed
Post by: dedndave on March 16, 2013, 01:36:31 AM
Quote from: jayanthd on March 16, 2013, 12:48:26 AM
Can you give an example code for Edit_GetText and Edit_SetText?

(http://img825.imageshack.us/img825/3366/16325455edit.jpg)

you've got text all over the place, there   :P
that is a much more complex set of controls than what you described
i am guessing that window was created with C++, using a set of advanced controls from .NET

i think you are refering to the "title" text that might appear above an edit control
that is usually done with a "static control", probably the simplest of all the windows controls

http://msdn.microsoft.com/en-us/library/windows/desktop/bb760769%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb760769%28v=vs.85%29.aspx)

(http://img6.imageshack.us/img6/3/tour13.gif)
Title: Re: MASM example code needed
Post by: TouEnMasm on March 16, 2013, 01:49:11 AM

There is a lazy method.Made a search on the masm sample and you find :
masm32\examples\exampl01\resdlg
Who need just littles modifies.
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 01:49:35 AM
Quote from: dedndave on March 16, 2013, 01:36:31 AM
Quote from: jayanthd on March 16, 2013, 12:48:26 AM
Can you give an example code for Edit_GetText and Edit_SetText?
(http://img825.imageshack.us/img825/3366/16325455edit.jpg)

you've got text all over the place, there   :P
that is a much more complex set of controls than what you described
i am guessing that window was created with C++, using a set of advanced controls from .NET

i think you are refering to the "title" text that might appear above an edit control
that is usually done with a "static control", probably the simplest of all the windows controls

http://msdn.microsoft.com/en-us/library/windows/desktop/bb760769%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb760769%28v=vs.85%29.aspx)


I have three edit boxes and 3 labels which give info about the edit boxes and two buttons. The user enters 123456 into one edit box and when generate button is clicked integer value of the string in edit box should be obtained and value + 12 and value * 12 must be performed and the two results should be converted to string and displayed in the other two edit boxes. That is all I need. I used WinASM because it is easy to create GUI.
Title: Re: MASM example code needed
Post by: dedndave on March 16, 2013, 01:54:54 AM
it probably creates the controls in the resource file (.RC)

(http://www.winasm.net/forum/uploads/post-5-1363328799.jpg)

you want:
(4) static text controls, to show the name of each edit control and "Calc"
(3) edit controls, to show the numbers
(2) button controls

the results could be displayed in simple static text windows
so all you really need is one edit control
but, you can also use an edit control to display results

you could also eliminate the buttons
when they are in the edit control, and press enter, the results can be updated (no Generate button)
the Exit function is taken care of with the close box in the title bar
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 02:06:32 AM
Quote from: dedndave on March 16, 2013, 01:54:54 AM
it probably creates the controls in the resource file (.RC)

(http://www.winasm.net/forum/uploads/post-5-1363328799.jpg)

you want:
(4) static text controls, to show the name of each edit control and "Calc"
(3) edit controls, to show the numbers
(2) button controls

the results could be displayed in simple static text windows
so all you really need is one edit control
but, you can also use an edit control to display results


You got it right dedndave. I need the code to set text to Label (Static Text) or Edit box, but if code is given for both it will be helpful. See attached file. If you have WinASM compile it and see. It is not showing the GUI I created it shows some other GUI. I asked the question in WinASM forum but nobody answers.
Title: Re: MASM example code needed
Post by: dedndave on March 16, 2013, 02:12:02 AM
so - you have a main window - then a dialog box ?
or do you just want the dialog box ?
Title: Re: MASM example code needed
Post by: qWord on March 16, 2013, 02:22:37 AM
I'm allowed to ask for what the resulting application is used?
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 03:10:27 AM
Quote from: dedndave on March 16, 2013, 02:12:02 AM
so - you have a main window - then a dialog box ?
or do you just want the dialog box ?


@dedndave


I don't need the main windows. I need just the Dialog window.


Here is my new WinASM project. I have used the Dialog>Base for the GUI. Please provide me the code.



Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 03:13:40 AM
Quote from: qWord on March 16, 2013, 02:22:37 AM
I'm allowed to ask for what the resulting application is used?


@qWord


I am actually doing some project where user inputs a numerical value and depending upon that some calulation is done and numerical result is converted to string and displayed in the Edit box. So, I want to know how to do it. What I have mentioned here is not the actual project. I have done such projects in VB, VB.Net, VC#.net, Delphi but I want to try it in ASM.
Title: Re: MASM example code needed
Post by: qWord on March 16, 2013, 04:00:47 AM
Quote from: jayanthd on March 16, 2013, 03:13:40 AMI am actually doing some project where user inputs a numerical value and depending upon that some calulation is done and numerical result is converted to string and displayed in the Edit box.
AFAICS we have a 'Generate'-Button and a output string of the form '1-234-567-890' (from your source) - I would call this a Key generator   ::)
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 04:17:48 AM
Quote from: qWord on March 16, 2013, 04:00:47 AM
Quote from: jayanthd on March 16, 2013, 03:13:40 AMI am actually doing some project where user inputs a numerical value and depending upon that some calulation is done and numerical result is converted to string and displayed in the Edit box.
AFAICS we have a 'Generate'-Button and a output string of the form '1-234-567-890' (from your source) - I would call this a Key generator   ::)


No. It is not a keygen. I just was trying to assign some initial value to Edit box. Actually it will be in the form "1234567890". There won't be hypens. See add.zip in reply 17.
Title: Re: MASM example code needed
Post by: qWord on March 16, 2013, 05:57:23 AM
Well, I can't help you with WinASM, but the attached example (MASM32 SDK 11) shows an advanced solution that validates the input while the user types the number in.
This is done using the CRT function sprintf() and sscanf(). Also remarks the fn- and rv-macros, which are described in the help file \masm32\help\hlhelp.chm.
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 06:07:13 AM
Quote from: qWord on March 16, 2013, 05:57:23 AM
Well, I can't help you with WinASM, but the attached example (MASM32 SDK 11) shows an advanced solution that validates the input while the user types the number in.
This is done using the CRT function sprintf() and sscanf(). Also remarks the fn- and rv-macros, which are described in the help file \masm32\help\hlhelp.chm.


It is giving fatal error. http://www.pixhost.org/show/3145/16328592_masm32.jpg (http://www.pixhost.org/show/3145/16328592_masm32.jpg)


Ok. Give MASM32 code.
Title: Re: MASM example code needed
Post by: dedndave on March 16, 2013, 09:13:49 AM
that error generally occurs when you already have an instance of the program running
terminate it before assembling   :t
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 04:39:28 PM
Quote from: dedndave on March 16, 2013, 09:13:49 AM
that error generally occurs when you already have an instance of the program running
terminate it before assembling   :t


Yes. It compiled after I followed your method but when I run it, it doesn't appear on the screen. It is shown in Task Manager (RCDlg.exe)
No GUI of the app on screen.
Title: Re: MASM example code needed
Post by: jj2007 on March 16, 2013, 06:19:52 PM
It assembles just fine. Check if the right resource file, if any, is being used. The rc file is named after the asm file, i.e. RCDlg.rc. There are some IDEs which understand that, such as RichMasm, but others may look for rsrc.rc and will not find it.
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 06:28:45 PM
Quote from: jj2007 on March 16, 2013, 06:19:52 PM
It assembles just fine. Check if the right resource file, if any, is being used. The rc file is named after the asm file, i.e. RCDlg.rc. There are some IDEs which understand that, such as RichMasm, but others may look for rsrc.rc and will not find it.


I already said it assembles and links but If I run the RCDlg.exe created it doesn't show any GUI on the screen but I can see it in Task Manager.
Title: Re: MASM example code needed
Post by: jj2007 on March 16, 2013, 06:52:04 PM
Yes. That is because it does not link in the resource file, as described above. Read posts carefully before responding.
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 07:08:44 PM
Quote from: jj2007 on March 16, 2013, 06:52:04 PM
Yes. That is because it does not link in the resource file, as described above. Read posts carefully before responding.


Thanks. It worked after including the RCDlg.rc file in the .asm file. I need a sample code for button click that is if Generate button is clicked then the results should be generated. Now it is generating the result if text changes in 1st edit box.
Title: Re: MASM example code needed
Post by: dedndave on March 16, 2013, 09:34:40 PM
most of us don't use the IDE you are using
some use IDE's, some just use batch files

we can modify the assembly behaviour by choosing different batch files
the ones i use look for "%1.rc", then "rsrc.rc" in the same folder as the asm file
if either is found, it is compiled with the resource compiler, then linked with the rest of the program
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 10:11:53 PM
Quote from: dedndave on March 16, 2013, 09:34:40 PM
most of us don't use the IDE you are using
some use IDE's, some just use batch files

we can modify the assembly behaviour by choosing different batch files
the ones i use look for "%1.rc", then "rsrc.rc" in the same folder as the asm file
if either is found, it is compiled with the resource compiler, then linked with the rest of the program


I am talking about RCDlg.zip


I got it working. It is a MASm32 program. Can you modify it so that result is generated when button is clicked?
Title: Re: MASM example code needed
Post by: dedndave on March 16, 2013, 10:37:54 PM
the way qWord has it written, no "generate" button is really needed
it updates the results any time the value in the input edit control changes

that's a pretty nice example   :t

if you still want it modified, i can do it
Title: Re: MASM example code needed
Post by: jayanthd on March 16, 2013, 10:42:08 PM
Quote from: dedndave on March 16, 2013, 10:37:54 PM
the way qWord has it written, no "generate" button is really needed
it updates the results any time the value in the input edit control changes

that's a pretty nice example   :t

if you still want it modified, i can do it


Yes. Modify it. I want some code for button click procedure.
Title: Re: MASM example code needed
Post by: dedndave on March 16, 2013, 10:57:34 PM
see if this is what you want
i tried not to mess up qWord's nice program   :P

i added the rgbCurrent and rc8 variables and moved a little bit of code
Title: Re: MASM example code needed
Post by: qWord on March 17, 2013, 02:25:43 AM
being not happy with daves hack, I've reworked the example: Coloring and calculation is separated and the code is TCHAR aware  :biggrin:

qWord
Title: Re: MASM example code needed
Post by: jayanthd on March 17, 2013, 02:54:45 AM
Quote from: dedndave on March 16, 2013, 10:57:34 PM
see if this is what you want
i tried not to mess up qWord's nice program   :P

i added the rgbCurrent and rc8 variables and moved a little bit of code


@dedndabe and qword


Both the files are not working. I added the line


include "RCDlg.rc" in the .asm file and tried building but it says cannot open file RCDlg.rc but the RCDlg.exe of qword is working but dedndave's RCDlg.exe is not showing up on screen. Is there any other method to include the .rc file?
Title: Re: MASM example code needed
Post by: dedndave on March 17, 2013, 03:07:08 AM
Quote from: qWord on March 17, 2013, 02:25:43 AM
being not happy with daves hack, I've reworked the example: Coloring and calculation is separated and the code is TCHAR aware  :biggrin:

qWord
::)

Jay
RC files are not ASM INClude files - they actually follow C syntax
you must compile them using rc.exe - or use Pelle's linker
if you use rc.exe, it creates an OBJ file that can be linked with the rest of your program

your IDE has a way to add an RC file to the project
that is what you really want to learn how to do, if you are to stay with that IDE
the IDE compiles the RC file and links the OBJ for you
Title: Re: MASM example code needed
Post by: jayanthd on March 17, 2013, 03:15:14 AM
Quote from: dedndave on March 17, 2013, 03:07:08 AM
Quote from: qWord on March 17, 2013, 02:25:43 AM
being not happy with daves hack, I've reworked the example: Coloring and calculation is separated and the code is TCHAR aware  :biggrin:

qWord
::)

Jay
RC files are not ASM INClude files - they actually follow C syntax
you must compile them using rc.exe - or use Pelle's linker
if you use rc.exe, it creates an OBJ file that can be linked with the rest of your program

your IDE has a way to add an RC file to the project
that is what you really want to learn how to do, if you are to stay with that IDE
the IDE compiles the RC file and links the OBJ for you


I have placed all your files + rsrc.rc in the same folder and using Build All command. I am using MASM32. Where is the menu to build RC files? I tried even opening RCDlg.rc file in MASM32 and used Compile Resource file but it is giving error rsrc.res file not found.


I put rc.exe in the project folder and used the command C:\qwordrcdlgmod\rc rcdlg.rc but the .obj file is not created.
Title: Re: MASM example code needed
Post by: dedndave on March 17, 2013, 03:21:05 AM
ahhh - ok
in the masm32\bin folder, you will find a number of batch files
and, if you use Hutch's QuickEditor (qe.exe), they may be accessed through the menus

with Hutch's original batch files, the resource file should be named rsrc.rc
you can modify the batch files to first look for ProjectName.rc

these batch files will show you what the process is for building ASM projects   :t
Title: Re: MASM example code needed
Post by: jayanthd on March 17, 2013, 03:27:36 AM
Quote from: dedndave on March 17, 2013, 03:21:05 AM
ahhh - ok
in the masm32\bin folder, you will find a number of batch files
and, if you use Hutch's QuickEditor (qe.exe), they may be accessed through the menus

with Hutch's original batch files, the resource file should be named rsrc.rc
you can modify the batch files to first look for ProjectName.rc

these batch files will show you what the process is for building ASM projects   :t


See my last post. It is updated. See attachment in this post. Tell me the method to Compile RCDLg.rc file
Title: Re: MASM example code needed
Post by: qWord on March 17, 2013, 03:40:00 AM
Quote from: dedndave on March 17, 2013, 03:07:08 AM
Quote from: qWord on March 17, 2013, 02:25:43 AM
being not happy with daves hack, I've reworked the example: Coloring and calculation is separated and the code is TCHAR aware  :biggrin:

qWord
::)
for your mod, type a number in and press the button several times to see why I'm not happy with that solution.
Title: Re: MASM example code needed
Post by: qWord on March 17, 2013, 03:44:12 AM
Quote from: jayanthd on March 17, 2013, 03:15:14 AMI put rc.exe in the project folder and used the command C:\qwordrcdlgmod\rc rcdlg.rc but the .obj file is not created.
yes, instead the the file rcdlg.res should be created. This file must be specified beside the object file, which is created by MASM:
link rcdlg.obj rcdlg.res
Title: Re: MASM example code needed
Post by: dedndave on March 17, 2013, 03:45:53 AM
here is qWord's latest version - plus a batch file i made to build it
unzip the attachment and double-click on the batch file
Title: Re: MASM example code needed
Post by: dedndave on March 17, 2013, 04:04:16 AM
what i neglected to mention, before....

RC.exe compiles the RC file to a RES file, RC -> RES
CVTRES.exe converts the RES file to an OBJ file that may be linked, RES -> OBJ

Pelle's linker has the capability to link RES files, directly, so a step is eliminated
Title: Re: MASM example code needed
Post by: jayanthd on March 17, 2013, 04:20:28 AM
Quote from: qWord on March 17, 2013, 03:44:12 AM
Quote from: jayanthd on March 17, 2013, 03:15:14 AMI put rc.exe in the project folder and used the command C:\qwordrcdlgmod\rc rcdlg.rc but the .obj file is not created.
yes, instead the the file rcdlg.res should be created. This file must be specified beside the object file, which is created by MASM:
link rcdlg.obj rcdlg.res


Is it link rcdlg.obj rcdlg.res or link rcdlg.res rcdlg.obj ?

Title: Re: MASM example code needed
Post by: jayanthd on March 17, 2013, 04:23:01 AM
Quote from: dedndave on March 17, 2013, 04:04:16 AM
what i neglected to mention, before....

RC.exe compiles the RC file to a RES file, RC -> RES
CVTRES.exe converts the RES file to an OBJ file that may be linked, RES -> OBJ

Pelle's linker has the capability to link RES files, directly, so a step is eliminated


I created the rcdlg.RES file from rcdlg.RC file using rc.exe and Then I created rcdlg.obj file from rcdlg.res using cvtres.exe


What is pelles's linker? Is it polink.exe?


But when I compile rcdlg.asm it also created rcdlg.obj and overwrites the rcdlg.obj created earlier.
Title: Re: MASM example code needed
Post by: Gunther on March 17, 2013, 04:35:51 AM
Hi jayanthd,

Quote from: jayanthd on March 17, 2013, 04:23:01 AM
What is pelles's linker? Is it polink.exe?

yes, it's polink.exe.

Quote from: jayanthd on March 17, 2013, 04:23:01 AM
But when I compile rcdlg.asm it also created rcdlg.obj and overwrites the rcdlg.obj created earlier.

You could solve that problem with a command line switch. Please check out ml /?. I think it's the switch ml /Fo, which lets you specify another output name for the OBJ file.

Gunther
Title: Re: MASM example code needed
Post by: dedndave on March 17, 2013, 04:53:03 AM
Quote from: jayanthd on March 17, 2013, 04:23:01 AM
But when I compile rcdlg.asm it also created rcdlg.obj and overwrites the rcdlg.obj created earlier.

if you look at the batch file i created,
you will notice that the OBJ created from the resource file is renamed to "rsrc" to avoid this conflict
Title: Re: MASM example code needed
Post by: Gunther on March 17, 2013, 06:03:05 AM
Hi jayanthd,

so, you've the full answer for your question.

Gunther
Title: Re: MASM example code needed
Post by: dedndave on March 17, 2013, 06:20:37 AM
perhaps he doesn't understand how to view/edit batch files
they are text files, but if you double-click on them, they execute   :P

to edit or view a batch file, right-click, then open with - i generally use notepad
Title: Re: MASM example code needed
Post by: Gunther on March 17, 2013, 06:43:04 AM
Quote from: dedndave on March 17, 2013, 06:20:37 AM
to edit or view a batch file, right-click, then open with - i generally use notepad

Any text editor will do the job.

Gunther
Title: Re: MASM example code needed
Post by: dedndave on March 17, 2013, 01:14:41 PM
i just opened one
i used right click - edit   :P
it opened in notepad
Title: Re: MASM example code needed
Post by: japheth on March 17, 2013, 01:39:59 PM
Quote from: jayanthd on March 17, 2013, 04:23:01 AM
I created the rcdlg.RES file from rcdlg.RC file using rc.exe and Then I created rcdlg.obj file from rcdlg.res using cvtres.exe

It's not necessary to launch cvtres.exe explicitly - it's called by MS link internally whenever it detects an input file to be a compiled resource. Also, this "strategy" avoids possible naming conflicts - as in your case.
Title: Re: MASM example code needed
Post by: jayanthd on March 18, 2013, 04:54:39 AM
Thanks everybody. dedndave's files are working but I am not able to use his batch file for other versions of RCDlg posted in this thread. I opened the batch file in edit pad and changed the file names according to the other RCDlg versions but when I use the batch file to build the projects it says cannot open file... when I get some time I will post the screenshots.


I know how to edit batch files. I learn't that while using DOS.  ;)



Title: Re: MASM example code needed
Post by: dedndave on March 18, 2013, 05:45:31 AM
i wrote that batch file specifically for that project
if it can't find the file, then you have to examine the names used in the batch more closely
you could replace the project name in the batch with %1, then provide the project name on the batch command line
that assumes that all the files have the same base filename


QuoteIt's not necessary to launch cvtres.exe explicitly - it's called by MS link internally whenever it detects an
input file to be a compiled resource. Also, this "strategy" avoids possible naming conflicts - as in your case.
thanks for the tip, Andreas - i'll give it a try   :t