News:

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

Main Menu

'marquee style' progress bar example

Started by zedd151, April 22, 2024, 04:34:50 AM

Previous topic - Next topic

zedd151

Inspired by a recent thread by NoCforMe (had issues with marquee progress bar), and some assistance from TimoVJL (provided C code example) I have decided to create a 'marquee style" progress bar example, in masm32 code.

include \masm32\include\masm32rt.inc
    DlgProc    proto :dword, :dword, :dword, :dword

.data
    hInstance  dd 0
    hProgress  dd 0
.code
start:
    invoke GetModuleHandle, 0
    mov hInstance, eax
    invoke DialogBoxParamA, hInstance, 1000, 0, addr DlgProc, 0
    invoke ExitProcess, eax

DlgProc proc hWin:dword, uMsg:dword, wParam:dword, lParam:dword
  .if uMsg == WM_INITDIALOG
    invoke GetDlgItem, hWin, 1003
    mov hProgress, eax
    invoke ShowWindow, hProgress, SW_HIDE                      ; hide progress bar until needed
  .elseif uMsg == WM_COMMAND
    .if wParam == 1001
      invoke ShowWindow, hProgress, SW_SHOW                    ; show progress bar
      invoke SendMessage, hProgress, PBM_SETMARQUEE, TRUE, 0    ; animate progress bar
    .elseif wParam == 1002
      invoke SendMessage, hProgress, PBM_SETMARQUEE, FALSE, 0  ; stop progress bar animation
      invoke ShowWindow, hProgress, SW_HIDE                    ; hide progress bar
    .endif
  .elseif uMsg == WM_CLOSE
    invoke EndDialog, hWin, 0
    xor eax, eax
    ret
  .endif
    xor eax, eax
    ret
DlgProc endp

end start

Push the "Start" button to start the progress bar.
Push "Stop" to stop it.

:azn:

Tested on Windows 7 only...
Ventanas diez es el mejor.  :azn:

jj2007

Fatal error, "cannot include file 'include'"

Vortex

Hi Jochen,

This line in the resource script :

#include "C:/masm32/include/RESOURCE.H"
should be changed to :

#include "\masm32\include\RESOURCE.H"

zedd151

Quote from: Vortex on April 22, 2024, 06:49:53 AMHi Jochen,

This line in the resource script :

#include "C:/masm32/include/RESOURCE.H"
should be changed to :

#include "\masm32\include\RESOURCE.H"
:mrgreen:
fixed in the archive as well.
That was resed's fault. lol

I didnt notice since I never had any trouble with it.
Ventanas diez es el mejor.  :azn:

jj2007

Exactly, Erol :thumbsup:

Quote from: sudoku on April 22, 2024, 06:56:02 AMThat was resed's fault.

I never used resed. Does it have any advantage over, say, Notepad? And I wouldn't count forward slashes in a Windows environment as an advantage...

zedd151

Quote from: jj2007 on April 22, 2024, 06:57:36 AMI never used resed. Does it have any advantage over, say, Notepad? And I wouldn't count forward slashes in a Windows environment as an advantage...
Sure, a nifty wysiwyg dialog editor. Can't do that in notpad.

Yes, the forward slashes are weird. Complain to ketilo next time he pops in for a visit.  :biggrin:
Ventanas diez es el mejor.  :azn:

NoCforMe

I think the forward slashes are C language lingo, not native Windows pathnames.

