The MASM Forum

General => The Campus => Topic started by: ragdog on April 13, 2017, 05:24:16 AM

Title: Statusbar control confused
Post by: ragdog on April 13, 2017, 05:24:16 AM
Hello

I need a Statusbar control for my little project but i confused.

Why return the second SB_SETTEXT always NULL and the set not the Text.


LOCAL sbParts[2] :DWORD

.if uMsg==WM_INITDIALOG
;--Statusbar
    invoke GetDlgItem,hWnd,IDC_STATUSBAR
    mov hStatusBar,eax
    mov [sbParts+0],150
    mov [sbParts+4], 120
    invoke SendMessage, hStatusBar, SB_SETPARTS, 2, addr sbParts
    invoke SendMessage, hStatusBar, SB_SETTEXT, 0, chr$ ("Part 1")
invoke SendMessage, hStatusBar, SB_SETTEXT, 1, chr$ ("Part 2")


Thank you in forward,
Title: Re: Statusbar control confused
Post by: fearless on April 13, 2017, 07:21:33 AM
try the following instead of GetDlgItem - might be the statusbar in your resource is set as a SB_SIMPLE (simple one part statusbar), so therefore it only sees one part for the bar and ignores the other parts?

Invoke CreateStatusWindow, WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN or SBS_SIZEGRIP, NULL, hWnd, IDC_STATUSBAR
mov hStatusBar,eax

Title: Re: Statusbar control confused
Post by: ragdog on April 13, 2017, 07:35:14 AM
Hello Fearless  :biggrin:

Its same with you solution the second return 0 and set not the Text.

I think this is a simply Mistake but i cannot find this little bug.  ::)

(http://fs5.directupload.net/images/170412/a9pjxtk5.png)
Title: Re: Statusbar control confused
Post by: fearless on April 13, 2017, 08:12:50 AM
Check to see if statusbar control is on the dialog in the resource editor, just to remove it for testing and see if its still showing the same.

Ive tested with and without manifests, tried using the CTEXT and chr$ macros just to try and replicate the issue, but cant seem to, all my test produce output in both panels.

Pretty strange tho :D
Title: Re: Statusbar control confused
Post by: HSE on April 13, 2017, 08:34:44 AM
InitCommonControls is ok?
Title: Re: Statusbar control confused
Post by: hutch-- on April 13, 2017, 11:13:50 AM
 :biggrin:

Do_Status proc hParent:DWORD

    LOCAL sbParts[4] :DWORD

    invoke CreateStatusWindow,WS_CHILD or WS_VISIBLE or \
                              SBS_SIZEGRIP,NULL, hParent, 200
    mov hStatus, eax
     
    ; -------------------------------------
    ; sbParts is a DWORD array of 4 members
    ; -------------------------------------
    mov [sbParts +  0],   125    ; pixels from left
    mov [sbParts +  4],   250    ; pixels from left
    mov [sbParts +  8],   375    ; pixels from left
    mov [sbParts + 12],    -1    ; last part

    invoke SendMessage,hStatus,SB_SETPARTS,4,ADDR sbParts

    ret

Do_Status endp


hStatus in this context is a GLOBAL value set in the .DATA? section.
Title: Re: Statusbar control confused
Post by: jj2007 on April 13, 2017, 11:27:54 AM
Quote from: ragdog on April 13, 2017, 05:24:16 AMWhy return the second SB_SETTEXT always NULL and the set not the Text.

Ask Windows (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1020), or post your full code.
Title: Re: Statusbar control confused
Post by: TWell on April 13, 2017, 04:26:11 PM
so with a minimal change to original source:
mov [sbParts+4], -1
Title: Re: Statusbar control confused
Post by: ragdog on April 13, 2017, 08:31:20 PM
Quotemov [sbParts + 12],    -1    ; last part


Yes this works fine.

I forgot it  :biggrin: