Hi, I've just started using Masm32 and think it's most excellent, and with Iczelion's tutorials it's made assembler so much easier to understand.
The full step by step explanations within the tutorials are superb.

I've been working my way through Iczelion's tutorials.
Tutorial 18 which implements the progress bar, is what I've been trying to implement in my test project.

If I create a progress bar as in the tutorial using invoke, eax would hold the hWnd for the progress bar.

The problem is, my progress bar is already placed on a Dialog Window in the resource file.

How would I get the hWnd of the progress bar in this instance.
Posted on 2001-09-18 00:28:57 by Unregistered
you nedd this ?

The GetDlgItem function retrieves the handle of a control in the specified dialog box.

HWND GetDlgItem(

HWND hDlg, // handle of dialog box
int nIDDlgItem // identifier of control


Identifies the dialog box that contains the control.


Specifies the identifier of the control to be retrieved.
Posted on 2001-09-18 00:50:17 by Bit7
If you included a resource item, and need thier handles use the following API.

invoke GetDlgItem, hDialogWindow, ItemNumber
mov hItem, eax

I do this in the WM_INITDIALOG, and store all handles needed into variables.

Its wise to number your dialog items in a systematic order, as you can then use loops to get alot of dialog item handles.

Hope this Helps..
Posted on 2001-09-18 00:52:57 by NaN
Doh!, Angelo beat me to the puch.. :D

Posted on 2001-09-18 00:54:53 by NaN
Hi guy's, thanks for that but I'm still struggling, just can't get that progress bar hWnd . There's something I'm missing but can't see what, here is my basic setup.

The progress bar bit in my resource file is the following
CONTROL "Progress Gauge", 1018, "MSCTLS_PROGRESS32", 0, 39,167,225,14, ,0
Dialog name and Progress bar variable setup
DlgName db "FlashDlg",0

hwndProgress dd ?

This is how I'm trying to get the handle to the progress bar
invoke GetDlgItem, ADDR DlgName , 1018
mov hwndProgress,eax
Am I doing this correctly
Posted on 2001-09-18 10:25:39 by Enforcer
HI NaN !
I'm the faster asm cow-boy of the WEST ! :)


invoke GetDlgItem, ADDR DlgName , 1018

is wrong

you don't have to push ADDR DlgName but DlgHandle (DWORD value !) :)

It is returned by CreateDialog or by

call DialogBoxParam, @hinst, offset DlgName, 0, offset DlgProc, 0
in eax the handle of the dialog

Posted on 2001-09-18 14:15:23 by Bit7
each control has a number assigned to it. i dont know how it picks the number (it being my resource editor) but it does. it puts this value in a .h file. eg.

#define LIST_ITEMS 1040
#define BTN_GO 1045
#define BTN_CONNECT 1046
#define EDIT_DETAILS 1051
#define EDIT_DISPLAYING 1052

you can use these numbers, although as they are pretty meaningless to someone without a photograpphic memory, most people tend to give them a name in their .const section



LIST_ITEMS equ 1040
BTN_GO equ 1045
BTN_CONNECT equ 1046

then just use GetDlgItem like angelo and NaN said.
if you want to retrieve the text from say an edit box you can use GetDlgItemText. Theres also other API's to set data etc. just look through your win32.hlp for GetDlg... SetDlg... etc. etc.

hope this helps.
Posted on 2001-09-18 15:59:25 by skud
DialogBoxParam cannot return a dialog handle -- it doesn't return until the dialog is closed! What does it return? -- the value specified by the EndDialog call that closed down the dialog.
Posted on 2001-09-18 17:38:51 by tank
Thanks Skud, I already have that Implemented.

What tank say's is correct, I found that out many many hours later.

Thing is, the only way I was able to get the correct handle for the progress bar
was to place the call *** invoke GetDlgItem,hDlg,IDC_PROGRESS *** just after
the Dialog was created in WinMain which works ok.

But surly, there must be a way to get a control's handle, outside of the procedure
where it was created.

If there is a way, can someone give some actual code, which would achieve this.

Posted on 2001-09-18 22:46:20 by Enforcer
you can get its handle outside the proc which created it. you can always just get the handle (within the original proc) and then save it for future reference... or you have to save the "hWin" ie.

mov eax, hWind
mov dialoghand, eax

and then use that with GetDlgItem

hope this helps.
Posted on 2001-09-19 07:51:33 by skud

There is a way.. but its a bit complicated. This is because the windows are ment to be encapsulatd, were api's only interface with the windows.

Basically, you can call the parent window's Class/Window LONG properties and enumerate all child windows. Then step thru them until you find the one you want.

I've never done this, but i have a program (on my web site), that does just this, called WinSPY or something. It Spy's on a window and tells you all you ever wanted to know about it.

Posted on 2001-09-19 16:17:04 by NaN
If I have fully understood your main window procedure needs a handle of a progress bar contained in a dialog box. Maybe it is a stupid idea, but why not to let dialog box procedure pass this value to its parent window (the main window)? During WM_INITDIALOG you can obtain progress bar handle and send a custom message (WM_USER + 1) to the parent window procedure.
Posted on 2001-09-19 16:34:12 by LuHa
Thanks all for you're input, it's given me much insight.
As you say Skud, getting the handle in the proc of the creation and storing it, seems the easiest way for me at this stage, of my assembler experience.

NaN, What is your web address, just out of interest I'd like to see that WinSPY.

It's nice to see fellow programmers trying to help each other out.

Again I thank you all for your help.
Posted on 2001-09-20 06:29:41 by Enforcer
enforcer, where abouts in england are you from?
Posted on 2001-09-20 11:15:32 by skud
West London, Skud
Posted on 2001-09-20 11:29:14 by Enforcer
aha ok.
its just i know a guy in england also called enforcer, except he's

Posted on 2001-09-20 13:22:05 by skud
My web site can be found as any other member with a web page... just click on the "www" button below the the person's message... (if ther isn't a 'www', then the person hasn't registered a web page with this board..)

My page is a free-for-all.. could be organized better, but it has enough wing-dings to keep people amused.

Check it out...

Posted on 2001-09-21 02:35:04 by NaN