News:

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

Main Menu

resource file way instead?

Started by daydreamer, June 04, 2020, 06:43:54 AM

Previous topic - Next topic

daydreamer

I am trying to go what seems the modern way of have the textmessages data in resource parted from main file and make use of it in a messagebox that pops up,with all kinds of "loadstring",loadintresource ...
I got it working now but how do I also make caption and other things like the "about box"?
what ID numbers are safe to choose to not interfere with other windows messages?1024?


//
#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_PSEUDO3D       ICON        "pseudo3d.ico"//"rose.ico" dont work
IDI_SMALL               ICON    "small.ico"

/////////////////////////////////////////////////////////////////////////////
//
// Menu
//

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


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

IDC_PSEUDO3D 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 pseudo3d"
FONT 8, "MS Shell Dlg"
BEGIN
    ICON            IDR_MAINFRAME,IDC_STATIC,14,14,21,20
    LTEXT           "pseudo3d, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
    LTEXT           "Copyright (c) 2020",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_PSEUDO3D   "PSEUDO3D"
   IDS_APP_TITLE       "pseudo3d"
IDC_INVENTORY "inventory \nsayonara flute\nhammer\ngoldie key\nlockpick\n"
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

daydreamer

it works with many messageboxes,but it could have been in a more structured way
too many listed after each other will remind of old "spaghetticode"
I am open for suggestions
// String Table
//

STRINGTABLE
BEGIN
   IDC_PSEUDO3D   "PSEUDO3D"
   IDS_APP_TITLE       "pseudo3d"
IDC_INVENTORY "inventory \nsayonara flute\nhammer\ngoldie key\nlockpick\n"
IDC_CHEST "Treasure chest,open it?\ndisarm it?\nleave it?"
IDC_CHESTCAP "Treasure chest!!!"
END
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

daydreamer

here the .h file with -1 and IDC_MYICON 2
added several messageboxes constants
.h is used together with the .rc file
#define SCREENWIDTH 800
#define SCREENHEIGHT 600
#define FULLSCREEN 0 //1=fullscreen,0=windowed
#define IDS_APP_TITLE 103

#define IDR_MAINFRAME 128
#define IDD_PSEUDO3D_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDI_PSEUDO3D 107
#define IDI_SMALL 108
#define IDC_PSEUDO3D 109
#define IDC_MYICON 2
#define IDC_INVENTORY 1024
#define IDC_CHEST 1025
#define IDC_CHESTCAP 1026
#define IDC_STAIR 1027
#define IDC_STAIRCAP 1028
#define IDC_QUEST 1030
#define IDC_QUESTCAP 1031
#define IDC_EXIT 1032
#define IDC_EXITCAP 1033
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_NO_MFC 130
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
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

Instead of using many resources with spaghetti code, I embed a spreadsheet as a resource and use the Lg$() macro to extract what I need - 9 lines of code for hundreds or thousands of strings identified by a 4-letter code, e.g. _AUT for "Austria":

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Lg$(File:"\Masm32\MasmBasic\Res\GuiData\GuiData.tab")        ; file:"path" loads the multilingual matrix
  For_ ct=0 To 5
       Lg$(Language: Mid$("ENESBRITDEFR", ct*2+1, 2))  ; example: Lg$(Lang:IT) sets Italian
       wPrintLine wLg$(LgTx), ":", CrLf$, Tb$, wLg$(_ASM), CrLf$, Tb$, wLg$("_BEL")    ; Unicode works better
       wPrintLine Tb$, wLg$("_USA"), CrLf$, Tb$, wLg$(_AUS), CrLf$, Tb$, wLg$(_AUT)    ; with many languages
  Next
EndOfCode

Español:
        Samoa americana
        Bélgica
        Estados Unidos
        Australia
        Austria
Português (BR):
        Samoa Americana
        Bélgica
        Estados Unidos
        Austrália
        Áustria
Italiano:
        Samoa Americane
        Belgio
        Stati Uniti d'America
        Australia
        Austria
Deutsch:
        Amerikanisch-Samoa
        Belgien
        Vereinigte Staaten von Amerika
        Australien
        Österreich
Français:
        Samoa Américaines
        Belgique
        Etats-Unis
        Australie
        Autriche
по-русски:
        American Samoa
        Belgium
        United States
        Australia
        Austria

TouEnMasm

The simple way is this one :
Quote
IDT_CREER_MDI_FILLE   RCDATA   "Creation_MDI_fille.txt"

Where  Creation_MDI_fille.txt  is a text file created with notepad,you can explain your life here.
That' all.After you acces it the classic way ,load...,put al that in a proc.
LoadResource give you a handle you can use as it is a file handle.
Fa is a musical note to play with CL

daydreamer

thanks Jochen :thumbsup:
Yves :thumbsup:
that will be a much better way to store quiz answers and questions than hardcode them or other things

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