[C++] Window/Dialog: Which do I use and how?

Pages: 12
It should say need size of client area to set nPage I guess. In terms of the 489, that number was the result of successive approximations I made when I created the app and put all the text boxes on it that I wanted. So in other words, if your main program window is 300 pixels up/down but you need 600 pixels to fit everything you want to be able to show, then your nPage will be 250, and your nMax will be 600 - or zero based 599.

If nMax < rc.bottom, I expect the scroll bars will disappear. Try incrementally reducing nMax and eventually you should obtain that outcome.
Last edited on
That makes sense. After working with it a bit, I find that when I use the scrollbar, the entire window, and thus the scrollbar as well moves rather than the content. This means a new window inside the one that owns the scrollbar I assume, but then how do I access the child to move it rather than the window? Also, how do I get the information out of the edit boxes? I'm guessing these answers are closely related.
Did you compile and run my examples meesa? The way they work should be your guide. Unless there is something wrong that the examples don't work on your computer (but they do on mine), what you should see as you click the up or down scroll buttons, or drag the thumb, is that the pane window on which the text boxes are sited moves, allowing you to view and interact with an area about twice the size of the parent window. From what you are describing, if I'm interpreting it correctly (and that is a big if), the thing isn't working...


the entire window, and thus the scrollbar as well moves rather than the content


See...that isn't right. That's why I'm asking if you compiled and ran my example.

In terms of getting data out of the text boxes, you use GetWindowText(). SetWindowText() programitically puts text in a text box.

You probably should start with introductory programs. If this is your first Windows GUI program you are tackling a lot to start.

Oh! Just another thought! The whole context for that program is Windows CE where you have postage stamp sized screens. You don't have to deal with window sizing there. Its either maximized or minimized with no inbetween. On a desktop/laptop, unless you create the main window with styles so it can't be resized, you are going to have to handle the WM_SIZE message. In one of mrfaosfx's recent threads...

http://www.cplusplus.com/forum/windows/33638/

(eighth post I think) I posted another scrolling demo with a resizable window that handles WM_SIZE. I'm going to be too busy for a day or two to get back to this and fix it for you by adding a WM_SIZE handler. Maybe somebody else can jump in before I get to it.
Last edited on
Scroll code in Windows is brutal. It'll eat you alive!
Missed one line, I'm going to guess that's my issue. (Find out in a few) But in answer to your question, I'm not directly using your code, I'm merging it into my project.

Also, I have done other stuff before this, and I knew about GetWindowText, but since I don't have HWND's to work with, I take it I use enumchildwindows to get all their contents?

but since I don't have HWND's to work with, I take it I use enumchildwindows to get all their contents?


Typically, you specify equates for the control ids of all child window controls such as edit controls, buttons, list boxes, you name it, and if you know the parent of a child window control, you get the HWND with...

GetDlgItem(hParent, ID_CONTROL);

For that reason they never need to be globals - their control ids act as proxies for thiir HWNDs.
Ahh, so that's why I made all those. :)

Although, would it be dirty to use the enum way? It would be a lot less code that way.
Whew! EnumChildWindows() is a very, very last resort for me to try to get a HWND. I cant imagine how you can think creating a callback function to list god knows how many child windows and trying somehow to match them up is easier than this for getting text out of ID_TEXT1....

1
2
TCHAR szBuffer[256];
GetWindowText(GetDlgItem(hParent,ID_TEXT1), szBuffer, 256);


Let's just say it gets repetative after 26 times. And that list will grow once I get everything figured out. But, since all my numbers are in succession, I might try a loop or something. Either way, Note to self: Don't use EnumChildWindows unless you want ALL the windows.

BTW, I got the scrolling issue figured it. Because I made the part that scrolled a second level window, I was changing procedures, thus I wasn't moving the right HWND. So I made myself a struct and stored the HWND there.
Topic archived. No new replies allowed.
Pages: 12