News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Taking full control over MessageBox API

Started by Biterider, May 22, 2020, 11:41:51 PM

Previous topic - Next topic

Biterider

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:

       
  • Get access to the control using a system hook.
  • Pass additional information using a custom caption string.
  • Intercept WM_NCCALCSIZE, release the hook and replace the dialog WndProc.
  • Store the pointer to the additional information in a new window property.
  • Intercept WM_INITDLG and setup the control, get information of child controls and reposition them.
  • Intercept WM_NOTIFY and WM_HELP and forward them to the dialog parent window.
  • Intercept WM_PAINT to perform custom drawing.
  • Intercept WM_NCDESTROY to release allocated resources.
Notes:

       
  • Don't use GWLP_USERDATA to store data. The original API uses it.
  • Don't try to change the parent of the buttons. They will not work anymore.
  • Calling DefDlgProc after interception WM_PAINT will draw the grey band behind the buttons on the original position. This call is necessary to paint the remaining controls but make sure that the previous artwork don't interfere with the actual drawing. In the demo code, the grey band in covered by the TextView control.
  • The Help dialog launched from the help button is also a MsgBox call.
  • The Tooltip information is obtained using a WM_NOTIFY that is forwarded to the main application.
  • I had to extend the TextView code and add some missing procedures in the ObjMem library. All those files are in the attachment.
  • The attached code is compiled for 32 bit and tested on Win10, Win8 and Win7. Still, the code may contain some bugs that I would like to hear about.
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

HSE

 :thumbsup:

Hi Biterider!

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

Regards. HSE

Equations in Assembly: SmplMath

Biterider

Hi HSE
Thanks for your feedback.  :thumbsup:
I was able to fix this issue and uploaded the corrected version on the first post.


Biterider

HSE

Perfect  :thumbsup:

I have more feedback :biggrin:

Things  that were working in ObjAsmB are not working in ObjAsmC, for example this test

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
Equations in Assembly: SmplMath

Biterider

#4
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

HSE

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?

Equations in Assembly: SmplMath

Biterider

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

HSE

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
Equations in Assembly: SmplMath

Vortex

Hi Biterider,

Here is another grep for Windows release :

https://github.com/stefankueng/grepWin

https://github.com/stefankueng/grepWin/releases/tag/2.0.1

Biterider

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

daydreamer

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

daydreamer

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
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

Biterider

#12
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
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

daydreamer

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
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
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding