Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Setting Focus on Scrolling Window

rtsmith
Beginner
410 Views
After a lot of agony, I have now managed to get my scrolling window to work. However, I have come up against a problem regarding using the page-up and page-down buttons. Jugoslav Dujic sent me a program which filled a scrolling window and allowed the vertical scroll bar to scroll the window contents up and down. This is now working in my own program.
However, in his WM_VSCROLL clause, he has the following code:
case(SB_PAGEUP)
newPos = iPos - MAX_LINES !Subtract one page
case(SB_PAGEDOWN)
newPos = iPos + MAX_LINES !Add one page
to allow the user to page up and down with the up/down buttons. Unfortunately it does not work because it does not allow a focus onto the screen itself. This is the CreateWindowEx code:
ghwndMain = CreateWindowEx( 0, lpszClassName, &
lpszAppName, &
WS_OVERLAPPEDWINDOW.OR.WS_VSCROLL, &
CW_USEDEFAULT, &
0, &
CW_USEDEFAULT, &
0, &
NULL, &
ghMenu, &
hInstance, &
NULL &
)
I would imagine that one of these parameters must be set to allow the screen not to be unavailable to the user, but working through the help for the command, I cannot determine which one it is.
Please could you indicate how to make the scrolling screen able to be focused upon so that I can do the page up/down.
My next task is going to be to allow the user to type an answer into the window on the presentation of a suitable question. I will also need to allow focus to do this.
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
410 Views
Hi Richard,

I hope you overcame your recent painting problems -- did you?

There's nothing suspicious about that CreateWindow call itself -- the problem has to lie elsewhere.

One simple case is that your window ended up disabled somehow; however, that would require that you have called EnableWindow(FALSE) yourself. So, you can test the enabled state of the window using IsWindowEnabled routine, but I guess it will return TRUE.

Other than that, there could be a lot of reasons why you cannot access the window. Note that, if the window's caption is blue, that means it is enabled.

However, default Windows scrollbars act a bit strangely -- that's probably a remnant from Windows 3.x days. Namely, they don't "stick" when user moves them -- instead, the application has to process WM_*SCROLL message and adjust their position itself, in a manner similar to what I have shown. Did you include SB_LINEUP/LINEDOWN cases in your code -- these handle the click on scrollbar's arrow? SB_PAGEUP/SB_PAGEDOWN handle the click on scrollbar's empty area.

Jugoslav
0 Kudos
Reply