flat assembler
Message board for the users of flat assembler.

Index > Windows > I need help building user interfaces in assembly language

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Overclick



Joined: 11 Jul 2020
Posts: 577
Location: Ukraine
Overclick
Quote:

Since it is just Windows API, I think it will be faster to write in C++ than in Assembly

Nothing is faster if you know what to do. Some default code is shorter in fasm than c++. Any high-level language is just macros of assembly, and fasm allow you to do any magic you want. The only reason of high-level languages is standardisation/agreement that never possible with free hands.
Post 14 Sep 2022, 13:47
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1464
Location: Toronto, Canada
AsmGuru62
Also, the FASM program with just a dialog box takes about 2Kb, but the C/C++ code of same nature may be larger.
Post 14 Sep 2022, 16:56
View user's profile Send private message Send e-mail Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 652
Location: Russia
macomics
AsmGuru62 wrote:
Also, the FASM program with just a dialog box takes about 2Kb, but the C/C++ code of same nature may be larger.
And what's the point if, when loaded into RAM, each section of the file occupies a multiple of 4 kb pages of memory?
Code:
#include <windows.h>
#include <winuser.h>

void Show(wchar_t *cap, wchar_t *mes, int ico) {
    HWND hWnd = GetForegroundWindow();
    MessageBoxW(hWnd, mes, cap, ico);
}

void Usage() {
    Show(L"Внимание!",
    L"Использование:\n\nMessageShow.exe <заголовок> <сообщение> [цифра-иконки]\n\n"
    "Цифра иконки (если не указана, то: Information)\n\n"
    "  1 Exclamation\n"
    "  2 Warning\n"
    "  3 Information\n"
    "  4 Asterisk\n"
    "  5 Question\n"
    "  6 Stop\n"
    "  7 Error\n"
    "  8 Hand\n\n",
    MB_ICONINFORMATION | MB_OK);
}

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow) {
    wchar_t** szArglist;
    int nArgs;
    szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
    if (NULL == szArglist) {
        Usage();
        return 0;
    } else {
        if (nArgs < 3) {
            Usage();
        } else {
            int ico = 0;
            if (nArgs > 3) {
                if (lstrcmpW(szArglist[3], L"1") == 0) {
                    ico = MB_ICONEXCLAMATION;
                }
                if (lstrcmpW(szArglist[3], L"2") == 0) {
                    ico = MB_ICONWARNING;
                }
                if (lstrcmpW(szArglist[3], L"3") == 0) {
                    ico = MB_ICONINFORMATION;
                }
                if (lstrcmpW(szArglist[3], L"4") == 0) {
                    ico = MB_ICONASTERISK;
                }
                if (lstrcmpW(szArglist[3], L"5") == 0) {
                    ico = MB_ICONQUESTION;
                }
                if (lstrcmpW(szArglist[3], L"6") == 0) {
                    ico = MB_ICONSTOP;
                }
                if (lstrcmpW(szArglist[3], L"7") == 0) {
                    ico = MB_ICONERROR;
                }
                if (lstrcmpW(szArglist[3], L"8") == 0) {
                    ico = MB_ICONHAND;
                }
            }
            HWND hWnd = GetForegroundWindow();
            MessageBoxW(hWnd, szArglist[2], szArglist[1], ico|MB_OK|MB_TOPMOST);
        }
        LocalFree(szArglist);
    }
    return 0;
}    

Code:
    E:\Tools\MSys64\mingw32\bin\gcc.exe ^
      -D UNICODE -D _UNICODE ^
      -s -Os -fno-ident -fno-stack-protector -fomit-frame-pointer ^
      -fno-unwind-tables -fno-asynchronous-unwind-tables -falign-functions=1 ^
      -e _WinMain ^
      -Wl,--enable-stdcall-fixup ^
      -nostdlib -nodefaultlibs -nostartfiles -o MessageShow.exe main.c -lkernel32 -luser32 -lshell32    

3072 bytes


Description:
Download
Filename: MessageShow.exe_3k_gcc.7z
Filesize: 1.09 KB
Downloaded: 14 Time(s)

Post 14 Sep 2022, 17:12
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 652
Location: Russia
macomics
Here are a few programs that may be useful for you.
ResEd - This is the later version of Ketil Olsen's ResEd dialog editor. It has been downloaded from the link that Ketil provided in the RadAsm IDE subforum.

Resource Compiler - A free resource compiler (GoRC.exe), which produces RES files from RC

And Resource Builder
Post 15 Sep 2022, 20:56
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1081
Location: Belarus
DimonSoft
Overclick wrote:
Quote:

Guys, since I gave up using dialog boxes long ago due to the quirks with fonts and font-relative sizing, may I ask you how in general do you build dialog-based interfaces with Per-Monitor High DPI support? I mean, it definitely should be possible, but I seem to be too lazy to figure out how to build things up together to ensure it looks properly everywhere. Arbitrary font properties, resizing controls at runtime based on current dialog size, adjusting it to monitor DPI, etc.

D2D1RenderTarget

No XP– support at the same time, which puts an assembly program at the same level of cross-platformness as C#/Java/any other element of Bristol scale or even worse Sad
Post 16 Sep 2022, 10:11
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.