Subclass, custom, etc.
I am using
C++11.I want to hide the scrollbar when not needed.
CodeBlocks 17.12 .
32 bit.
I want to show the scrollbar only when it is needed.
Would it be easier to CreateWindowExW two
Expand|Select|Wrap|Line Numbers
- h_BoxThatScrolls = CreateWindowExW
- (
- WS_EX_CLIENTEDGE,
- L"edit",
- 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",
- WS_CHILD | ES_MULTILINE | ES_WANTRETURN | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL,
- 10, 10,
- 100, 100,
- hwnd,
- (HMENU) BoxThatScrolls,
- GetModuleHandle( nullptr ),
- nullptr
- );
and
Expand|Select|Wrap|Line Numbers
- h_NoScrollBox = CreateWindowExW
- (
- WS_EX_CLIENTEDGE,
- L"edit",
- L"Lines of Stuff\r\n1\r\n2\r\n3",
- WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL | ES_MULTILINE,
- 10, 10,
- 100, 100,
- hwnd,
- (HMENU) NoScrollBox,
- GetModuleHandle( nullptr ),
- nullptr
- );
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.
orMaybe 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.