473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How To Auto-Hide Scrollbars On Edit Control ? C++

SwissProgrammer
220 128KB
I was reading about How To Auto-Hide Scrollbars On Edit Control and I did not like the complicated ways that were suggested.

Subclass, custom, etc.


I am using
C++11.
CodeBlocks 17.12 .
32 bit.
I want to hide the scrollbar when not needed.
I want to show the scrollbar only when it is needed.

Would it be easier to CreateWindowExW two


Expand|Select|Wrap|Line Numbers
  1. h_BoxThatScrolls = CreateWindowExW
  2.             (
  3.                 WS_EX_CLIENTEDGE,
  4.                 L"edit",
  5.                 L"Lines of Stuff\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30",
  6.                 WS_CHILD | ES_MULTILINE | ES_WANTRETURN | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL,
  7.                 10, 10,
  8.                 100, 100,
  9.                 hwnd,
  10.                 (HMENU) BoxThatScrolls,
  11.                 GetModuleHandle( nullptr ),
  12.                 nullptr
  13.             );
and
Expand|Select|Wrap|Line Numbers
  1. h_NoScrollBox = CreateWindowExW
  2.             (
  3.                 WS_EX_CLIENTEDGE,
  4.                 L"edit",
  5.                 L"Lines of Stuff\r\n1\r\n2\r\n3",
  6.                 WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL | ES_MULTILINE,
  7.                 10, 10,
  8.                 100, 100,
  9.                 hwnd,
  10.                 (HMENU) NoScrollBox,
  11.                 GetModuleHandle( nullptr ),
  12.                 nullptr
  13.             );
Make the NoScrollBox visible.
Make the BoxThatScrolls invisible or hidden.
Make these the same size (width and height) and position them in the same place.


Put text into the NoScrollBox.

If the text (and whatever else is there) takes up more vertical room than the height of the NoScrollBox, put that stuff into the BoxThatScrolls. Make the NoScrollBox invisible. Make the BoxThatScrolls visible. Or set the zorder for that.
or
Maybe only use text and limit the length of each text line that I put in so that it will not go past the horizontal width of the edit window and then count the line returns ("\r\n") and if the line returns are above a certain total, use the BoxThatScrolls. That seems easy enough.



I am learning how to use CreateWindowExW and as I study it I have tried to get an easy answer (that I can easily understand) for this question.

Helpful comments, and of course code, are welcome.


Thank you.
Jan 1 '21 #1
0 1517

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kevin Myers | last post by:
Hello, Please forgive my reposting of this note with hopefully a more relevant subject line. On an Access 2000 form under Windows 2000 I would like to use a Kodak Image Edit Control to...
0
by: perspolis | last post by:
Hi all I used DHTM Edit Control to show body of an HTML file. With this control user can edit content of that. One problem I have with this control is I can't show unicode content. How can I...
1
by: metridevkk | last post by:
Hi, I need to use a Masked Edit Control in my ASPX page. In VS.Net, I added the reference to MSMask.dll for my application & also added the MaskEdBox to the Toolbox. After adding the control to...
1
by: david | last post by:
Anybody could give me hint how use this control in asp.net web form. The problem is: I try to use COM component in my web form app by using MS training kit for windows form application. I would...
7
by: Mike | last post by:
Hello, I am developing a simple web editor to enable my users to update their websites and add simple formatting to the text. The page content is recovered from a SQL Server database and...
1
by: Kostis | last post by:
Hello there! I have created a windows application in VB.NET and I want to retrieve data from an access database. I create the OleDbConnection, an OleDbAdapter, a dataset and finally a Data Form...
3
by: Panos | last post by:
Hi all, I can't clear a Masked edit control. I use it to input dates, so I have defined the mask as "##/##/####". I use the the well known meb.mask="" meb.text="" , but nothing happens. Does...
2
by: Mick_fae_Glesga | last post by:
Hello everyone! OK, I'm writing a windows program that requires the user to enter Cyrillic characters into an Edit control. But, I can't seem to get the Cyrillic characters to appear in the...
5
by: shakthi | last post by:
Hi all, Am new to MFC appilcation programming.Plese tell me how to display a file with its path that is chosen from a file dialog.Am trying to create a dialog box displaying a list of...
2
by: crapycoder | last post by:
hi all, please help....!! i have added a kodak image edit control on my form. when i click get image button, "abc.img" will be displayed. i have a button named "copy to clipboard". when...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.