Author Topic: Customized ProgressBar - Source Code embeded - RosAsm syntax  (Read 17918 times)

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
OK....succeeded to make a custom progressbar control in replacement of msctls_progress32 using HCBT_CREATEWND
Many tks for drizz for the custom control functions.

I just finished analyzing the way progressbar works exactly inside comctls32.dll (finished v 5 and started analysis on v 6 that uses visual style stuff)...I´ll later update this custom control to work exactly as the ones existent inside comctls (But....adding more progressbar messages and styles). It will then use the windows messages and the ones that were customized.

Once this is finished it would be a good idea do the same for the other windows controls as well.



Source code is embeded in the app. RosAsm source code.

This is just a beta test version. I´ll try to finish it as soon as possible.

The main function is CustomDlgProgressBar

Also created a GetWindowPos
« Last Edit: May 27, 2012, 03:15:04 PM by guga »
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar
« Reply #1 on: May 25, 2012, 01:05:13 PM »
Updated test version - now it can display a border as the background (it ressembled 3d)
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar
« Reply #2 on: May 25, 2012, 02:01:49 PM »
Fixed test version

« Last Edit: May 25, 2012, 03:23:22 PM by guga »
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #3 on: May 30, 2012, 05:03:32 AM »
OK...now enable it to runs vertical and smooth
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #4 on: May 30, 2012, 08:33:27 PM »
new version.....added borders surrounding the progressbar and enabled vertical in default win style and allowed change the amount of blocks on it.

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #5 on: May 30, 2012, 10:33:57 PM »
   Some pretty good examples guga. thx

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #6 on: May 31, 2012, 12:29:19 AM »
Hi xandax. Many tks.

I´m clkeaning up the code and will try to fix some minor problems i found.

Later i´ll also try to make it work the PBM_SETSTATE, PBM_GETSTATE, PBM_SETMARQUEE messages with and without visual styles.

Once i succeed to reproduce all common windows messages from Vista/Seven to work on winXP and earlier, i´ll try to ad some more effects on the progressbar (enabling a background image, shrinking the text along the progressbar movement etc).

All of this will work on simple sendmessages commands
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #7 on: May 31, 2012, 02:31:49 AM »
    i would like to see the source.... are you going to post that?

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #8 on: May 31, 2012, 03:26:24 AM »
I did not removed the source.
The source code is already inside the file. The app is made with RosAsm software, which means it contains the source embeded in the executable. To you see the source you need to open it in RosAsm.

You need to dl rosasm pack on my forum under "RosAsm Development" . After you dl complete pack, all you need is to dl the update.

There is no need to install...Only unzip and run the main executable. ON this release probably you won´t need to configure the settings, since i already did that....But if you need, it is easy to follow.

The last official version is  RosAsm2053a on the updates.

Once i finish the progressbar control...i´ll restart updating rosasm itself (i´m building a new feature for the debugger)


To open and run this customized Progress bar demo, all you need to do is open it in rosasm:
1 - Pressing F5 key assembles the App (Or use the "Compile" item on the main menu)
2 - Pressing F6 key it assembles and runs the app through rosasm debugger. (The debugger is a source code level) (or use "Run" item on the menu...but....to run...you need to assemble it 1st)

If you want to kiil (delete) the source that is embeded you need the app sourcekiller made for it. Not sure if i included in the pack....but if i didn´t...i´ll include it later)


P.S.: If you have troubles, tell me so i can help.

Sorry if i didn´t made the masm source. It have being a long time since i last coded in masm. So, for me it is faster coding in RosAsm. RosAsm syntax is easy and the macro set is similar to the masm ones (err...more likely it is Nasm based) . I have in my plans to make a converter to RosAsm to Masm/Fasm/Nasm syntaxes and vice-versa, but....i´ll only reach that after i succeed to make rosasm import and export libraries, and several other updates i have in mind.

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #9 on: June 02, 2012, 10:25:27 AM »
    Thanks guga. Nice work. I'll download

farrier

  • Member
  • **
  • Posts: 58
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #10 on: June 02, 2012, 10:38:46 PM »
guga,

What method do you recommend for extracting the source code from your executables. I won't install RosAsm just to get the source.  Surely there is a better way.  Edit with NotePad?

I appreciate your effort and hope to learn from your code!

Thanks in advance,

farrier
For the code is dark, and full of errors!
It's a good day to code!
Don't Bogart that code, my friend!

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #11 on: June 02, 2012, 11:40:51 PM »
All you need is open it with RosAsm (there´s no need to install, just unzip it). Open the executable in rosasm and on the menu you choose:
"File+Save Source Only"

But, i´m uploading the source here on the version i´m working on if you want to take a look.

This is only the asm source. The dialog is not included, since it is a binary data and not a rsrc one.

The source is divided in titles internally (A TITLE is a token that makes RosAsm to display the source in each Tab)
When you open the source in notepad you will see 1st my macro set. The next TITLE is called " Part01" that is responsable for the GUI only.

The main function responsable for the customized progressbar itself is CustomDlgProgressBar (Inside TITLE "Customized")

This is the main function that hooks the default win progressbar and recreates the functions and messages. The function "CbtHookProc" is responsable for that as the label suggests.

The main progressbar function starts at: CPB_WndProc and is something like:

Code: [Select]

Proc CPB_WndProc:
    Arguments @hWnd, @uMsg, @wParam, @lParam


    xor ebx ebx
    call 'USER32.GetWindowLongA' D@hWnd, 0
    mov ecx D@uMsg
    mov edx D@lParam
    mov esi eax

    .If_Or D@uMsg = &WM_PAINT, D@uMsg = &WM_PRINTCLIENT

        call CPB_OnPaint esi, D@hWnd, D@wParam
        ;call ProPaint esi, D@hWnd, D@wParam
        xor eax eax
(...)

    .Else_If D@uMsg = &PBM_SETMARQUEE
    .Else_If D@uMsg = &PBM_SETSTATE ; &PBST_NORMAL, &PBST_ERROR, &PBST_PAUSED
    .Else_If D@uMSg = &PBM_GETSTATE

    .Else
@Default:
        call 'USER32.DefWindowProcA' D@hWnd, D@uMsg, D@wParam, D@lParam

    .End_If

EndP

I recommend you open it in RosAsm to you be able to go back and forward inside the code using the mouse click button on a given label (variable, functions etc)....This way would be easier for you to follow the code, i think.

But, if you want to try using notepad only...No problem...but it will take more time i guess. Also, if you want, i can split the different titles and upload here. (Think on Each title as a different asm file)

If you need any help, let me know.

