Click to See Complete Forum and Search --> : Drawing & Dragging Simple Controls


Ali Imran
March 19th, 2005, 03:48 AM
Hi gurus

What I want is not that hard to understand.
I am trying to write a small resource generator not the resource editor.
The applciation I am trying to write will allow user to create simple controls like button, combox, listox, toolbars, radio, check, prograssbar etc over the dialog.

I can create button at runtime by creating new window. But I want it to be dragged by user mouse at runtime. Is there any way I can put a layer over the said controls and let the top layer capture the moue events so that user can drag the controls.

Do I have to create simple transparent window over the actual control, and draw a rectangle with 4 edges so that the user can resize the control through them? or is there a better way to do this?

Will there be any kind developer to write a small example for me just to draw a button over a dialog using mouse and allow user to resize it, and especially retrieve the coordinates of drawn objects.

If possible please let me know the besr way to maintain the list of controls in an array.

NOTE: Attached Image will give you more clear Idea of what I am taking of.

I need to get it done in WINAPI (no MFC at all).

Any help or direction is highly appreciated.

I will be waiting for the kind informative reply.

regards

kkez
March 19th, 2005, 07:59 AM
If you want some easy control to resize the control, and you don't mind about the rectangle with the 4 black vertex:
1) to allow resizing, just add WS_THICHFRAME to every window you create. Then you should only handle WM_SIZE/WM_SIZING to update the control's properties. In this way Windows will draw a border around the control, i know it's odd but...
2) to allow dragging, just handle WM_MOUSEMOVE and make sure wParam is MK_LBUTTON (that is, user is moving mouse holding down the left mouse button), then use SetWindowPos with SWP_NOSIZE (to maintain the current size) Ex:
case WM_MOUSEMOVE:
{
if (wParam != MK_LBUTTON)
break;

SetWindowPos(hButton, ......, SWP_NOSIZE)
}
Of course you should subclass every control you add, to handle all these messages.

Ali Imran
March 19th, 2005, 09:43 AM
That is outstanding mate ;)

It is good to use some predefined features rather than creating new layers.

Q. Can I find a developer to write such applciaton for me a give me the full souce?

I dont know if it will be agaisn the forum rules, but I will gladly pay reasonable amount for it, or add full credit to the developer in the final applciation on the new site will will be launching.

Why cant I do all that stuff easily?
Becuase I am almost a beginner in WINAPI (not in c/c++).

regards