I get an invalid handle on the call to the CreateWindowEx for the status bar
WndProc proc hWnd:HWND, uMsg:UINT, wParam, lParam
LOCAL ps:PAINTSTRUCT ; pointer to paint structure
LOCAL hdc:HDC ; handle to device context
LOCAL hMemDC:HDC ; handle to memory draw buffer
.IF uMsg==WM_CREATE
CALL Check_Admin ; check if program is being run as administrator
invoke CreateWindowEx,NULL, ADDR szButtonszClassName,ADDR szButtonText,\ ; create button
WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
130,110,140,25,hWnd,ButtonID,hInstance,NULL
mov hwndButton,eax ; save button handle
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
invoke lstrlen, ADDR szWarningText ; length of string returned in eax
invoke TextOut, hdc, 70d, 50d, ADDR szWarningText, eax ; output text to window
invoke EndPaint,hWnd, ADDR ps
.ELSEIF uMsg==WM_COMMAND
.IF dw_Admin_Flaq==1
;------------------------------------- Status Bar ------------------------------------------------
invoke CreateWindowEx,NULL,ADDR szProgressClass,NULL, WS_CHILD+WS_VISIBLE,25,\
170,Status_width,Status_height,hWnd,IDC_PROGRESS,hInstance,NULL
mov hwndProgress,eax
mov eax,350d
invoke SendMessage,hwndProgress,PBM_SETRANGE,0,eax
;----------------------------------------------------------------------------------------------------
invoke CreateWindowEx,NULL,ADDR szProgressClass,NULL, WS_CHILD or WS_VISIBLE,25,\
170,Status_width,Status_height,hWnd,IDC_PROGRESS,hInstance,NULL
mov hwndProgress,eax
invoke SendMessage,hwndProgress,PBM_SETRANGE,0,350D0000h
Still getting the error. The handle is the program's starting IP as it should be. I enclosed 2 snaps of the debugger.
did you forget the attachment ??? :P
Yup I did sorry the end of a very long day.
i added a little code, here...
invoke CreateWindowEx,NULL,ADDR szProgressClass,NULL, WS_CHILD or WS_VISIBLE,25,\
170,Status_width,Status_height,hWnd,IDC_PROGRESS,hInstance,NULL
mov hwndProgress,eax
invoke MessageBox,0,uhex$(eax),0,0
invoke PostMessage,hWnd,WM_SYSCOMMAND,SC_CLOSE,NULL
xor eax,eax ;return 0
this demonstrates a few things...
first, the CreateWindowEx call is successful, as it displays a non-zero handle
second, this is the proper way to terminate a program from within WndProc
as it allows windows to properly destroy the window(s) and exit cleanly via the message loop
the WM_SYSCOMMAND message should be sent to the main window
finally, the WM_COMMAND message returns a 0 in EAX
i should also mention that when a WM_COMMAND message is received, it is prudent to
verify it was a BN_CLICKED notification and check the control ID so you know which button was pushed
ok - one more thing :P
the PBM_SETRANGE message requires as lParam:
QuoteThe LOWORD specifies the minimum range value, and the HIWORD specifies the maximum range value.
The minimum range value must not be negative. By default, the minimum value is zero. The maximum
range value must be greater than the minimum range value. By default, the maximum range value is 100.
so, if you want a range of 0 to 350.....
invoke SendMessage,hwndProgress,PBM_SETRANGE,0,15E0000h
As Dave wrote already, it does create a statusbar on WinXP SP3, and the call to PBM_SETRANGE succeeds.
Thank You. I added your exit routine, and will add the BN_CLICKED filter. I traced it through Olly and see the handle returned in eax, but I am not seeing a rectangle for the status bar in the App window. I guess that added to my confusion.I imagine I have to POST more message data through the event handler routine SendMessage to make it visible. I'm on Windows 7 64x.
i see that Bill has an example of a progress bar...
\Masm32\examples\Bill_Cravener\controls
he always writes nice stuff that is easy to understand :t
Thanks. I've been reading Iczelion's Tutorial 18, I believe it is a little dated. :t
Don,
A progress bar is pretty simple to get going, ensure you set the correct style in InitCommonControls or the EX version then all you need is to set the range and have some interval events (disk IO etc ...) and then feed the number to the control and it will display a progress bar for you in real time. Depending on the OS version you are using you may need to set the SMOOTH style for a more modern looking display. Bill's example works fine and there is another in the masm32 example code that is also very simple to use.
Quote from: Don57 on October 16, 2012, 10:10:53 AM
Thank You. I added your exit routine, and will add the BN_CLICKED filter. I traced it through Olly and see the handle returned in eax, but I am not seeing a rectangle for the status bar in the App window.
Don,
I see the rectangle but it is very low. Raise the y pos by 100 pixel to see it.
\masm32\examples\dialogs_later\progress\* is a good folder ;-)
Thank You