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...
Fatal error, "cannot include file 'include'"
Hi Jochen,
This line in the resource script :
#include "C:/masm32/include/RESOURCE.H"
should be changed to :
#include "\masm32\include\RESOURCE.H"
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.
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...
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:
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?
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:
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
Thanks, Timo. I had never used poasm. What are the advantages over ml?
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.
When I have some free time, (and remember to do it), I'll check it out. :thumbsup:
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.
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"
@Vortex:
Does my example not work for you?
Hi sudoku,
Your example works fine. I only proposed some small improvements.
@Vortex
why not just remove WS_VISIBLE from resource file.
my mistake, WS_VISIBLE is default
Hi Timo,
If you mean the following :
CONTROL "",1003,"msctls_progress32",PBS_MARQUEE|PBS_SMOOTH,12,9,114,12
I am sorry but this will not work. You can edit the original resource script with Pelles IDE : Setting the property Visible of the progress bar to No will modify the flag to NOT WS_VISIBLE.
By NOT using SW_HIDE in the intialization, this is the result. Progress bar shows like this upon opening the program, not what is desired. :rolleyes:
(https://i.postimg.cc/yWXgCCXC/marquee.png) (https://postimg.cc/yWXgCCXC)
What is desired is that nothing shows until 'start' is pressed. And that is what my example does.
using 'NOT WS_VISIBLE' in the resource file works (without using SW_HIDE in init.), but seems unorthodox.
Deleted comment, as it did not quite sound as I intended, and it may have offended.
Hello,
QuoteIt's getting to be that a guy can't post a simple working example without a whole lot of drama.
Now, this statement does not welcome the efforts trying to help you. It was probably my fault. :undecided:
Quote from: Vortex on April 23, 2024, 06:55:58 AMIt was probably my fault.
No Vortex, I didn't mean to give you that impression. Maybe its all my fault for not seeing the forest through the trees.
I do appreciate the help.
Thanks for the tips, as well :thumbsup:
Hi sudoku,
No fiasco and nothing wrong. All of us, we are here to learn and experiment. Never get discouraged. Life means trial and error for all the humans.
Quote from: Vortex on April 23, 2024, 07:07:53 AMNo fiasco
No, all is well. I am just having a bad couple of days.
Here is a custom marquee style progress bar control.
There must be a manifest file for the program that you might use it in.
one of hutch's custom control sources was used as a template.
; ########################################################################
MarqueeProgress proto :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
;; example
;; invoke MarqueeProgress, hWin, 20, 20, 200, 24, 2004
;; mov hMarquee, eax
MarqueeProgress proc hParent:DWORD, a:DWORD, b:DWORD, wd:DWORD, ht:DWORD, ID:DWORD
szText mrqClass, "msctls_progress32"
invoke CreateWindowEx, 0,
ADDR mrqClass, 0,
WS_CHILD or WS_VISIBLE or PBS_MARQUEE or PBS_SMOOTH,
a, b, wd, ht, hParent, ID,
hInstance, NULL
ret
MarqueeProgress endp
; ########################################################################
A working example attached. (using generic.exe from masm32 examples)
I will add two buttons later, to work in the same way as my dialog box example.
I had forgotten to add the buttons in this example.
How is that a "custom" control?
A custom control is where you modify the control's default behavior or appearance, most often through the use of owner draw (or subclassing). This is just a stock progress bar, no?