Author Topic: Event-driven programming  (Read 6141 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5944
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Event-driven programming
« Reply #15 on: December 22, 2017, 10:35:01 AM »
This one will not run, it pops a message box saying it could not open MbSnippets.asc for Recall FileRead$.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: Event-driven programming
« Reply #16 on: December 22, 2017, 05:38:33 PM »
Oops, I forgot that this file is present only in MasmBasic installations :bgrin:

Try attached version 4 then. You can drag a plain text or RTF file over the exe to see its content in the edit control. The included source SkelGuiGroup.asc will do, for example. If you max the window, it even becomes a source viewer, but beware, clicking on some other control (case, full word, date, time) will use the edit control.

Note that, as a demo, the trackbar resets the progressbar. The trackbar control has a very odd way to communicate its status, it sends a WM_HSCROLL message:

Event Message
  .if uMsg_==WM_HSCROLL                 ; horizontal trackbar sends this message
        mov eax, lParam_
        .if eax==hTrack
                mov ticks, rv(GetTickCount)             ; try to sync with progressbar ;-)
                shl rv(SendMessage, lParam_, TBM_GETPOS, 0, 0), 9
                sub ticks, eax
        .endif
  .elseif uMsg==WM_CLOSE ...

LiaoMi

  • Member
  • ***
  • Posts: 329
Re: Event-driven programming
« Reply #17 on: December 22, 2017, 07:01:44 PM »

if you type a string with a space, then the selection of the full line doesnt work, only a part before the space is selected.

I tried that now, but if I click left of the string, the whole line gets selected. No such problem here, or do you mean something else?


Hi,

thats what I meant, correct, this is strange, I tested on windows 10 latest version, selection after space doesnt work, the fourth version ends with an exception.

Code: [Select]
EXCEPTION_DEBUG_INFO:
           dwFirstChance: 1
           ExceptionCode: C0000005 (EXCEPTION_ACCESS_VIOLATION)
          ExceptionFlags: 00000000
        ExceptionAddress: 004057EF skelguigroup.004057EF
        NumberParameters: 2
ExceptionInformation[00]: 00000000 Read
ExceptionInformation[01]: 00000000 Inaccessible Address
First chance exception on 004057EF (C0000005, EXCEPTION_ACCESS_VIOLATION)!

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5944
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Event-driven programming
« Reply #18 on: December 22, 2017, 07:24:26 PM »
Nope, version 4 does not run at all. 51712 bytes, if I double click on it, the cursor changes for a moment but it exits without displaying the window.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: Event-driven programming
« Reply #19 on: December 22, 2017, 08:03:57 PM »
Thanks, Hutch & LiaoMi. Does it also crash when you drag a file over the exe? It seems that my check for Exist(commandline) has a problem. Should be fixed with attached version 5:

Version 4 (early macro expansion):
Code: [Select]
If_ Exist(CL$()) Then SetWin$ hBigEdit=FileRead$(Exist$)
Version 5 (macro expansion delayed):
Code: [Select]
If_ Exist(CL$()) Then <SetWin$ hBigEdit=FileRead$(Exist$)>
[rant]it won't crash with Win7-64, and only Win7-64, because Micros**t grabs exceptions when they happen inside WndProc[/rant]

This is how it should look like, with the source in the background:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5944
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Event-driven programming
« Reply #20 on: December 22, 2017, 08:18:31 PM »
Yep, everything on this one worked fine. Looks OK on my Win10 64 pro.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: Event-driven programming
« Reply #21 on: December 22, 2017, 08:28:25 PM »
Great, thanks :t

I know this programming style is a bit like the Antichrist for the assembler purist (and I already convinced José to dedicate himself to VB .NOT); it is a demo how powerful a macro assembler can be. Compare that for example to the desperate attempts of QT to provide a UI system that is compatible between Windows and Linux; my code produces exes around 50k, their code for a hello world UI app starts at 8MB or so.

And the code above is not just a hello world, it's a full-fledged Windows application with 17 controls that loads a RTF file from the commandline and pins a string array into the listbox etc ... the 40k overhead is there, of course, so it won't qualify for the "smallest exe ever" contest. But it works, I use it actually quite a lot for my private stuff :icon_cool:

P.S.: Just learned something when testing in my XP VM: If the manifest includes a reference to GdiPlus 1.1, the OS complains about a bad configuration. The attached XP version has a barebones manifest and loads controls version 6.00. They look nice, actually.

LiaoMi

  • Member
  • ***
  • Posts: 329
Re: Event-driven programming
« Reply #22 on: December 22, 2017, 08:43:50 PM »
 ::) Find - Replace still dont mark all text, when I do double-click. All other components work fine  :t

AW

  • Member
  • *****
  • Posts: 1606
  • Let's Make ASM Great Again!
Re: Event-driven programming
« Reply #23 on: December 22, 2017, 08:58:37 PM »
I know this programming style is a bit like the Antichrist for the assembler purist (and I already convinced José to dedicate himself to VB .NOT);
As much as I have convinced you to produce a compiler for your High Level Language and not be dependent on assemblers.  :icon_rolleyes:

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: Event-driven programming
« Reply #24 on: December 22, 2017, 09:07:08 PM »
::) Find - Replace still dont mark all text, when I do double-click. All other components work fine  :t

The RichEdit control behaves like that, see screenshot below.
If you place the cursor near the left border, the cursor looks to the right, and a double-click selects the full line
If you place the cursor on top of a single word, the cursor looks to the left, and a double-click selects the word.

LiaoMi

  • Member
  • ***
  • Posts: 329
Re: Event-driven programming
« Reply #25 on: December 22, 2017, 09:57:38 PM »
::) Find - Replace still dont mark all text, when I do double-click. All other components work fine  :t

The RichEdit control behaves like that, see screenshot below.
If you place the cursor near the left border, the cursor looks to the right, and a double-click selects the full line
If you place the cursor on top of a single word, the cursor looks to the left, and a double-click selects the word.

Here everything is fine, but in the text edit component (Find text edit - Replace text edit), it does not work, just right-click and select all helps.

HSE

  • Member
  • ****
  • Posts: 856
  • <AMD>< 7-32>
Re: Event-driven programming
« Reply #26 on: December 23, 2017, 12:43:54 AM »
As much as I have convinced you to produce a compiler for your High Level Language and not be dependent on assemblers.  :icon_rolleyes:
:biggrin:

I know this programming style is a bit like the Antichrist for the assembler purist
:biggrin:  You can add here that some people like MasmBasic but are incapable to fight with RichMasm   :(  (of course, to use MasmBasic independently require a help file that you never will write).

 


jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: Event-driven programming
« Reply #27 on: December 23, 2017, 02:05:59 AM »
:biggrin:  You can add here that some people like MasmBasic but are incapable to fight with RichMasm

Open the *.asc source in WordPad or MS Word, select all, copy, paste in qEditor, and off you go ;-)

LordAdef

  • Member
  • ****
  • Posts: 606
Re: Event-driven programming
« Reply #28 on: December 26, 2017, 01:54:34 PM »
What's the problem with Richmasm? It's a neat ide.

jj2007

  • Member
  • *****
  • Posts: 8891
  • Assembler is fun ;-)
    • MasmBasic
Re: Event-driven programming
« Reply #29 on: December 26, 2017, 07:44:24 PM »
That's a nice comment, Alex, is it Christmas? :biggrin:

New version of the controls demo is here and looks like this: