i am creating a small BUTTON window using CreateWindowEx api and setting its parent to the form window.
The newly created child button is added successfully to the form's client area as expected but when I scroll the parent window, the child button remains in its initial position and doesn't follow the scrolling.
Is there a window style bit that I should set in the parent or in the child window so parent and child become synchronized when scrolling the parent form?
This is a tricky thing to do. I'll put together a little sample project where I'm doing this. Give me a few.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Ok, here's a little demo project that shows how I do it. It does use subclassing so be careful. Ideally, you'd always shut down your program by closing all its forms, as that'd protect the IDE.
EDIT: You know? Maybe I missed the point. When I initially read your post, I was thinking the non-client area. For the client area, why not just create the controls with the IDE tools you have?
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Ok, here's a little demo project that shows how I do it. It does use subclassing so be careful. Ideally, you'd always shut down your program by closing all its forms, as that'd protect the IDE.
EDIT: You know? Maybe I missed the point. When I initially read your post, I was thinking the non-client area. For the client area, why not just create the controls with the IDE tools you have?
Thanks.
Using native vb form controls will defeat the purpose of what I am trying to do which is to make this work with a child win32 control created from scratch in order to learn if & how this can be done.
I can subclass the parent window and intercept the scrolling message and reposition the child button accordingly but I thought there might be a window Style or Extended Style that I could set to make child and parent synchronized.
I wonder how vb does this behind the scenes with the forms controls.
Last edited by JAAFAR; Nov 23rd, 2021 at 12:04 PM.
if u want to create custom buttons, why not just skip the hassle with child-forms and other outdated component and instead create your own using any of the graphic engine we have such as gdi/cairo/d2d/directx etc.
that will give u more freedom and also stability.
if u want to create custom buttons, why not just skip the hassle with child-forms and other outdated component and instead create your own using any of the graphic engine we have such as gdi/cairo/d2d/directx etc.
that will give u more freedom and also stability.
As I said, I am just wanting this for the sake of learning and to see if\how this can be done.
Basically, it sounds like you're trying to do what Krool has already done for us.
Krool has put in a tremendous amount of work giving us a complete set of controls that are created from scratch. See the CodeBank for his work, or you can look at my onesie-twosie examples of his work where I've peeled it apart into individual controls.
It will take some work on your part to just follow through the code on one of his controls, but it does seem like that's what you're wanting.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Basically, it sounds like you're trying to do what Krool has already done for us.
Krool has put in a tremendous amount of work giving us a complete set of controls that are created from scratch. See the CodeBank for his work, or you can look at my onesie-twosie examples of his work where I've peeled it apart into individual controls.
It will take some work on your part to just follow through the code on one of his controls, but it does seem like that's what you're wanting.
Thanks for the info. I will take a look at Krool's work.
. . . but when I scroll the parent window, the child button . . .
Which API do you use to scroll tha parent window?
Sending WM_MOUSEWHEEL messages to a hWnd does not scroll anything per se. It's each window's custom drawing routines responsability to adjust virtual viewport or top index or whatever method they use internally to implement visual scrolling.
Do you offset parent window's client area somehow and expect child windows to recognize something has changed in the parent drawing settings?
The easiest 100% working, no lagging method to implement child controls scrolling is to place a *second* container inside your parent window which will server as a virtual canvas (the whole area to be explored) so you can reposition it on scroll notifications into negative coords and emulate scrolling of the parent window "viewport".
The easiest 100% working, no lagging method to implement child controls scrolling is to place a *second* container inside your parent window which will server as a virtual canvas (the whole area to be explored) so you can reposition it on scroll notifications into negative coords and emulate scrolling of the parent window "viewport".
</wqw>
That sounds like a good idea to avoid lagging. Never done anything like that before but I will try to give it a shot and see.