The MASM Forum

Projects => ObjAsm => Topic started by: Biterider on May 22, 2020, 11:41:51 PM

Title: Taking full control over MessageBox API
Post by: Biterider on May 22, 2020, 11:41:51 PM
The MessageBox API is one of the preferred APIs when it comes to simply displaying a message, but its simplicity comes at a cost.
Formatting options, size control and other drawing capabilities are missing. On the other hand, it has a well-designed behavior that most users are used to.

As you probably know, I recently designed a control that can draw formatted text based on a markup string. The idea behind this new advanced API is to combine the well-behaved MessageBox with new drawing features. This new API is simply called MsgBox and is parameter compatible the the original MessageBox. This way, you exchange the name of the API and add the markup string.

This approach is not limited to an OOP framework because the drawing code can easily be replaced with your own custom code.

Here are some details of the implementation:
Notes:
For this example, I used the following markup string:

"{S.X 420}{S.Y 195}{PADDING 20}", \
"[INDENT 55]",\
  "[B,H +6,C #FF4F4F]Warning![~]{P}", \
  "[H +2]Critical system failure   - ERRID 521 -  [~]", \
  "[Info 0, Font 'Webdings', H +1]{#69}[~]{P}", \
  "[C #5F4FFF]", \
    "[I]Read the instruction manual for more information  [~]", \
    "[Info 1, Font 'Webdings', H +1]{#69}[~]", \
  "[~]", \
"[~]"


Have fun,  :biggrin:

Biterider
Title: Re: Taking full control over MessageBox API
Post by: HSE on May 23, 2020, 02:07:12 AM
 :thumbsup:

Hi Biterider!

If you move the message out of screen, buttons disappear (except "anular").

Regards. HSE

Title: Re: Taking full control over MessageBox API
Post by: Biterider on May 23, 2020, 05:00:55 AM
Hi HSE
Thanks for your feedback.  :thumbsup:
I was able to fix this issue and uploaded the corrected version on the first post.


Biterider
Title: Re: Taking full control over MessageBox API
Post by: HSE on May 24, 2020, 04:59:47 AM
Perfect  :thumbsup:

I have more feedback :biggrin:

Things  that were working in ObjAsmB are not working in ObjAsmC, for example this test (http://masm32.com/board/index.php?topic=8232.msg90242#msg90242)

I can't see what it's different  :rolleyes: , "symbol not defined " is everywhere.

\masm32\ObjAsm\Code\Objects\Pixelmap.inc(251) : Error A2102: Symbol not defined : sIID_IPicture
d:\masm32\ObjAsm\Code\Objects\Pixelmap.inc(251): Included by
  MacroLoop(7): iteration 1: Macro called from
   MakeObjects(9)[Objects.inc]: Macro called from
    TestPXM.asm(58): Main line code
Inheritance path: OA_Primer,OA_LinkedList
Inheritance path: OA_Primer,OA_Streamable,OA_Pixelmap,OA_Pixelmap2
TestPXM_Main.inc(85) : Error A2063: Symbol not defined : OA_TestPXM.Pxm1
$GetInstance32(1)[Objects.inc]: Macro called from
  MethodInvoke(92)[Objects.inc]: Macro called from
   OCall(5)[Objects.inc]: Macro called from
    TestPXM_Main.inc(85): Included by
     TestPXM.asm(88): Main line code
Title: Re: Taking full control over MessageBox API
Post by: Biterider on May 24, 2020, 06:23:00 AM
Hi HSE
This symbolic GUID is defined here \ObjAsm\Code\Inc\Windows\sGUID.inc
Try including this file at the beginning of your project.

I have a tool here that helps me to quickly find such things. It is called "Windows Grep" (Version 2.3). Unfortunately, the original site is not available anymore, but it can be downloaded from other sites. I like the tool, because it shows the results immediately in addition to some lines before and after the match.

Biterider
Title: Re: Taking full control over MessageBox API
Post by: HSE on May 24, 2020, 07:26:34 AM
Hi Biterider!

Ok.  :thumbsup:

TestPXM_Main.inc(85) : Error A2063: Symbol not defined : OA_TestPXM.Pxm1
$GetInstance32(1)[Objects.inc]: Macro called from

Then, is new version failing to find includes?

Title: Re: Taking full control over MessageBox API
Post by: Biterider on May 24, 2020, 08:24:31 AM
Hi HSE
I got it working  :biggrin:
You have to do 2 things: adjust the inheritance and modify the OnSize declaration. That's all.


MakeObjects Primer, Stream
MakeObjects WinPrimer, Window, Dialog, DialogModal, DialogAbout
MakeObjects Button, ColorButton
MakeObjects WinApp, SdiApp



Object TestPXM , TestPXMID, SdiApp
  RedefineMethod    Init
  RedefineMethod    Done   
  RedefineMethod    OnSize,     WPARAM, LPARAM

  StaticMethod      Startup

  VirtualEvent      OnCreate,   WM_CREATE
  VirtualEvent      OnCommand,  WM_COMMAND
  VirtualEvent      OnPaint,    WM_PAINT

  ;Embed grid1, GridFixW
  DefineVariable cualquiera, dword, 0

  Embed     Pxm1,  Pixelmap2
ObjectEnd


Biterider
Title: Re: Taking full control over MessageBox API
Post by: HSE on May 24, 2020, 09:28:14 AM
Hi Biterider

Quote from: Biterider on May 24, 2020, 08:24:31 AM
adjust the inheritance
That was the problem!! For some reason, 6 years ago I write objects in that order, and all projects ... are a copy of the same  :biggrin: :biggrin: :biggrin:

Quote from: Biterider on May 24, 2020, 08:24:31 AM
the OnSize declaration.
Yes, that was evident and solved previoulsy (erasing OnSize in Window.inc :biggrin:)

Thanks very much. HSE
Title: Re: Taking full control over MessageBox API
Post by: Vortex on May 24, 2020, 06:37:26 PM
Hi Biterider,

Here is another grep for Windows release :

https://github.com/stefankueng/grepWin

https://github.com/stefankueng/grepWin/releases/tag/2.0.1
Title: Re: Taking full control over MessageBox API
Post by: Biterider on May 24, 2020, 07:01:07 PM
Hi Vortex
Thanks for the link. I just tried it out.   :thup:
It seems that it is being actively developed (version 2.0.1.882 is dated 2020/05/21) and has many good features.

Biterider
Title: Re: Taking full control over MessageBox API
Post by: daydreamer on May 26, 2020, 01:38:24 AM
thanks Biterider :thumbsup:
Title: Re: Taking full control over MessageBox API
Post by: daydreamer on May 27, 2020, 03:28:17 AM
I let inventory list popup
Db "sayonara flute",13,10
...and list of other item
So It's need to be replaced by markup for blue text "sayonara flute"... Hexadecimal = RGB.. Followed by different colors for each item,preferably text color =same as object color? ( I have several different flutes in there)

Sayonara flute only works so far = exit dungeon, to ground floor
Title: Re: Taking full control over MessageBox API
Post by: Biterider on May 27, 2020, 06:01:29 AM
Hi daydreamer
I posted a sort of reference on how to build the markup string here http://masm32.com/board/index.php?topic=8524.msg93250#msg93250 (http://masm32.com/board/index.php?topic=8524.msg93250#msg93250)
I also posted the the markup string used in the example. It should help you to build your own. It is not that hard.

Biterider
Title: Re: Taking full control over MessageBox API
Post by: daydreamer on May 28, 2020, 05:29:48 PM
Quote from: Biterider on May 27, 2020, 06:01:29 AM
Hi daydreamer
I posted a sort of reference on how to build the markup string here http://masm32.com/board/index.php?topic=8524.msg93250#msg93250 (http://masm32.com/board/index.php?topic=8524.msg93250#msg93250)
I also posted the the markup string used in the example. It should help you to build your own. It is not that hard.

Biterider
thanks
started to test look of things with help of HTML,might be good tool to develop look of several GUI parts