flat assembler
Message board for the users of flat assembler.

Index > Windows > Windows vs dialogues?

Author
Thread Post new topic Reply to topic
fasm14



Joined: 23 Jan 2021
Posts: 14
Location: Russia
fasm14
Beginner question, if I'm trying to do something which can be accomplished with both normal windows and dialogues, which one do I pick? Is there one that runs faster/has a smaller executable file size?
Post 28 Mar 2021, 17:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18472
Location: In your JS exploiting you and your system
revolution
I doubt there is any significant difference between them.

The only change is in how the internal flags are set for the controlling objects. After that Windows just renders them for you.
Post 28 Mar 2021, 18:13
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 445
Location: Ukraine
Overclick
Best choice is to begin by Dialogues.
1) Easy to create Window-form at any resource redactor with many kind of items (buttons etc)
2) No need to worry about msg-loop.
3) Almost the same to Window even if you want to render some items individually.
4) Windows have more freedom but not many people actually need that. Freedom adds more routine to do.
Post 28 Mar 2021, 19:38
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1011
Location: Belarus
DimonSoft
In fact, dialogs are good until one tries to do complex UI. The problem is that control sizes are given in dialog units when one builds a dialog template but then, when you handle dialog resize and stuff you have to call SetWindowPos/MoveWindow which take pixels. Conversion is not quite straightforward (calculations are relative to dialog font size, AFAIR), add the complexity of supporting High-DPI and other brand new features. Not to mention that dialog procedures are like window procedures but with additional complications. What one really gains is being able to just invoke IsDialogMessage and get keyboard navigation work. Now ask yourself which properties of the solutions are pros and which are cons for your project.
Post 29 Mar 2021, 18:36
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 445
Location: Ukraine
Overclick
Example of moving multiwindowed Dialogues:
Sticked child
Code:
devices_dragwindow:
        invoke  ReleaseCapture
        invoke  SendMessage,[hWnd],WM_SYSCOMMAND,61458,0
        mov             rax,1
        ret
devices_wmmove:
        invoke  GetWindowRect,[hWndMain],_rect
        mov             r11d,[_rect.bottom]
        sub             r11d,[_rect.top]
        invoke  GetWindowRect,[hWnd],_rect
        sub             [_rect.top],r11d
        invoke  SetWindowPos,[hWndMain],0,[_rect.left],[_rect.top],\
                                0,0,SWP_NOSIZE+SWP_NOZORDER
        xor             rax,rax
        ret
    

Main Dialogue
Code:
dragwindow:
        invoke  ReleaseCapture
        invoke  SendMessage,[hWnd],WM_SYSCOMMAND,61458,0
        mov             rax,1
        ret
wmmove:
        cmp             [status_DlgChild],0
        je              @F
        invoke  GetWindowRect,[hWnd],_rect
        invoke  SetWindowPos,[hWndChild],0,[_rect.left],[_rect.bottom],\
                                0,0,SWP_NOSIZE+SWP_NOZORDER
        @@:
        xor             rax,rax
        ret
    

No problem to mapping items coordinates for resizing by same way. You do that any way.
Dialogue = Window + easy start. Then you can modify it whatever you want.
Post 29 Mar 2021, 19:08
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1011
Location: Belarus
DimonSoft
The point is that one has different units in the dialog template and at runtime. Plus let’s change fonts in the dialog. For projects where cons take less than one gains from pros dialogs do work well.
Post 29 Mar 2021, 21:15
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 445
Location: Ukraine
Overclick
You don't need to use that template it's optional.
To change the fonts you can use 3 different techniques:
1) Stretch textures
2) Draw whatever you want
3) WM_SETFONT
Example:
Code:
invoke  CreateFont,30,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,\
                        OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,\
                        DEFAULT_QUALITY, DEFAULT_PITCH,'Courier new'
invoke  SendDlgItemMessage,[hWnd],404,WM_SETFONT,rax,TRUE
    
Post 30 Mar 2021, 02:31
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1011
Location: Belarus
DimonSoft
Sorry, it seems you reply to somebody else.

I never complained about having to build dialog templates, they’re quite convenient as a replacement for rich Delphi-like environments. I never said one can’t change fonts: it would be stupid, everyone knows a dialog is a just a window of a system-defined class that is in cahoots with the system in certain aspects. And no, thanks, stretching textures to display text in a program with complex UI is not what I will ever consider: in 2021 we spend a lot of time to support High-DPI systems instead of letting them stretch our windows for us at compatibility layer, so stretching pre-drawn UI elements/texts ourselves is definitely a step back.

And yes, what’s left is to draw everything directly, with High DPI in mind and as font-settings-agnostic as possible. Having dialog units which are “¼ of the average character width” for x coordinate and “ of the average character height” for y coordinate and mapping them to pixels every now and then? No, thanks, just give me my pixels right away. We’ve fought for pixels to be nearly-square since like CGA times and today we have them. Which means we can forget restricting ourselves to x- and y-axis aligned values. Can I have a 45-degrees rotated UI element with size based on other element sizes which looks great with any font and any DPI selected, please?

And I hope you don’t try to tell me I should draw everything by hand and use dialogs just to create windows. I’m OK with calling another RegisterClassEx, replacing DialogBoxParam with CreateWindowEx and controlling the message loop myself.
Post 30 Mar 2021, 07:46
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3387
Location: vpcmipstrm
bitRAKE
Sadly dialogs are just a throwback to the 16bit windows days and never modernized. Many people switched to alternatives because they wanted a "system" that worked with their design. Even MS abandoned them - so few windows 10 apps use them. The WinUI 3 is the current flavor being pushed.

Wasn't there a tool that converted dialog templates to standard window functions?

_________________
¯\(°_o)/¯ unlicense.org
Post 30 Mar 2021, 09:38
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 445
Location: Ukraine
Overclick
bitRAKE, Everything on Win 10 looks like 16bit windows ))) WinUI represents everything include it's own dialogues. Can I see some examples of WinUI on fasm somewhere?


DimonSoft, check up how Windows does stretch icons. It works both ways. You can rotate it or stretch by corners too. It's not big deal to use EnumChildWindows or something own to do routine that windows does. I'll say again Dialogue is a Window with all of that functionality. You can always get back to routine or pass it on. You can register your own class or modify exist one. Different is how you begin your project, how you declare predesigned items that is all. The rest you can add or modify by same way as Window does.
Post 30 Mar 2021, 12:32
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3387
Location: vpcmipstrm
bitRAKE
Overclick wrote:
Can I see some examples of WinUI on fasm somewhere?
Nope.

https://docs.microsoft.com/en-us/windows/apps/winui/winui3/
https://github.com/microsoft/ProjectReunion

(From the roadmap, unpackaged desktop apps are planned for Q4 2021.)

The browser is the UI rendering platform going forward. :/

_________________
¯\(°_o)/¯ unlicense.org
Post 30 Mar 2021, 12:42
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1011
Location: Belarus
DimonSoft
Overclick wrote:
DimonSoft, check up how Windows does stretch icons. It works both ways. You can rotate it or stretch by corners too.

Not sure why you’re talking about this. Window icons are just small, and quite useless user-task-wise, pieces of UI. I’m more concerned about controls user interacts with having usable sizes and smooth appearance on a wide set of monitors.

Quote:
It's not big deal to use EnumChildWindows or something own to do routine that windows does. I'll say again Dialogue is a Window with all of that functionality. You can always get back to routine or pass it on. You can register your own class or modify exist one. Different is how you begin your project, how you declare predesigned items that is all. The rest you can add or modify by same way as Window does.

Exactly. But I can spend hours trying to convince dialog class to do what I need, digging through all the compatibility stuff and the quirks of DLUs… in fact, just reimplementing most of it from scratch. Or I can just do it from scratch in the first place.

It’s like a choice between buying an old building to demolish it and build a new one and buying just plain land with nothing built on it. The second way seems to be cheaper and lets avoid dealing with sewer pipes buried in the ground.

Still, dialogs are a great way to go for simpler projects with relaxed requirements or for proofs-of-concept that should be written faster.
Post 30 Mar 2021, 15:42
View user's profile Send private message Visit poster's website Reply with quote
Overclick



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

Not sure why you’re talking about this. Window icons are just small, and quite useless user-task-wise, pieces of UI. I’m more concerned about controls user interacts with having usable sizes and smooth appearance on a wide set of monitors.

I see you don't know. There is few sizes and windows stretch closest one. You can load 4k textures and stretch them to smaller size. Or you can use resizing by fixed steps.
Quote:

But I can spend hours trying to convince dialog class

You can modify class to your own, it's very flexible. Just set the name of new class into resource editor.
Ofcourse if you don't need any default items even text, textures or draw items then you don't need Dialogue at all.
Quote:

Still, dialogs are a great way to go for simpler projects with relaxed requirements or for proofs-of-concept that should be written faster

That what I'm trying to say.
Post 30 Mar 2021, 16:46
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1011
Location: Belarus
DimonSoft
Overclick wrote:
I see you don't know. There is few sizes and windows stretch closest one. You can load 4k textures and stretch them to smaller size. Or you can use resizing by fixed steps.

I do. Everyone who has ever tried to write a resource section in FASM had to dive into the details of how icons are stored as resources.

But windows icons are used in very specific places with metrics almost exactly known in advance. Which really differs from complex UI. Window icons are the easiest part: one can just prepare the icon in a few sizes and it should work for most cases. Even if it looks bad, it doesn’t make user experience terrible, just aesthetical attractiveness goes a bit down. Compare this to program window or certain controls inside it being extremely small at 16k monitor up to the point of their text being too small to be readable.

Overclick wrote:
You can modify class to your own, it's very flexible. Just set the name of new class into resource editor.

Dialogs don’t work by plain magic. If it quacks like a dialog, one still has to cooperate with dialog manager. And the word “quirks” is not arbitrarily chosen: DLUs are only one of them and it once took Raymond Chen 9 blog posts to explain just a few. But we’re still waiting as he said it was enough “for now”.
Post 30 Mar 2021, 23:08
View user's profile Send private message Visit poster's website Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 445
Location: Ukraine
Overclick
Quote:
dialog manager

Dialogue manager works via predesigned Window msg-loop. It can accept almost all kind of "window" commands. Othervice it have similair alternative. I tried, it's very funny. And yes, class can be modified, I did that for my own. Just show me some your examples I'll try to make them run via Dlg.

Quote:

DLUs are only one of them and it once took Raymond Chen 9 blog posts to explain just a few. But we’re still waiting as he said it was enough “for now”

Another stupid classes and methods? Or even more -- nothing to do by assembly? Do you believe it won't be visually limited for next years? MS sticked to their Surface as privileged platform for all past years. And now they provide another "super fast" stupid tiles UI for small slowly tablets? Do someone have performance issues with old UI even aero except tablets users? I don't think so.
Old-school Windows will stay popular for long...
Post 31 Mar 2021, 00:25
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1011
Location: Belarus
DimonSoft
Overclick wrote:
Quote:
dialog manager

Dialogue manager works via predesigned Window msg-loop. It can accept almost all kind of "window" commands. Othervice it have similair alternative. I tried, it's very funny. And yes, class can be modified, I did that for my own. Just show me some your examples I'll try to make them run via Dlg.

Nobody argued that. It’s just a matter of how much one gains and how much it costs later.

Overclick wrote:

Quote:

DLUs are only one of them and it once took Raymond Chen 9 blog posts to explain just a few. But we’re still waiting as he said it was enough “for now”

Another stupid classes and methods? Or even more -- nothing to do by assembly? Do you believe it won't be visually limited for next years? MS sticked to their Surface as privileged platform for all past years. And now they provide another "super fast" stupid tiles UI for small slowly tablets? Do someone have performance issues with old UI even aero except tablets users? I don't think so.
Old-school Windows will stay popular for long...

Sorry, you clearly don’t know what you’re talking about. DLUs are one of the basic things one faces when they start to use dialogs. And Raymond’s blog as well as the dialog manager series are exactly about old-school Windows. Why would a guy who was responsible for old-school Windows user-mode services, including window and dialog managers, write about anything else?

There was no notion of any modern Windows “technology” in any of my posts here. Just High DPI monitors but they do not replace old-school Windows programming, they just require a programmer to be aware of new hardware that gained significant market share in the period of time that has passed since CGA was a shiny brand-new catch word.
Post 31 Mar 2021, 14:08
View user's profile Send private message Visit poster's website Reply with quote
Overclick



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

Why would a guy who was responsible for old-school Windows user-mode services including window and dialog manager write about anything else?

I just guess. I don't know him. Good if so.

Thanks for hint. Seems I need to add Scale option for my exist project too
Post 31 Mar 2021, 14:12
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:  


< 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.