March 28, 2024, 11:00:17 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Append Edit / Horizontal scroll bar

Started by Andy, November 17, 2020, 11:52:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

November 17, 2020, 11:52:35 PM Last Edit: November 17, 2020, 11:56:59 PM by Andy
This is the scenario:

In my editor (yes groan - sorry), I have two files loaded.

1. The editor code itself.
2. One of Bill's source files.

Now, with the editor code (and with some longer lines in it) it shows the horizontal scroll bar at the bottom.

With Bill's file (and with shorter lines) there isn't an horizontal scroll bar at the bottom.

The problem:

When viewing my editor code, the horizontal scroll bar covers over line 26 (the last line visible) which is what I want it to do. 

When viewing Bill's file, line 26 is visible - which i don't want.

I can't just reduce the number of visible lines as I would be left with the same problem.

I tried to force the Rich Edit control to show the horizontal scroll bar by using the EM_SHOWSCROLLBAR message, but it only shows when it needs too regardless.

I tried to add a long line of spaces to the end of the rich edit text but the AppendEdit function just doesn't do it.

The rich edit control is sub classed, can I force it to show regardless there? - if so how? 

Any ideas anyone?

Attached are screen shots showing you the problem.

Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

1) Maybe you can try by adding WS_HSCROLL to richedit styles.

2) Another option, on your subclassed richedit process WM_NCCALCSIZE

  CASE WM_NCCALCSIZE
      INT style = GetWindowLong(hWnd, GWL_STYLE)
      SetWindowLong(hWnd, GWL_STYLE, style & WS_HSCROLL)

These options may or may not work ;)


Andy

Fasecero,

Nice to hear from you again! it's been too long, hope you are well.

I tried both methods, the second one does put the horizontal scroll bar in, but then kills off all the other rich edit functions so it becomes unusable.

I tried with and without RETURN's and returning wParam, and returning zero made no difference.

    SELECT uMsg
           CASE WM_NCCALCSIZE
                INT style = GetWindowLong(hWnd, GWL_STYLE)
                SetWindowLong(hWnd, GWL_STYLE, style & WS_HSCROLL)
                RETURN CallWindowProcA(GetPropA(hwnd,"edit_handler"),hwnd,uMsg,0,lParam)
                'RETURN CallWindowProcA(GetPropA(hwnd,"edit_handler"),hwnd,uMsg,wParam,lParam)

Any ideas?

Thanks,
Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

Thanks! Glad to see you too. I'm following your editor progress :)

Sorry, I made a few mistakes, first the subclass needs to be done on the richedit, not the main window and you have to replace the symbol "&" for "|", and you have to add WS_VSCROLL too. Here's a complete example, you have to add some lines for the scroll to appears but you should see both scrollbars, and in theory this will not interfere with the rest of your code.

$INCLUDE "windowssdk.inc"

CONST RICHEDIT_1 = 1
WNDPROC origRichProc
WINDOW w1
OPENWINDOW w1,0,0,600,400,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&w1_handler
CONTROL w1,@RICHEDIT,"",7,35,570,294,0x50B010C4,1

' subclass the richedit
origRichProc = SetWindowLong(GetDlgItem(w1.hwnd, RICHEDIT_1), GWL_WNDPROC, &richProc)

' redraw the window
RedrawWindow(w1.hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN)
InvalidateRect(w1.hwnd, NULL, NULL)

' main loop
WAITUNTIL w1 = 0
END

' window procedure
SUB w1_handler(), INT
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
' remove the subclass
SetWindowLong(GetDlgItem(w1.hwnd, RICHEDIT_1), GWL_WNDPROC, &origRichProc)
CLOSEWINDOW w1
ENDSELECT

RETURN 0
ENDSUB

SUB richProc(hWnd:INT,uMsg:INT,wParam:INT,lParam:INT),INT
SELECT uMsg
CASE WM_NCCALCSIZE
INT style = GetWindowLong(hWnd, GWL_STYLE)
SetWindowLong(hWnd, GWL_STYLE, style | WS_HSCROLL | WS_VSCROLL)
ENDSELECT

RETURN CallWindowProc(origRichProc, hWnd, uMsg, wParam, lParam)
ENDSUB


Andy

Thanks,

I can see you have put a lot of work into this.

A long way back I decided to hide the built in vertical scroll bar as it moves up and down a lot when colouring.

As your example needs the vertical scroll bar I can't use it unfortunately. :'(

I do however have a work around. When you now try to click on the "bottom line" where a horizontal scroll bar would be, I set the edit position to my "actual bottom line" i.e. the one above. :)

But thanks again,
Andy.
 
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

It took me 5 min to write that text, don't worry. I have pre-made snipplets for every control, I once did the same thing (hidding/showing the scrollbars) for a listview, so I just had to copy/paste some blocks. You can show the horizontal scrollbal and hide the vertical scroll with the following update to my example

SUB richProc(hWnd:INT,uMsg:INT,wParam:INT,lParam:INT),INT
SELECT uMsg
CASE WM_NCCALCSIZE
INT style = GetWindowLong(hWnd, GWL_STYLE)
style = style | WS_HSCROLL
style = style & NOT(WS_VSCROLL)
SetWindowLong(hWnd, GWL_STYLE, style)
ENDSELECT

RETURN CallWindowProc(origRichProc, hWnd, uMsg, wParam, lParam)
ENDSUB

BUT if you have a workaround that's cool, if something works don't change it!

billhsln

To Fasecero, you say you did snippets for every control, did you comment what each option that goes with each control does?  And would you be willing to share with the user base?  I don't know about anyone else, but this sounds like it would be extremely useful.  I know I keep having to go back and forth between old code I have done and the IWB documentation.  Even after all that there are times I can't find exactly what I am looking for and then go to the forum.  If I can't find it on the forum, I ask (love the forum, great place get answers).

Just asking, if you are willing.

Thanks,
Bill

PS, I know Spanish is your native language, but I think I could put it thru Google Translate or some other web based thing to convert it to english.  If I get that to work, I will pass it along in english (of course, your name has to be associated with it).  Will also let people know where I got it translated, so they can do it in their language.
When all else fails, get a bigger hammer.

fasecero

Hello Bill. I may have used wrong words, I'm so sorry. The snipplets for every control I'm refering to resides inside many folders (more than 600) written in EB, IWB, FreeBasic, C++, and .net. When I see I can answer on a particular topic I know more or less where do I have to look, but many times I have to convert the code first. For the example above, I have used a listview example written in C++ long time ago. I think I have no way to post all these info.

Andy

Bill,

You are absolutely spot on.

This happens to me all the time - and I agree with you about how good the forum is regarding help.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

billhsln

To Fasecero, I understand. I keep lots of code in the Snippet Manager and still end up looking thru all the code I have created over the years.  It is amazing how much code I have written in 40 years.

Thanks for the reply,
Bill
When all else fails, get a bigger hammer.