I´m still working on the code. So i didn´t botter cleaning it yet. I´m trying to make the text shows vertically and make it goes back and forward accordying to the movements of the progressbar. I`m analysin g a MFC code of a app called ProgressCtrlX_demo for this purpose.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #12 on: June 03, 2012, 05:19:14 AM »
This is a test that maked the text vertical (not the font, just the text pos)....and allows it to be multiline

Code: [Select]
; PBCreateFont
; http://www.swissdelphicenter.ch/torry/showcode.php?id=506
Proc WritePercentage:
    Arguments @hMem, @pRect, @nPct
    Local @hOldFont, @TextLen
    Structure @StrBuff 64, @StrBuff_DataDis 0
    Uses edi, eax, ecx, edx

    mov edi D@hMem

    mov esi D@pRect
    call ZeroMemory TextRect, Size_Of_RECT
    move D$TextRect.Left D$esi+RECT.LeftDis
    move D$TextRect.top D$esi+RECT.TopDis
    move D$TextRect.bottom D$esi+RECT.BottomDis ; height
    move D$TextRect.right D$esi+RECT.RightDis ; width
   
   
    call 'USER32.GetClientRect' D$edi+PRO_DATA.hwndDis, textrect2
    ;call ZeroMemory D@StrBuff, 64
    call 'GDI32.SetBkMode' D$edi+PRO_DATA.hMemDCDis, &TRANSPARENT
    call 'GDI32.SelectObject' D$edi+PRO_DATA.hMemDCDis, D$edi+PRO_DATA.hFontDis
    mov D@hOldFont eax
    C_call 'USER32.wsprintfA' D@StrBuff, {B$ "%d%%
    456", 0}, D@nPct
    call StrLenProc D@StrBuff
    mov D@TextLen eax

    mov ecx &DT_VCENTER__&DT_NOCLIP__&DT_SINGLELINE__&DT_CENTER
    Test_If D$edi+PRO_DATA.dwStyleDis &PBS_VERTICAl
        ; get height of text with word break (no text drawing occurs here)
        call 'USER32.DrawTextA' D$edi+PRO_DATA.hMemDCDis, D@StrBuff, eax, TextRect, &DT_CALCRECT__&DT_WORDBREAK__&DT_CENTER
        ; Set new positions so text will be vertically centered
       
        ;mov D$TextRect.Left 0
        mov eax D$textrect2.bottom
        shr eax 1
        mov ecx D$TextRect.bottom
        shr ecx 1
        sub eax ecx
        mov D$TextRect2.top ecx
        ;move D$TextRect.bottom D$esi+RECT.BottomDis
        mov ecx &DT_WORDBREAK__&DT_CENTER
        mov D@TextLen 0-1
    Test_End

    call 'USER32.DrawTextA' D$edi+PRO_DATA.hMemDCDis, D@StrBuff, D@TextLen, TextRect2, ecx;
    call 'GDI32.SelectObject' D$edi+PRO_DATA.hMemDCDis, D@hOldFont

EndP


Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

farrier

  • Member
  • **
  • Posts: 58
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #13 on: June 03, 2012, 02:37:01 PM »
guga,

Thanks for the code.

Notepad it is!  I have a mental block against RosAsm, maybe I'll get over it!

Do I understand that dialog code would not be included in a RosAsm program?  Only the digital data required for the .exe to display the graphics?

Thanks,

farrier
For the code is dark, and full of errors!
It's a good day to code!
Don't Bogart that code, my friend!

guga

  • Moderator
  • Member
  • *****
  • Posts: 1449
  • Assembly is a state of art.
    • RosAsm
Re: Customized ProgressBar - Source Code embeded - RosAsm syntax
« Reply #14 on: June 03, 2012, 10:48:47 PM »
Hi farrier
No worry. You ´ll get over it soon :t

Quote
Do I understand that dialog code would not be included in a RosAsm program?  Only the digital data required for the .exe to display the graphics?

No...dialog is included in RosAsm. But, so far it is created with RosAsm itself internally (under rosasm resource editor), using CreateDialogIndirectParam. The dialogs are mapped from DLGTEMPLATE internally. I mean it don´t parse any rsrc file. The user creates his resources from RosAsm resources editor. So far, it can export/import a text and binary representation of the resources (bin or text DLGTEMPLATE data)
I´m working on a resource editor to alow parsing rsrc, res, dfm files as well (probably VB resources too, using a proper converter for VB files). Once i finish this new upgrade, RosAsm will be able to import and export rsrc/res/dfm or other types of resources files. (I plan to allow converting also from 16bit resources - I know, too old...But...i would like to see the resources inside the 16bit dlls inside winXP as well).

There are several updates i plan for RosAsm, but, now..i´m working almost alone (JE made good upgrades too, that i´l take a look after i upgrade some tools for the debugger)...But since i´m working pratically alone it will take a long time for me to implement all updates i have in mind like:
* New resources editor:
    - New GUI editor for teh resource (I like the looks of visual studio resource editor. i`ll try to make it more similar to it)
    - It will allow parsing and exporting rsrc, res and other resource files.
    - It will create full windows apps (their skeletons at least) based on the resources
    - Allow the edition of all windows resources types
    - Allow  exporting resource obj files
* Disassembler:
  - Update some internall functions
 - FInish the DIS system (Data identifying system). A sort of a digital DNA to identify functions based on teh original libraries
 - Enable ability to import and export pdb, dbg files
* LibScanner
 - Finish the libscanner enabling it to import and export all kind of lib files to create the proper DNA (DIS) data files for usage on the disassembler
* Debugger
 - Finish the ability to dump and fix the loaded modules on user choice
 - Make a dialog to display properly the disasembled files while you are debuggin. (Now it display only a single line on the debugger caption)
 - Try to make a real time log file to the user analysis the different flags of the code flow that is being debugged
* General upgrade
 - Separate the assembler, disasembler, debugger, resources editor and make they works standalone or integrated with the whole RosAsm pack. (Isolating the different parts of the project is good for a matter of development)
 - Enable the hability to users create plugins for RosAsm
 - Enable the hability to users import and export lib/obj files in RosAsm
 - Perhaps i´ll enable the hability to import and export linux elf files (For usage under wine)
 - Enable a light script engine for the disassembler structures, equates etc

As you see, i have lots of projects planned, but working quite alone is a hard task to accomplish soon. So, new developers are welcome to help
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com