News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

any way to put texts in rc file instead?

Started by daydreamer, September 12, 2022, 08:57:49 PM

Previous topic - Next topic

daydreamer

Hi
any way to include indirect or direct text in rc file instead of put it in asm source db "Hello",10,13 ?
here is example of file menu and help box uses text from rc file
for example could that be used for any MessageBox ?
note it makes use of "resource.h" that is filled with lots of kind of equates like
#define SMALL   123

//Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1

/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.

IDI_WINDOWSXO       ICON         "x3dtext.ico" //windowsXO.ico"
IDI_SMALL               ICON     "0.ico" //small.ico"
IDI_BACKG ICON "background.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//

IDC_WINDOWSXO MENU
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "E&xit",                IDM_EXIT
    END
    POPUP "&Help"
    BEGIN
        MENUITEM "&About ...",           IDM_ABOUT
    END
END


/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//

IDC_WINDOWSXO ACCELERATORS
BEGIN
    "?",            IDM_ABOUT,              ASCII,  ALT
    "/",            IDM_ABOUT,              ASCII,  ALT
END


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About windowsXO"
FONT 8, "MS Shell Dlg"
BEGIN
    ICON            IDR_MAINFRAME,IDC_STATIC,14,14,21,20
    LTEXT           "windowsXO, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
    LTEXT           "Copyright (c) 2022",IDC_STATIC,42,26,114,8
    DEFPUSHBUTTON   "OK",IDOK,113,41,50,14,WS_GROUP
END

/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
    IDD_ABOUTBOX, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 163
        TOPMARGIN, 7
        BOTTOMMARGIN, 55
    END
END
#endif    // APSTUDIO_INVOKED

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE
BEGIN
    "#ifndef APSTUDIO_INVOKED\r\n"
    "#include ""targetver.h""\r\n"
    "#endif\r\n"
    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
    "#include ""windows.h""\r\n"
    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
    "\0"
END

3 TEXTINCLUDE
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE
BEGIN
   IDC_WINDOWSXO   "WINDOWSXO"
   IDS_APP_TITLE       "windowsXO"
END

#endif
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE resource.
//

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

LiaoMi

Hi Daydreamer,

can be done in a similar way  :azn:

zedd151

#2

#define IDR_RCDATA1 1

#include "C:/masm32/include/RESOURCE.H"


IDR_RCDATA1 RCDATA
BEGIN
"This is text as RCDATA entered directly into a resource file.
Second line of text


"
END


RCDATA perhaps?  STRINGTABLE?
I've never seen any advantages in using the resource section for strings or any kind of text (as opposed to data section) so don't really know why it would be used.
Especially if needed to find resource, load resource, lock resource, etc, etc, blah, blah, blah. Seems more efficient to either use as ascii data; or a little less efficient, but easy to do, to open and load an external file for larger texts with file name as an ascii string in .data.
Or another option embed it in the .code section? As long as it doesn't need to be changed anyway.

daydreamer

great thanks LiaoMi :thumbsup:
the way to learn is sometimes become more versatile,not always learn more advanced topics
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jj2007

Stringtable example attached (you don't need MasmBasic to use it, although wRes$(ID) would be a good choice).

TimoVJL

Quote from: swordfish on September 12, 2022, 09:20:16 PM
STRINGTABLE?
I've never seen any advantages in using the resource section for strings or any kind of text (as opposed to data section) so don't really know why it would be used.
Never heard about multilanguage resources ?
May the source be with you

zedd151

Quote from: TimoVJL on September 13, 2022, 01:52:40 AM
Never heard about multilanguage resources ?
Um, yeah. But I have never had that need personally. And I highly doubt I'll need it in the future either as most of the programs I write were not intended for the masses. Same goes for UNICODE. No real need, seldom if ever used by me intentionally.

daydreamer

great thanks Jochen :thumbsup:
swordfish REALtm assembly programmers compete in 2 main things
fastest speed so I cant resist code in SIMD
smallest size,cant resist 2-4 byte unicodes already made for you if you need chess pieces,mahjong pieces,cards for both card games and tarot program
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jj2007

Quote from: daydreamer on September 13, 2022, 03:17:29 AM2-4 byte unicodes already made for you if you need chess pieces

Indeed one nice application of Unicode :thumbsup:

Vortex

Another good method is to convert the text file into a linkable MS COFF object module. Hutch's fda tool ( File Data Assembler ) can be used for this purpose.

.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\user32.inc
include     \masm32\include\masm32.inc

includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\masm32.lib

EXTERN  szString:DWORD   ; declare the external string

.code

start:

    invoke  StdOut,ADDR szString

    invoke  ExitProcess,0

END start


daydreamer

thanks again Jochen,looks great :thumbsup:
thanks Erol  :thumbsup:
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jj2007

Quote from: daydreamer on September 13, 2022, 06:40:52 PM
thanks again Jochen,looks great :thumbsup:

Thanks, Magnus. There was actually a little glitch (it didn't show the chessboard, just the figures). New version attached.