The MASM Forum

General => The Campus => Topic started by: xandaz on November 06, 2020, 03:11:26 AM

Title: ScrollBar doesnt show in RichEdit Control.
Post by: xandaz on November 06, 2020, 03:11:26 AM
    Hy guys. I created both horizontal and vertical scrollbars for a RichEdit controls but they don't show. Anyone knows why?
Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: TouEnMasm on November 06, 2020, 03:28:13 AM

There must be enought text in the richedit for that.
But without the code ,it isn't possible to affirm it is that.
Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: xandaz on November 06, 2020, 03:33:57 AM
     There's enough text. the bars just dont show.
        invoke  CreateWindowEx,0,addr WC_SCROLLBAR,0,WS_VISIBLE+WS_CHILD+SBS_VERT+SBS_RIGHTALIGN,\
                    CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,\
                    [edi.MdiStruct.hEdit],0,hInstance,0
        mov     [edi.MdiStruct.hVScroll],eax
        invoke  SendMessage,eax,SBM_SETRANGE,0,1000                   
        invoke  CreateWindowEx,0,addr WC_SCROLLBAR,0,WS_VISIBLE+WS_CHILD+SBS_HORZ+SBS_BOTTOMALIGN,\
                    CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,\
                    [edi.MdiStruct.hEdit],0,hInstance,0
        mov     [edi.MdiStruct.hHScroll],eax
        invoke  SendMessage,eax,SBM_SETRANGE,0,1000
        invoke  EnableScrollBar,[edi.MdiStruct.hEdit],SB_BOTH,ESB_ENABLE_BOTH


Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: xandaz on November 06, 2020, 03:37:10 AM
   oh i see now. they need size. i thought there was a way to automate the scrollbars. problem solved
Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: xandaz on November 06, 2020, 03:52:36 AM
     This complicates the hell outta my job. if i use SBS_HORZ and SBS_VERT don't the scroll bars just appear sized and aligned as witth SBS_BOTTOMALGIN and SBS_LEFTALIGN?
Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: TouEnMasm on November 06, 2020, 04:47:04 AM

Try this

Quote
   INVOKE     CreateWindowEx, NULL, addr crichedit, NULL,\
      WS_CHILD or WS_BORDER or ES_MULTILINE or \
      ES_NOHIDESEL or ES_SAVESEL or ES_SELECTIONBAR or\
      WS_HSCROLL or ES_AUTOHSCROLL or\
      WS_VSCROLL or ES_AUTOVSCROLL or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,\
      0, 0,largeur, hauteur, Htab,NULL, Hinst, NULL
Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: Greenhorn on November 06, 2020, 04:54:59 AM
Hi xandaz,

why don't you just use ES_AUTOHSCROLL | ES_AUTOVSCROLL in the style flags of the RichEdit ?

Setting up your own scroll bars needs management about line height/width and window height/width.
https://docs.microsoft.com/en-us/windows/win32/controls/scroll-text-in-scroll-bars

But I'm not sure if you receive the WM_HSCROLL/WM_VSCROLL messages if the mouse is ovr the rich edit control.

Kind regards
Greenhorn
Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: Greenhorn on November 06, 2020, 04:56:39 AM
Quote from: TouEnMasm on November 06, 2020, 04:47:04 AM

Try this

Quote
   INVOKE     CreateWindowEx, NULL, addr crichedit, NULL,\
      WS_CHILD or WS_BORDER or ES_MULTILINE or \
      ES_NOHIDESEL or ES_SAVESEL or ES_SELECTIONBAR or\
      WS_HSCROLL or ES_AUTOHSCROLL or\
      WS_VSCROLL or ES_AUTOVSCROLL or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,\
      0, 0,largeur, hauteur, Htab,NULL, Hinst, NULL

Thanks ToutEnMasm  :thumbsup:
Title: Re: ScrollBar doesnt show in RichEdit Control.
Post by: xandaz on November 06, 2020, 04:58:50 AM
    Thanks a lot. I knew there was a way. thanks tout  :thumbsup: