flat assembler
Message board for the users of flat assembler.
Index
> Windows > Loading vars into a menu |
Author |
|
revolution 29 Jan 2014, 14:10
clamicun wrote: I hardly can believe that programs (most today) which offer many different languages, have 25 different menus written in the Using fixed sized buffers is generally not a good method. All that data copying and having to ensure the buffers are large enough to hold the longest string creates a lot of opportunity for errors. |
|||
29 Jan 2014, 14:10 |
|
clamicun 30 Jan 2014, 14:36
Multilingual programs usually use a string resource to place all the strings from each language. Then the dialogue resources can point to a string resource by reference and the OS will display the string with the matching language.
Using fixed sized buffers is generally not a good method. All that data copying and having to ensure the buffers are large enough to hold the longest string creates a lot of opportunity for errors. ------------------- Thank you for the advice, Revolution ! That is more or less what my program does. The mentioned langfiles (e.g. french.txt) consist of one string, which is loaded on startup, depending of an "INIFILE", which contains 'de' or 'en' or 'fr' ..." . And "ensure the buffers are large enough..". Don't we to always do that ? But unfortunately you didn't refer to my actual question. Is it or is it not possible - the way FASM manages menus - to work with variables or must I insert pure text? menuitem '&Do something',0,MFR_POPUP Have a nice day! Clamicun |
|||
30 Jan 2014, 14:36 |
|
revolution 30 Jan 2014, 14:51
clamicun wrote: But unfortunately you didn't refer to my actual question. Code: menuitem string_resource_identifier_for_do_something,0,MFR_POPUP |
|||
30 Jan 2014, 14:51 |
|
typedef 30 Jan 2014, 16:41
First of all please use code tags and quote tags.
I'm surprised revolution didn't blow his head on that one No. There's no need to create 100 menus for 100 languages. You see, when a program supports multiple languages, it will come with language files (usually DLLs containing string resources). Each language file/DLL/language pack contains a string table. In this string table, each string has a unique ID number that is the same across all language packs/files/DLLs. Code: DEFINE IDS_HELLO = 1 ; de.dll IDS_HELLO "Hello in German" ; ru.dll IDS_HELLO "Hello in Russia." ; en_Us.dll IDS_HELLO "Howdy" ; en_GB.dll IDS_HELLO "H'llo" ; When loading the strings chosen_lang_pack = "de.dll"; module = LoadLibraryAsResourceNotExecutableForSecurityReasons(chosen_lang_pack); LoadString(IDS_HELLO,buffer); AppendMenu(..., ID_HELLO, buffer); If you app supports a really small set of languages, you can just jam-pack them in your EXE. However, adding more language support means updating the EXE also. |
|||
30 Jan 2014, 16:41 |
|
clamicun 30 Jan 2014, 17:30
Thank you both,
Revolution and typedef ! that was it. |
|||
30 Jan 2014, 17:30 |
|
clamicun 06 Feb 2014, 22:20
Unfortunately that was it not.
After a couple of days - trying - I did not succeed. Espacially I do not know what to do with.... module = LoadLibraryAsResourceNotExecutableForSecurityReasons(chosen_lang_pack); Wherever I put it, it gives me an errormessage. Revolutions idea with that MACRO - might be not to much - but I do not understand it at all. I would be very thankful for some more 'detailed' information, if you please and have the time to do it. After 3 month of trying 'ASSEMBLER' I start to really like it. |
|||
06 Feb 2014, 22:20 |
|
baldr 07 Feb 2014, 05:48
clamicun,
Naturally LoadLibraryAsResourceNotExecutableForSecurityReasons() isn't exported by Kernel32.DLL. What typedef meant was (probably) LoadLibraryEx(chosen_lang_pack, NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE). |
|||
07 Feb 2014, 05:48 |
|
clamicun 08 Feb 2014, 16:06
invoke LoadLibraryEx,chosen_lang_pack, NULL,LOAD_LIBRARY_AS_IMAGE_RESOURCE
gives an errmsg from fasmw. But anyway I give it up for a while and use 5 different menus. Problem with people who know a lot on assembler is, that they mostly are very scarce with explanations |
|||
08 Feb 2014, 16:06 |
|
typedef 08 Feb 2014, 18:43
This isn't an assembly problem.
The problem with people who don't know stuff it that they don't know |
|||
08 Feb 2014, 18:43 |
|
baldr 09 Feb 2014, 06:23
clamicun,
Don't give up, we're here to help but can't do this with that scarce information you've provided. What kind of errmsg does fasmw gave you? Is that related to undefined LOAD_LIBRARY_AS_IMAGE_RESOURCE symbol? Can't it be resolved using simple 'LOAD_LIBRARY_AS_IMAGE_RESOURCE = 32' definition that stems right from WinBase.h? As an alternative, trivial lucky Google search takes you right to the specification of LoadLibraryEx() with all those flags defined in plain hypertext. Don't be lazy, do the homework. |
|||
09 Feb 2014, 06:23 |
|
clamicun 09 Feb 2014, 15:23
baldr,
yes thanks - I knew already that LOAD_LIBRARY_AS_IMAGE_RESOURCE = 20h. I think my information is not scarce at all (first post). All I want, is to write a menu, which can be used with various languages. And unfortunately I do not succed to get typedefs post from 30 Jan 2014, 14:51 to work with the knowledge I have. That probably has to do with the fact, that I do not fully understand the "secrets" of string resources. The syntax of LoadString ?? "A handle to an instance of the module whose executable file contains the string resource" ?? o.k. I do not give up. P.S. By the way typedef, semiphilosophical considerations do not help with with assembler. |
|||
09 Feb 2014, 15:23 |
|
typedef 09 Feb 2014, 18:26
There's no philosophy involved here.
The problem is you haven't clearly identified your problem. This is how I see it in this case: Making a menu is not a problem rather your goal. Your problem is the lack of API information that can be easily obtained from MSDN and or visiting revolution's website. And may I ask: is assembly your first programming language on Windows? Because if you've made Windows menus in other programming languages, the problem becomes how to use the API in assembly. If however you don't know both then take some time to learn assembly first then learn the API as you go. And you don't just get all the knowledge in one package. It comes after a few trials and errors and some research. Good luck. |
|||
09 Feb 2014, 18:26 |
|
clamicun 10 Feb 2014, 17:30
I knew, you would answer my "by the way". People like you - probably from Northamerica (no insult to Canadians) always do.
I did not mention "philosophy" - I mentioned "semiphilosophy" if know what I mean. And I stick to that. Good luck as well. |
|||
10 Feb 2014, 17:30 |
|
Kenneth 10 Feb 2014, 18:49
I've never attempted to make any of my stuff work in other languages, but I'd imagine I would do something like attached file. Doesn't show it working with menus but the idea is the same. Looks like SetMenuItemInfo would work with menus but not sure, example shows changing texts for button and titlebar.
Basically I would use fasm to compile your own language files like such: Code: format binary as 'lng' use32 org 0 lookuptable dd string1, string2 string1 du "Ceci n'est pas possible",0 ;string1csz = $ - string1 string2 du "Ceci est possible",0 ;string1csz = $ - string1 Then you can see what languages the user has files for and manually change all your texts using your little custom language file. Set the strings in a static order, the beginning of the language file has offset to correct string to use. [edit]bug, change line: invoke SendDlgItemMessage, [hWnd], lbLanguages, LB_SETCURSEL, 0, langEnglish to: invoke SendDlgItemMessage, [hWnd], lbLanguages, LB_SETCURSEL, 0, 0 [/edit]
|
|||||||||||
10 Feb 2014, 18:49 |
|
typedef 10 Feb 2014, 20:22
clamicun wrote: I knew, you would answer my "by the way". People like you - probably from Northamerica (no insult to Canadians) always do. Then why are you surprised? Is it wrong to reply? And I don't think only North Americans are the only people who do that. clamicun wrote: I did not mention "philosophy" - I mentioned "semiphilosophy" if know what I mean. And I stick to that. I don't know what you mean but in your sentence, semi is modifying the word philosophy thereby making it convey less of what it normally should. So, since semi-philosophy (not much philosophy or little philosophy) still is philosophy, therefore implications dictate you must be talking about philosophy. i.e A semi-circle is still a circle, but not a full circle. |
|||
10 Feb 2014, 20:22 |
|
AsmGuru62 10 Feb 2014, 22:04
Hi clamicun,
So, you are trying to make a program with multi-language interface? Beside already mentioned methods of doing that (DLLs and whatever...) -- you can also use simple text files to represent strings you want. Then you simply load these files into memory and get access to text using a simple number. So, basically, your text file will look like that: Code: 1. string 1 2. string 2 and so on... so you know which number points to which text. Then you parse these files and keep a map of strings in memory. I did stuff like that long ago for Win32 and it was working OK without any DLLs. Text files must be UNICODE. |
|||
10 Feb 2014, 22:04 |
|
clamicun 11 Feb 2014, 21:59
Thank you all !
Just a bit of explanation. I am not trying to write a multi-language program, it is ready since 1989 - MS-DOS. It was some hell to write it - I remember. There were a couple of programes named name_de.com name_en.com name_pt.com .... You could choose the language by loading another program. I wrote it with Borland C and in assembler (the asm compiler was something with the name of 'NASM' - I remember that the creator (indian name) was classicly from Bangalore - even 25 years ago). Now I am retired since last year and have lots of time. So I checked a bunch of old rotten disquetes - (I had to find a very old working computer to read them). Found the program. Decided to transform the MS-DOS into Win32 just for fun. Having done - the last 25 years - computerwork only with php, html, js, css ond so on - I am starting from the bottom. more... The old MS-DOS is a program to encrypt files (very popular in these days, that is why I am working on it). The 'algoritmus' is not much 'sophisticated' today, but the NSA is going to hack any program because they very likely invented it. That's it. Good night P.S. I found the name of the asm compiler in the net - It was not Bangalore but Madurai. NGASM.COM G.Gurupandian and G.Namasivayam 16, South Veli Street Madurai - 625 001 Tamil Nadu, India. |
|||
11 Feb 2014, 21:59 |
|
baldr 11 Feb 2014, 22:51
clamicun,
Win32 has embedded facility to serve appropriate string from STRINGTABLE resource depending on current locale. I'll look into that later, probably that'll help. "Don't sit down, it's time to dig another one. -- For long you live and high you fly -- but only if you ride the tide -- and balanced on the biggest wave -- you race toward an early grave." |
|||
11 Feb 2014, 22:51 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.