I've used resed; pretty nifty li'l tool, but it seems geared towards C, not assembly language. I ended up stealing some of its workings and creating my own tool, DialogGen, which instead of creating a resource (.rc) file that must be compiled by the resource compiler, generates a simple assembly-language include file that you just INCLUDE in your program. It too is WYSIWIG. (I'd post it here but to be honest it's full of bugs, and far too complicated to even have to explain. I use it despite its flaws. Someday maybe I'll fix it ...)

BTW, shouldn't this thread be in the Windows API forum since it deals with a Windows control?
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on April 22, 2024, 10:00:55 AMBTW, shouldn't this thread be in the Windows API forum since it deals with a Windows control?

I tend to share sudoku's view. It's a little project, too small for the Showcase, more like a demo. "Windows questions" creep in, that's normal, but still, I think it fits nicely here :thumbsup:

TimoVJL

For just using poasm.exe
ifndef __POASM__
include \masm32\include\masm32rt.inc
else
.model flat, stdcall
ExitProcess    proto :dword
GetModuleHandleA proto :dword
DialogBoxParamA proto :dword, :dword, :dword, :dword, :dword
EndDialog      proto :dword, :dword
GetDlgItem      proto :dword, :dword
ShowWindow      proto :dword, :dword
SendMessageA    proto :dword, :dword, :dword, :dword
SendMessage equ SendMessageA
GetModuleHandle equ GetModuleHandleA
TRUE equ 1
FALSE equ 0
WM_CLOSE equ 10h
WM_INITDIALOG equ 110h
WM_COMMAND equ 111h
SW_HIDE equ 0
SW_SHOW equ 5
PBM_SETMARQUEE equ 1034
endif
May the source be with you

zedd151

Thanks, Timo. I had never used poasm. What are the advantages over ml?
Ventanas diez es el mejor.  :azn:

TimoVJL

Quote from: sudoku on April 22, 2024, 10:40:39 PMThanks, Timo. I had never used poasm. What are the advantages over ml?
poasm support invoke in x64 mode.
Pelles C have own IDE, poide, so those users can test code examples with it's debugger, as newer versions have just own debug format only, not CodeView any more.
May the source be with you

zedd151

When I have some free time, (and remember to do it), I'll check it out.  :thumbsup:
Ventanas diez es el mejor.  :azn:

Vortex

Hi sudoku,

Some powerful Poasm statements :

QuoteOPTON CSTRINGS:ON C : escape sequences are processed in string literals.
INCBIN : Includes a (binary) file within the file being assembled.
CINCLUDE : Parses a C include file, looking for #define statements.

Vortex

Hi sudoku,

Some small recommendations :

- You don't need to hide the progress bar while initializing the dialog box. Specifiying the flag NOT WS_VISIBLE in your resource script will hide the control.

- For better code maintenance, it's preferable to define some equates to replace the identifiers based on ID numbers.

Here is the complete code :

; Original example code by sudoku
; https://masm32.com/board/index.php?topic=11864.0

include \masm32\include\masm32rt.inc

DlgProc PROTO :dword,:dword,:dword,:dword

IDB_START   equ 1001
IDB_STOP    equ 1002
IDC_PBBAR   equ 1003

.data?

hInstance   dd ?
hProgress   dd ?

.code

start:

    invoke  GetModuleHandle,0
    mov     hInstance,eax
    invoke  DialogBoxParam,eax,1000,0,ADDR DlgProc,0
    invoke  ExitProcess,eax

DlgProc PROC hWin:dword,uMsg:dword,wParam:dword,lParam:dword

    .if uMsg == WM_INITDIALOG
   
        invoke  GetDlgItem,hWin,IDC_PBBAR
        mov     hProgress, eax

    .elseif uMsg == WM_COMMAND
   
        .if wParam == IDB_START
       
            invoke  ShowWindow,hProgress,SW_SHOW                   ; show progress bar
            invoke  SendMessage,hProgress,PBM_SETMARQUEE,TRUE,0    ; animate progress bar

        .elseif wParam == IDB_STOP

            invoke  SendMessage,hProgress,PBM_SETMARQUEE,FALSE,0   ; stop progress bar animation
            invoke  ShowWindow,hProgress, SW_HIDE                  ; hide progress bar
           
        .endif
   
    .elseif uMsg == WM_CLOSE
 
        invoke  EndDialog,hWin,0

    .else

        xor     eax,eax
        ret

  .endif
 
    mov     eax,1
    ret
   
DlgProc ENDP

END start

#include "\masm32\include\Resource.h"

#define IDB_START 1001
#define IDB_STOP 1002

1000 DIALOGEX 10,10,141,54
CAPTION "Marquee Style"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW|DS_CENTER
BEGIN
  CONTROL "Start",IDB_START,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,12,30,54,15
  CONTROL "Stop",IDB_STOP,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,72,30,54,15
  CONTROL "",1003,"msctls_progress32",NOT WS_VISIBLE|PBS_MARQUEE|PBS_SMOOTH,12,9,114,12
END

1 24 "manifest.xml"

zedd151

@Vortex:
Does my example not work for you?
Ventanas diez es el mejor.  :azn: